Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Assignment - 1.3: Questions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Data Structures and Algorithms

Assignment – 1.3
QUESTIONS
This assignment contains 10 questions covering Trees, BST, Heap and AVL

Tell yourself, “Definitely I can do well”.

************************************* All the Best ***********************************

1. Which of the following is true for computation time in insertion, deletion and
finding maximum and minimum element in a sorted array?

a. insertion – O(1), deletion – O(1), maximum – O(1), minimum – O(1)

b. insertion – O(1), deletion – O(1), maximum – O(n), minimum – O(n)

c. insertion – O(n), deletion – O(n), maximum – O(1), minimum – O(1)

d. insertion – O(n), deletion – O(n), maximum – O(1), minimum – O(1)

2. The time complexity to build a heap of ‘n’ elements and Heap sort is____ and
_______.

a. O(log n) and O(n)

b. O(n) and O(n log n)

c. O(n) and O( log n)

d. O( n log n) and O(n)

3. Consider a array representation of ‘n’ element binary heap where the element are
stored from index 1 to index n of the array. For the element stored at index i of the
array (i<=n), the index of parent is______________

a. Floor ((i+1)/2) b. ceil((i+1)/2) c. floor(i/2) d. ceil(i/2)


4. What is the maximum height of any AVL tree with 7 nodes. Assume that height
of the tree with single node is 0.

a. 2 b. 4 c. 3 d. 5

5. The following numbers are inserted into an empty binary search tree in the given
order: 10, 1, 3, 5, 15, 12, 16. At which level would 5 be inserted? Assume that root has
level 1.
A) 2
B) 3
C) 1
D) None of the above

6. Given the following numbers, arrange them into a Binary Search Tree. Let the root be
at position 1. If a node is at position is i, the left child will be at position 2i and right
child at 2i+1 ( i.e. the right child of root will be at position 3).
While forming a binary search tree by inserting 9, 5,1,12,6,7,8 in order, which positions
will be filled?

A). 1,2,3,4,5,11,23
B). 1,2,3,6,5,10,20

C). 1,2,4,8,3,6,12
D). 1,2,3,4,5,6,12

7. which of the following can be the sequence of nodes examined in BST while searching
for key 88?

A). 90,40,65,50,88
B). 90,110,80,85,88

C). 190,60,90,85,88

D). 65,140,80,70,88
8. The following there are known to be preorder, inorder and post order sequences of a
binary tree. But it is not known which is which.

I. M B C A F H P Y K

II. K A M C B Y P F H

III. M A B C K Y F P H

Pick the true statement from the following:

A) I and II are preorder and in order repectively.

B) II and III are Preorder and postorder respectively.

C) II is the inorder but nothing about other two.

D) II and III are the preorder and inorder respectively

9. We are given with set of ‘n’ distinct elements and a unlabelled binary tree with ‘n’
nodes. In how many ways we can populate the a tree with a given set , so that it
becomes a BST?

A) 0 B)1 C) n! D)2nCn/n+1

10. I. The time taken to find the maximum element in a max heap is O(n)

II. The worst case time complexity of search an element in BST is O(logn)

III. AVL tree is used to search element in O(n)

IV. The time taken to find the minimum element in min heap is O(1)

Which of the above statement is/are false?

A) I and II only

B) I,II and III only

C) I, III and IV only

D) All the above

You might also like