






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: Allocated Tree, Processes Elements, Finserting an Element, Allocated Tree, Binary Tree, Implementing, Dynamic Binding
Typology: Exams
1 / 10
This page cannot be seen from the preview
Don't miss anything!
Name:
(1.1) T F An inorder traversal always processes the elements of a tree in the same order, regardless of the order in which the elements were inserted.
(1.2) T F The running time Reheap-Down in O ( logN ) where N is the number of elements in the heap.
(1.3) T F The largest value in a binary search tree is always stored at the root of the tree.
(1.4) T F An O ( logN ) algorithm is slower than an O ( N ) algorithm.
(1.5) T F Inserting an element onto an unsorted list takes O (1) time.
(1.6) T F To delete a dynamically allocated tree, the best traversal method is postorder
(1.7) T F When building a binary search tree, the order in which elements are inserted in the tree is unimportant.
(1.8) T F Derived classes have access to the private members of their base classes.
(1.9) T F Suppose that a complete binary tree containing 85 elements is stored in an array tree[]. The subtree rooted at tree[10] is a full binary tree with four levels.
(1.10) T F Implementing a priority queue using a heap is more efficient than using a linked-list.
(2.3) Explain the following terms:
activation record:
run-time stack:
header and trailer nodes:
dynamic binding:
(2.4) Label the following binary tree with numbers from the set {6,22,9,14,13,1,8} so that it is a legal binary search tree (you can choose the numbers in this set in any order).
Show how the tree above would look like after each of the following operations: (i) delete 13 (ii) insert 34 (use the original tree)
(2.5) Compare recursion with iteration in terms of (i) time, (ii) memory, and (iii) efficiency.
(2.6) Trace the function below and describe what it does.
template
(b) [10 pts] Implement the new push function and the derived class’s constructor.
(c) [5 pts] Which functions and from which class should be declared as virtual?
(5) [15 pts] Write a client boolean function that determines if a binary search tree and an unsorted list contain exactly the same elements. Analyze its running time performance using big-O. The specifications of the binary search tree and unsorted linked-list are given in the next page.