Assignment Questions S2
Assignment Questions S2
Task Q. Questions CO K-
No. No. Level
1 Explain Push and Pop operations of Stack. The following CO1 K2
operations are performed in a empty stack, Push(10), Push(20),
Pop, Push(30), Push(40), Pop, Pop, Push(50), Pop. What will be
the value at top of the stack?
2 A max-heap initially has five elements with the level-order traversal as CO2 K3
follows: 80, 65,57,49,34,27,12
Two elements '10' and '17' are inserted in the heap in that order. After
insertion of these elements in the heap, discuss the level-order traversal
of the heap.
5 Write an algorithm for Merge sort. Show the intermediate steps CO5 K3
when the following numbers 398, 165, 183, 789, 274, 412, 907,
321, 823, and 120 are sorted using Merge sort.
1 Explain the Push and Pop operations of Stack. The sequence of CO1 K2
operations performed on stack are PUSH(40), PUSH(20), POP,
PUSH(60), PUSH(10), POP, POP, POP, PUSH(30), POP. What is the
sequence of the value popped out?
2 Write the Infix to Postfix algorithm. What is the postfix expression for CO2 K3
the infix expression (A / B) + [(C * D) /F + D] /E?
5 Discuss Partition algorithm for Quick sort. Sort the following CO5 K2
numbers 555, 222, 155, 622, 302, 421, 829 using Quick sort
algorithm.
3. 1 Intrepret the complexity of the following function. CO1 K2
(i)function()
{
int i, j, k;
for(i = n/2; i<=n; i++)
for(j= 1; j<=n/2; j++)
for(k=1;k<=n; k=k*2)
print(“Welcome”);
}
2 Consider the following list of numbers which are inserted in the CO2 K3
order into an initially empty binary search tree
{12,23,5,67,43,31,39,56,72} What is the post-order traversal
sequence of the resultant tree?
2 Construct binary max-heap tree for the following list of elements. 15, CO2 K3
17, 14, 9, 13, 26, 11. What is the array that represents a binary max-
heap?
3 A hash table contains 10 buckets and uses linear probing to resolve CO3 K3
collisions. The key values are integers and the hash function used
is key % 10. If the values 85,47,33,63,72,29 are inserted in the
table, in what location would the key value 142 be inserted?
4 Discuss the topological sorting algorithm and find the solution CO4 K3
to the following instance of Topological sorting problem.
5 Discuss a Partition algorithm for Quick sort. Sort the following CO5 K2
numbers 23, 49, 59, 31, 46, 82,34 using Quick sort algorithm.
5. 1 Interpret the complexity of the following functions CO1 K2
function ()
{
i=1;
s=1;
while (s <= n)
{
i++;
s = s+ i;
print(“welcome”);
}
}
2 Consider the following inorder and preorder traversal of a binary CO2 K3
tree
Pre order → ABCEIFJDGHKL
In order → EICFJBGDKHLA
What is the post order traversal of a binary tree?
3 Consider a hash table of size seven with starting index zero and a CO3 K3
hash function (6x+3) mod 4. Assuming the hash table is initially
empty. What is the content of the table when the sequence
1,3,8,10,5 are inserted into the table using closed hasing? (Note –
Use ‘-‘ to denote empty location in the table)
4 Give Breadth First Search Algorithm. Illustrate BFS graph CO4 K3
traversal for the following graph.
5 Discuss Insertion sort algorithm. Sort the following numbers 43, CO5 K2
45, 23, 50, 35, 46,92, 87,76 using Insertion sort algorithm.
1. The seven elements M,N,O,P,Q,R,S and T are pushed onto a CO1 K2
6. stack in reverse order (starting from T). The stack is popped five
times and each element is inserted into a queue. Two elements
are deleted from the queue and pushed back onto the stack.
One element is popped from the stack. What is the popped
item?
2 Consider the following list of numbers which are inserted in the CO2 K3
order into an initially empty binary search tree 100, 830, 645, 248,
435, 176, 989, 100, 439. What is the pre-order traversal sequence
of the resultant tree?
3 Explain B-Tree. Insert the following set of numbers in a B-Tree. CO3 K3
21,34,11,42,56,73,82.
4 Give Dijkstra’s algorithm and Illustrate Dijkstra’s algorithm for CO4 K3
the following graph.
5 Write an algorithm for Bubble sort and sort the following list of CO5 K3
numbers using Bubble sort algorithm.
74, 56, 65, 12,47, 81, 42, 59, 20
1. Consider the following postfix expression with single digit CO1 K2
operands: 9 2 3 * / 8 2 * + 5 8 * -. What is the top two elements of
the stack after the second * is evaluated?
2. The elements 32, 25, 80, 56, 78, 43, 67 are inserted one by one in CO2 K3
the given order into a max-heap. What is the array representation
of the resultant max-heap?
3. Show how many rotations are required during the construction CO3 K3
of an AVL tree if the following elements are to be added in the
given sequence. 75, 57, 43, 25, 36, 66, 78, 20, 28.
4. Discuss the topological sorting algorithm and find the solution CO4 K3
to the following instance of Topological sorting problem.
7.
.
5. Write an algorithm for Selection sort and sort the following list of CO5 K3
numbers using Selection sort algorithm.
54, 26, 93, 17,77, 31, 44, 55, 20