Rany Audeh |
The Question covers Complexity and Recursion (
5 Marks ): a.(2 Marks) Express the complexity of the following code using Big-O notation. Explain how you reached your answer. for ( i = 1 ; i <= n ;i ++ ){ if ( a[i] > 0 ){ for ( j = 0 ; j< n ; j= j+2) c[i] = c[i] / b[i] ; } else c[i] = b[i] ; } b.(3 Marks) Express the complexity of the following code using Big-O notation. Explain how you reached your answer. What is the value returned if n = 8 initially? private int method1(int n){ if ( n = = 1 ) return 1; else return method1(n/2) +n ; }/method1 |
Dmytro Bernevek |
a) Using the following data crate an AVL tree [24, 32, 29, 10, 26, 9, 47, 51] b) Delete node '47' from the tree and then delete node '26' from the tree. Redraw the tree after every deleton. Do not forget about AVL property after each deletion. |
Janine Imada |
part (a) (5 marks) Convert this CBT into a min heap: [2 5 7 4 9 3 6 8 2]. Redraw the tree after each swap. part (b) (3 marks) Explain, in general terms, how heapsort is applied to a min heap. Be sure to include a diagram of the array in your answer. |
John Athanassiades |
(6 Marks) Given the following input data: [S Y
T W A B] create a BST. As the tree is built, you are required to thread the
tree so that a S.O.T. can be performed (Recall the 2 Rules from our lecture
notes when doing this). In the space below, redraw the tree after EACH insertion
showing the state of the threads. |
Steven Barkovic |
Using the following data, 10 6 11 25 23 20 2 9
7 27 1, construct a BST. Delete the following nodes from the tree 1 9 25. Redraw the tree after each deletion. Determine the average path length before each node is deleted and after each node is deleted. |
Willie Reynolds |
Question covers contiguous storage and binary trees: 1 mark - definition - What is contiguous storage?? 1 mark - Show student a tree and get them to represent it as contiguous storage. ie. Show them Example tree in Dave's notes and must represent this as contiguous storage. Given [ a,b,g,c,f,h,i,d,e]: 1 mark: Calculate the parent of i. 1 mark: Calculate the left child of b. 1 mark: Calculate the right child of g. |
Mwinchande Othman
Chande |
1) a) Given the following numbers create a BST 8,5,15,2,7,11,17,1,6,13. (2 Marks) b) write out the order in which the nodes visited for postorder, inorder, preorder traversal for the BST you created. (3 Marks) c) Draw and label a diagram of the contiguous memory representation of the tree in part a. (2 Marks) d) Show the predecessor and successor threads if the tree in part a was to be threaded for a preorder and inorder traversal. (3 Marks) |
Keita Muto |
Given algorithms f and g where: f(p) = 10p^2 +
45p - 20 and g(p) = 35p + 40, where p is the problem size: 1) At what problem size p is algorithm f and g computationally equivalent? 2) If p was 20, which algorithm should be used? Explain why? |
Geordie Harris |
Given the DAG complete
the following: Give the output when you apply a Top Sort to the graph. Do the same using a stack for output. |
Justin Kalicharan |
Given the CBT [r, t, w, p, v, s, z, b] create a max heap based on the lexicographic properties of the data. Show all steps as a separate tree. |
Joel Glanfield |
When considering traversing a tree, we have 3 options:
S.O.T., Post- Order, and Pre-Ordered traversals. 1) If we wanted to thread a tree after it has been built, which type of traversal would we need to use if we wanted left and right threads? 2) Which type of traversal would not allow a tree to be completely threaded and why? |
Mike Sawyer |
Define a min-heap and a max-heap? and Build a heap from this list of numbers(2,4,5,3,6,8,7,9,10), give the final tree representation and give the final array representation of this heap. |
Darryl Gough |
In point form, discuss the advantages and disadvantages
of the following terms or concepts as they pertain to computer data structures. Recursion vs. Iteration BST vs. Sorted Array Node Deletion from BST vs. Soft (lazy) Deletion from a BST |
Robert Blacklock |
Given 'head' pointing to a linked list contarining
an integer value 'count' and a node pointer 'next'. Write a method, which uses link inversion to print out in reverse order. |