20CS332 - C++ AND DATA STRUCTURES-v1
20CS332 - C++ AND DATA STRUCTURES-v1
THIRD Semester
(Regulations 2020)
1
6. What does the following function do for a given CO3 A
Linked List with first node as head? Justify your
answer.
void fun1(struct node* head)
{
If (head == NULL) return;
fun1(head->next);
cout<<head->data;
}
7. What is the maximum height of any binary search CO4 A
tree with 7 nodes? Assume that the height of a
tree with a single node is 0.
8. Derive the adjacency matrix of the given graph. CO4 A
PART B –– (5 x 16 = 80 Marks)
4
Note:
Assume that PUSH() takes stack
name and element to inserted as
input.
POP() takes stack name from which
element to be popped and second
argument is the popped element.
Write the code in C++ with class
definition to perform PUSH and POP
operation in array based Stack.
ii. Write a routine to traverse the list and (6) CO3 Ap
make the List empty while traversing in
linked list implementation of list with a
pictorial representation.
(OR)
(b) i. Design a Circular Queue using array (10) CO3 Ap
implementation to maintain library book
information like bookId, availability and
price.
Write methods to implement the following
operations using C++:
a. Enqueue
b. Dequeue
c. isFull
d. isEmpty
14.(a) Construct an AVL tree for the data given (16) CO4 An
below. Specify the type of rotations for
5
each of the elements while inserting into
an initially empty AVL tree. 2, 4, 1, 42,
10, 12, 9, 22, 15. Write functions for
single and double rotations in AVL tree.
(OR)
(b) Using Dijkstra’s Algorithm, find the (16) CO4 An
shortest distance from source vertex ‘S’
to remaining vertices in the following
graph. Write the algorithm for the same.
**********