data structure

  

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

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with Answers Market
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
Testimonials
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Psychology
I requested a revision and it was returned in less than 24 hours. Great job!
Customer 452467, November 15th, 2020
Accounting
Thank you for your help. I made a few minor adjustments to the paper but overall it was good.
Customer 452591, November 11th, 2021
Political science
I like the way it is organized, summarizes the main point, and compare the two articles. Thank you!
Customer 452701, February 12th, 2023
Technology
Thank you for your work
Customer 452551, October 22nd, 2021
Business Studies
Great paper thanks!
Customer 452543, January 23rd, 2023
Psychology
Thank you. I will forward critique once I receive it.
Customer 452467, July 25th, 2020
Political science
Thank you!
Customer 452701, February 12th, 2023
Education
Thank you so much, Reaserch writer. you are so helpfull. I appreciate all the hard works. See you.
Customer 452701, February 12th, 2023
Finance
Thank you very much!! I should definitely pass my class now. I appreciate you!!
Customer 452591, June 18th, 2022
11,595
Customer reviews in total
96%
Current satisfaction rate
3 pages
Average paper length
37%
Customers referred by a friend
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat