Question 1 (20 POINTS): Decision trees provide an abstraction for comparison sort algorithms. 1.?.) (5 POINTS) Draw a decision tree for Insertion sort on 4 elements. 1.B.) (5 POINTS) What is the shortest path in the decision tree? What does this represent from Insertion sort algorithm standpoint? 1.C.) (5 POINTS) What is the longest path in the decision tree? What does this represent from Insertion sort algorithm standpoint? 1.D.) (5 POINTS) How many leaves are there in the decision tree? What does this represent from Insertion sort algorithm standpoint? Question 2 (20 POINTS): Assume we have n integers that range from 0 to $n^3$-1 in value. What will be the algorithmic complexity of sorting these numbers by using Radix sort? Please show your work.
Added by Samantha C.
Close
Step 1
A. To draw a decision tree for Insertion sort on 4 elements, we start with the initial unsorted array and consider all possible comparisons and swaps until we reach the sorted array. Here is an example of a decision tree for Insertion sort on 4 elements: ``` Show more…
Show all steps
Your feedback will help us improve your experience
Vaibhav Jain and 95 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
This question concerns binary search trees, amortized complexity, and heaps (20 marks total). (a) Define the properties that make a binary tree into a Binary Search Tree (BST). How would a "removeMin" operation be implemented for a BST? That is, show how to find and remove the minimum element of a BST. What is the Big-O complexity of removeMin, in terms of the height h and/or number of nodes n, of the BST? (b) Suppose that a sorting procedure, "BST-Sort", is implemented using a BST - in the same fashion as HeapSort, but instead using a BST. In this procedure, n elements are inserted one at a time into an initially-empty BST, and then removed from the BST using removeMin until the BST is again empty. Assume the BST is a simple one with no mechanism to maintain balance. What is the worst-case complexity of BST-Sort? Justify your answer and give a simple example with n=4.
Sri K.
5. [12 points] Write down the output of the breadth, preorder, in-order and post-order traversal for the given tree. 6. a) [4 points] What is the difference between a binary tree, and a binary search tree? b) [3 points] Give usage example for each one. Question 2 (Graph) – [30 points] For the graph shown in the figure, answer the following questions: 1. [2 points] is the graph directed or undirected? 2. [2 points] is the graph weighted or unweighted? 3. [2 points] is the graph connected or unconnected? [2 points] If it is not connected, give an example of why not. 4. [2 points] is the graph cyclic or acyclic? [2 points] If it is cyclic, give an example of a cycle. 5. [9 points] Write the order that a depth-first search (DFS) would visit vertexes if it were looking for a path from vertex A to vertex I. 6. [5 points] give an application example of a graph with the same properties of this graph. 7. [4 points] What are some differences between tree and graph?
Adi S.
Akash M.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD