






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Main points of this exam paper are: Binary Tree, Implementing Breadth, Maximum Number, Largest Value, Full Tree, Directly Connected, Priority Queue
Typology: Exams
1 / 12
This page cannot be seen from the preview
Don't miss anything!
Name:
(1.1) T F The maximum number of nodes in a tree that has L levels is 2^L
(1.2) T F A queue should be used when implementing Breadth First Search (BFS).
(1.3) T F The largest value of a binary search tree is always stored at the root of the tree.
(1.4) T F A complete tree is also a full tree.
(1.5) T F In a binary tree, every node has exactly two children.
(1.6) T F Tree operations typically run in O ( d ) time where d is the number of nodes in the tree.
(1.7) T F To delete a dynamically allocated tree, the best traversal method is postorder
(1.8) T F In a heap, the left child of a node is always less than the right child of a node.
(1.9) T F Implementing a priority queue using heaps is more efficient than using linked lists.
(1.15) T F The order in which elements are inserted in a binary search tree in unimportant.
(2.1) What is the number of nodes in a full tree with L levels? Prove it (show all the steps care- fully).
(2.2) What is the maximum number of levels (height) of a tree with N nodes? What is the mini- mum number of levels (height) of a tree with N nodes? Justify your answers.
(2.3) Assume A is an array-based tree with 70 nodes.
(2.4) We have discussed two different approaches to implement a priority queue. Which are these two approaches? How do they compare in terms of efficiency (time wise)? Justify your answer.
(2.5) Given the graph below, draw its adjacency matrix representation (store the vertices in alpha- betical order)
(2.9) Show how the tree in (2.8) would look like after each of the following operations:
(i) delete 22
(ii) insert 34 (use the tree from step (i))
(2.10) Given the tree shown below, show the order in which nodes in the tree are processed by preorder traversal.
(2.11) A priority queue is implemented as a heap. Show how the heap shown below would look like after each of the following operations:
37
20 10 2 19
41
66
11 18 6
(i) pq.Enqueue(38);
(ii) pq.Enqueue(102); (use the heap from step (i))
(2.12) Continue problem (2.11) (iii) pq.Dequeue(x); What is the value of x? (use the heap from step (ii))
(v) pq.Dequeue(y); What is the value of y? (use the heap from step (iii))
(3.1) (10 pts) Write a function that returns the largest value in a binary search tree (full credit will be given only to the most efficient solutions).
(3.2) (10 pts) Write a boolean member function IsBST that determines if a binary tree is a binary search tree.