Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Allocated Tree - Data Structures - Exam, Exams of Data Structures and Algorithms

Main points of this exam paper are: Allocated Tree, Processes Elements, Finserting an Element, Allocated Tree, Binary Tree, Implementing, Dynamic Binding

Typology: Exams

2012/2013

Uploaded on 04/07/2013

sethuraman_h34rt
sethuraman_h34rt 🇮🇳

4.3

(8)

159 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 308 Data Structures
Spring 2003 - Dr. George Bebis
Final Exam
Duration: noon - 2:00 pm
Name:
1. True/False (3 pts each) To get credit, you must give brief reasons for your answers !!
(1.1) TFAn inorder traversal always processes the elements of a tree in the same order, reg ardless
of the order in which the elements were inserted.
(1.2) TFThe running time Reheap-Down in O(logN) where Nis the number of elements in the
heap.
(1.3) TFThe largest value in a binary search tree is always stored at the root of the tree.
(1.4) TFAn O(logN) algorithm is slower than an O(N) algorithm.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Allocated Tree - Data Structures - Exam and more Exams Data Structures and Algorithms in PDF only on Docsity!

CS 308 Data Structures

Spring 2003 - Dr. George Bebis

Final Exam

Duration: noon - 2:00 pm

Name:

  1. True/False (3 pts each) To get credit, you must give brief reasons for your answers !!

(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 int Mystery(TreeType *tree, int &n) { if(tree != NULL) { n++; Myster y(tree->left, n); Myster y(tree->right, n); } }

(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.