Data structure | Computer Science homework help

  

Data Structures and Algorithm Analysis

1. How much memory will the following structures take up? Hint: int takes 4 bytes, float takes 4 bytes, char takes 1 byte. – 9 points

a. struct Structure1 {int a,b,c,d,e[10]; float f;};

b. struct Structure2 {int a[12]; float b[5];};

c. struct Structure3 {char a[10][12][4], b[5][5], c[10];};

2. Show the steps when sorting (smallest to largest) the following arrays of numbers using selection sort i.e. every time a swap occurs, show what the current state of the array looks like, including the final sorted array. – 12 points

a. [10, 2, 5, 8, 9, 1, 4, 7]

b. [7, 1, 3, 2, 5, 4, 8, 12, 9]

c. [8, 7, 6, 5, 4, 3, 2, 1]

d. [5, 3, 8, 1, 9, 4, 2, 6]

3. Big-O: What is meant by f(n) = O(g(n))? Give the definition and then explain what it means in your own terms. – 5 points

4. Big-Omega: What is meant by f(n) = Ω(g(n))? Give the definition and then explain what it means in your own terms. – 5 points

5. Show that , make sure you use the definition and justify the inequalities and constants used. – 4 points

6. Show that , make sure you use the definition and justify the inequalities and constants used. – 4 points

7. Show that , make sure you use the definition and justify the inequalities and constants used. – 4 points

8. Show that , make sure you use the definition and justify the inequalities and constants used. – 4 points

9. Show that , make sure you use the definition and justify the inequalities and constants used. – 4 points

10. What principle governs how you add/remove elements in a stack? Spell it out and briefly explain. – 4 points

11. Briefly describe an application of a stack. – 4 points

12. What principle governs how you add/remove elements in a queue? Spell it out and briefly explain. – 4 points

13. Briefly describe an application of a queue. – 4 points

Consider the following graph (pseudocode for BFS and DFS given on page 9):

14. Write the order in which the nodes would be visited in when doing a breadth first search (BFS) traversal starting at node 4. Also, write the distances from 4 to every other node. – 6 points

15. Write the order in which the nodes would be visited in when doing a breadth first search (BFS) traversal starting at node 5. Also, write the distances from 5 to every other node. – 6 points

Same graph (for your convenience):

16. Write the order in which the nodes would be visited in when doing a depth first search (DFS) traversal starting at node 4 (order discovered or order off the stack). – 6 points

17. Write the order in which the nodes would be visited in when doing a depth first search (DFS) traversal starting at node 5 (order discovered or order off the stack). – 6 points

18. Give the definition of a graph. – 5 points

19. Give the definition of a tree (from graph theory). – 4 points

           

BFS Pseudocode (for     graph with n vertices):

Input: grapharray[n][n], source

queue<int> Q

int distance[n] (array to keep     track of nodes distances (from source), all values set to -1 except source     which is set to 0 i.e. -1 = not visited)

Q.push(source)

while(Q is     not empty)

v = Q.front

Q.pop()

for each neighbor w of v

if distance[w] = -1

print w

distance[w] = distance[v]+1

Q.push(w)

end if

end for

end while

         

DFS Pseudocode (for     graph with n vertices):

Input: grapharray[n][n], source

stack<int> S

int visited[n] (array to keep     track of nodes visited, all values set to 0 except source which is set to 1     i.e. 0 = not visited, 1 = visited)

S.push(source)

while(S is     not empty)

v = S.top

S.pop()

for each neighbor w of v

if visited[w] = 0

print w

visited[w] = 1

S.push(w)

end if

end for

end while

Bonus (4 points): Show all of the steps (splitting and merging) when using mergesort to sort (smallest to largest) the following array (they are the numbers 1 through 16):

[16, 1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8]

Bonus (2 points): describe how you could implement a queue using 2 stacks.

Bonus (4 points) Draw the binary search tree that would be constructed by inserting the following values in the exact order given (starting with an empty tree i.e. first value will be the first node in the tree): – 

a. Binary Search Tree A: 8, 9, 2, 7, 1, 10, 3, 5, 6, 4

b. Binary Search Tree B: 10, 7, 9, 12, 4, 2, 5, 3, 1, 14, 11, 19, 13, 18, 20

Get 20% Discount on This Paper
Pages (550 words)
Approximate price: -

Try it now!

Get 20% Discount on This Paper

We'll send you the first draft for approval by at
Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

Custom Writings Help is a Quality-Oriented Company in Online Writing as a result of hiring exceptional professionals to execute clients' tasks.

Essays

Research Papers

At Custom Writings Help,We understand the struggle of research paper writing, and that is why at Custom WritingS Help, we are all out to help you. We pride ourselves on having a team of clinical writers. The stringent and rigorous vetting process ensures that only the 'BEST' Writers are chosen for the job. We have highly qualified Ph.D. and MA writers working with us; we equally offer these experienced writers specific bonuses and incentives to make them deliver highly original, unique, and informative content at reasonably low prices.

Admissions

Thesis Writing Service

Worlwide, Many Masters Students are struggling with Thesis Completion. A thesis is likely to be the longest and most challenging piece of work a student has ever completed. However, unlike essays and other assignments, a student can pick a particular interest topic and work on their initiative. Fortunately, we are there for you. At Custom Writings Help, you are assured of an authentic, imaginative, informative, linguistically great, and advantageous thesis that adheres to all your needs. So, why continue considering different writers when you have discovered the best in the field?

Editing

Custom Papers

Not a single student can avoid writing custom papers. However, a total lack of experience, skills, and time makes it very hard to produce a superb writing piece. Therefore, if you are seeking professional help, turn to us. Our specialized and experienced writers compose a variety of model papers, including custom essays, college term papers, research papers, book reports, MBA essays, executive summaries, dissertations, Ph.D. theses, admission essays, and research proposals for college and university students at any level.

Coursework

Essay Writing

Most of the students disregard the critical principles of essay writing and compose papers below sensible guidelines. Therefore, with Custom Writings Help, one should not worry about his/her essay. Our Writers compose informative and engaging content on all complexities and topics. We write meaningful and smart essays while prioritizing all aspects that bring about a good grade, such as impeccable grammar, proper structure, zero-plagiarism, and conformance to guidelines.

Coursework

Coourse Work Writing

Don't let the seemingly never-ending onslaught of writing assignments get you down. If you are looking where to get course work assistance online, the writers at Custom Writings Help are here to assist you with all of your writing needs. We undertake to unique delivery of papers that meet the professor's requirements. The content is proofread, edited, and checked plagiarism before submission to customers. No matter how big or small your work is, we will deliver on time. Try US Now! !

Coursework

Dissertation Writing Service

High-Quality Dissertation Writing Services are rare. They require Ph.D. academicians – not easily found. However, are an exception. The years, time, and resources we have invested in the dissertation world has given us a competitive advantage over others. Choose to come to Custom Writings Help; You will find perfect Ph.D. consultants who have written hundreds of dissertations theses ready to help you. Let our dissertation-writing services help you craft your dissertation, for you are assured we will give you the results.