Assignment 2 - DS
Assignment 2 - DS
1. Sort following Elements using Merge sort 45, 32, 65, 76, 23, 12, 54, 67, 22, 87
2. Use quick sort algorithm to sort 15,22,30,10,15,64,1,3,9,2. Is it a stable sorting
Algorithm? Justify.
3. The keys 12, 17, 13, 2, 5, 43, 5 and 15 are inserted into an initially empty hash
table of length 15 using open addressing with hash function h(k) = k mod 10 and
linear probing. What is the resultant hash table?
4. Write a quick sort algorithm. Use quick sort algorithm to sort the following element:
15, 22, 30, 10, 15, 64, 1, 3, 9, and 52
5. Use Heap sort algorithm, sort the following sequence:
18, 25, 45, 34, 36, 51, 43, and 24.
6. Describe various ways to select Pivot element in quick short.
7. Differentiate between linear and quadratic probing techniques.
8. Use the merge sort algorithm to sort the following elements in ascending order.
13, 16, 10, 11, 4, 12, 6, 7. What is the time and space complexity of merge sort?
UNIT 4- TREE
1. Examine the minimum number of interchanges needed to convert the array 90, 20, 41,
18, 13, 11, 3, 6, 8, 12, 7, 71, 99 into a maximum heap
2. For a binary tree T, the preorder and in-order traversal sequences are as follows :
In order: H K D B I L E A F C M J G
Preorder: A B D H K E I L C F G J M
(i) Construct a binary Tree.
(ii) What is its Post-order traversal sequence?
3. Write an algorithm to in-order tree traversal of binary tree. Also Construct the binary
tree of the following given traversal order
In-order : M, E, P, A, Q, T, R, C, F, K.
Post-order: M, P, E, Q, R, C, T, K, F, A.
4. For given sequence of numbers, construct a heap and a BST
34, 23, 67, 45, 12, 54, 87, 43, 98, 75, 84, 93, 31
5. Show the maximum number of node in a binary tree of height h is 2h+1- 1.
6. For a binary tree T, the preorder and in-order traversal sequences are as follows :
In order: B C A E G D H F I J
Preorder: A B C D E G F H I J
(i) Construct a binary Tree.
(ii) What is its post-order traversal sequence?
7. The order of nodes of a binary tree in inorder and postorder traversal are as follows:
In order: B, I, D, A, C, G, E, H, F.
Post order: I, D, B, G, C, H, F, E, A.
(i) Draw the corresponding binary tree.
(ii) Write the pre order traversal of the same tree.
8. Construct an expression tree for the following algebraic expression.
(3a-b) ↑2(4c+2d) ↑3
9. Construct an Binary Search tree by inserting the following elements in the order of
their occurrence: 60, 2, 14, 22, 13, 111, 92, 86. Also delete 60 and 14.
10. Write functions to:
i. Count leaf nodes in Binary Tree
ii. Find maximum in a Binary Tree
iii. Count One child Node in Binary Tree