Given the BST to the right, provide the following (Each is independent of the others) (8pts)
- Show the result of inserting 17
- Show the result of removing 27
- Show the result of removing 50
- Show the result of removing 20
- For the graph to the right, provide the following(each is independent of the others) (15pts)
- Show the node order and spanning tree that results from BFS(5)
- Show the node order that results from BFS(4)
- Show the node order that results from the DFS(5)
- Show the node order that results from the DFS(4)
- Construct an adjacency matrix representation for this graph
- Construct an adjacency list representation for this graph
- Find the shortest path from 1 to all other nodes
- Below is the adjacency matrix for a directed weighted graph. Draw the visual representation of the graph it represents (6pts)
| Β | 1 | 2 | 3 | 4 |
| 1 | 3 | 4 | ||
| 2 | 1 | 6 | 8 | |
| 3 | 7 | 9 | ||
| 4 |
- What big O family would you classify the following code fragment as? Why? (6pts)
Writing a Similar Assignment?
Get a Scholar-Written Paper Matched to Your Brief
Every order is handled by a degree-holding expert in your subject β written to your exact rubric, fully original, and delivered ahead of your deadline.
Start My Orderwhile(val> 0)
{
sum += val;
val /= 2;
}
- The below code fragments can be used to implement a list with LIFO behavior(6pts)
N++Β Β Β Β Β Β Β |Β Β Β val = L[n];
L[n] = val |Β Β Β n–;
This code is simple however your boss believes you need to go through all the extra pieces of work and fully implement a stack and follow stack naming conventions.Β Why would that be preferable to the easy to use and implement code above?
- Now for a little bit of a thinker. It is possible that we can see a O(n^2) algorithm perform a task faster then a O(n) algorithm.Β Explain how that may be possible and do these sorts of cases show O() is not useful. (6pts)
- Show the state of each listed data structure after the insertion of the following data
5, 2, 7, 13, 4
Then show me the state of the structure after 1 REMOVE operation. Diagrams are preferable, ensure whatever you choose is very clearly marked. (14pts)
Stack
Max heap
Binary search tree
Hashtable(5 buckets, mod number by 5 for hash algorithm, use chaining for collisions)
- Linked list operations. Write a code fragment for each(code fragment, not entire program!)(8pts)
- p, q, and r are pointers into the list
- Each node in the list has a val and next field
- Assume p, q, and r are initialized properly
- Print the larger of the 2 values of p and q
- Insert r between p & q in the list, where p & q are consecutive items
- Assume p and q point to items in a linked list and that p is to the left of q (p is before q). Write a loop that forces r to visit each node between p and q
- p points to a node in the middle of the list(not beginning or end). Delete the node after p.
- In class, we discussed both Primβs &Kruskalβs algorithms and how they may result in the same or different MST. Provide a graph where they will provide a different MST.(6pts)
- Consider the QuickSort algorithm. Show a reasonable state of the list after the first round of choosing a pivot point and partitioning the list(6pts)
List: 17, 45, 11, 30, 47, 12, 33
- When studying O() we always end up with terms like O(N), O(N^2), O(N^3) even though there are other statements in the code that make up the overall efficiency of the program. For instance take the code below
for(i = 0; i< x; i++)
Stuck on Your Assignment?
Cola Papers Experts Are Ready Right Now
Join thousands of students who submit confidently. Human-written, plagiarism-checked, and formatted to your institution's exact standards.
{
for(z = 0; z < x; z++)
{
Val *= 2;
Tmp += 1;
}
}
while(x != 0)
{
Val β= x;
x–;
}
Return 0;
Would become O(2n^2 + 2n + 1).Β Why does it make sense to drop all of the other numbers and just take the highest-powered term? In this case O(n^2). (6pts)
- Given the graph below, find the solutions to the requested operations and show the process you took to reach those solutions in as much detail as possible(13pts)
- Show the steps in solving the shortest path problem according to Dijkstraβs algorithm when starting at node 6.
- Construct the MST for the graph according to Primβs algorithm starting at vertex 1
- Construct the MST according toKruskalβs algorithm
Our Key Guarantees
- β 100% Plagiarism-Free
- β On-Time Delivery
- β Student-Friendly Pricing
- β Human-Written Papers
- β Free Revisions (14 days)
- β 24/7 Live Support