CPP 1
CPP 1
]
Your Roll No.....
1. Write your Roll No. on the top immediately on receipt of this question paper.
Šection A
1. (a) Draw all possible binary search trees for the three elements A, B, and C. 3
(b) Explain the operation performed by the following code on a singly linked list. 3
void func(int x)
if (tail == 0)
tail = head;
3
(c) 'Stack data structure plays an important role in the implementation of recursion'.
Justify the statement with suitable example.
(d) Where in a max-heap might the smallest element reside, assuming that all elements 3
are distinct? Justify your answer.
3
(e) Consider the following list of numbers:
To search given number in the above list, which of the searching techniques
a
(f What will happen if we attempt to remove a node from an empty queue? Give one 3
way to solve this problem.
(g) In the balanced binary tree given below, how many nodes will become unbalanced 3
when a node is inserted as a child of the node "G"? Justify your answer.
B C
D E F
i. f (n) is O(1).
5
(i) Consider the following sequence of operations on an empty stack:
After performing these operations, what would be the value of the expression
(s+q)? Also show the contents of stack and queue.
Section В
2. (a) Differentiate between Binary Search Tree and Balanced Search Tree. 4
B C
D E F G H
1 J K L M N P
Ο
Q R S
(c) Write member functions to perform the following operations on Queue using array: 6
i. isEmpty()
ii. isFull()
iv. dequeue ()
int myFunc(int n) {
if (n >= 0 && n <= 9)
return n;
A* ((B+C)/D)
for(i=0;i<n;i++)
{ for(j=0;j<n;j++)
{ Statement;
(c) Explain how Master's theorem can be used for solving recurrences giving suitable 6
example.
void fun(int x)
if(x > 0)
fun (x-1);
fun(x-1);
}
5
(b) Create a Binary search tree with the keys inserted in following order:
6
(c) Determine the preorder, inorder and postorder traversals of the following tree:
B C
D E F
(b) Consider the following array-based queue of characters, where queue is allocated 5
n=6 memory cells:
Queue: b, d, a, g
i. enqueue('p')
ii. dequeue ()
iv. enqueue('z')
v. front()
After every operation, show the contents of the queue with front and rear
pointers.
(c) Write member functions to perform the following operations on Doubly Linked List: 6
i. Insertion at head
7 (a) Consider a circular linked queue: (9,8,7,6,5,4,3, 2) such that the cursor 4
points to performing following operations
5. After on this queue, what would be the
front and rear elements of the queue?
5
(b) Write a program to implement the following operations for stack using linked list:
i. isEmpty)(
ii. size()
iii. push ()
iv. pop ()
य पुस्तक ालय
कालिन्दी महाविद्यालGE LIBRARY
LLE
KALINDI CO P.T.O.
5960 8
6
(c) Build a max heap from the following array of numbers:
4, 10, 3, 5, 1, 12, 7, 9