You are on page 1of 4

Candidate Seat no………….

CHAROTAR UNIVERSITY OF SCIENCE & TECHNOLOGY


Fourth Semester of B. Tech (CE/CSE) Examination
May 2022
CE245 Data Structures and Algorithms
Date: 06.05.2022, Friday Time: 10.00 a.m. To 1.00 p.m. Maximum Marks: 70
Instructions:
1. The question paper comprises two sections.
2. Section I and II must be attempted in separate answer sheets.
3. Make suitable assumptions and draw neat figures wherever required.
4. Use of scientific calculator is allowed.

SECTION – I
Q- 1 Answer the questions below.
(i) What is the complexity of running Quick sort on an array of size n, which is already [01]
sorted?

(ii) State True or False: In a linked list representation of the simple queue, insertion should [01]
be performed at end and deletion should be performed from beginning.

(iii) Why is it possible to access elements of an array in random order? [01]


(iv) Given an array A[-3:3, 5:10], Find the address of A[0][8] if array elements are organized [02]
in Column-Major order. Base Address is 200. Each element takes 2 bytes for storage.

Q – 2(a) Convert the following expression into postfix form using stack: A*(B+C)*D-E. Evaluate [03]
the postfix form for A=4, B=8, C= (-2),D=3,E=9.
Q – 2(b) Answer the questions below. (Any Three) [12]
(i) Given code deletes the node which doesn't follow the ascending order sequence from this
linked list : 3>>>4>>>5>>>6>>>7>>>9>>>8>>>10.
Write the correct statements for a1,a2,a3,a4.
node structure is defined using this code:
struct node
{
int data;
struct node * link;
} *head, *p;
Code to remove node is::
struct node *C= head;
while(C->data <= a1)
{
p=a2;
C=a3;
} a4;

Page 1 of 4
Candidate Seat no………….

(ii) Explain the recursion stack for tower of Hanoi for number of discs=3.
(iii) Explain different cases of overflow condition for Circular Queue. Also mention the
condition to display the queue contents for every case.
(iv) Consider the structure to store the details of students who have registered for the Codechef
contest.
struct codechef_contest
{
int rollno;
char firstname[20];
char lastname[20];
};
Details are arranged in ascending order (not necessarily contiguous) by roll numbers.
Mention the efficient approach to change the last name of a student with any given roll
number. Show the steps with any example.

Q–3 Answer the questions below. (Any Three) [15]


(i) Compare Bubble sort and Selection sort for the following example with respect to number
of passes and complexity.
5,6,8,9,10,45,67,89,90,99

(ii) Consider the doubly linked list with data 34,78,65,67,39.


1. Write the steps to insert node with data 100 at end.
2. Write the steps to delete a node with data 67.

(iii) Consider the two sorted list T1: 5,8,11 and T2: 4,6,9,15,20,28. Write steps to merge the
T1 and T2 in ascending order.
(iv) Write steps to replace recursion with a stack, to find the factorial of number 6.

SECTION – II
Q- 4 Answer the questions below.

(i) What is the maximum number of edges in an acyclic undirected graph with n vertices? [01]

(ii) What is the maximum height of any AVL-tree with 12 nodes? [01]

(iii) A simple Graph has 24 edges and degree of each vertex is 4. Find the number of vertices. [01]

(iv) Match the following: [02]

Applications Data Structures


A. Routing tables I. Graph
B. Music Playlist with next and previous navigation II. Tree
C. Function calling and return III. Doubly Linked List
D. Social Network IV. Stack

Page 2 of 4
Candidate Seat no………….

Q-5(a) Justify that hashing is an efficient searching method compared to Linear search and Binary [03]
search.
Q – 5(b) Answer the questions below. (Any Three) [12]

(i) The keys 22, 38, 33, 12, 3, 43, 15 and 85 are inserted into an initially empty hash table of
length 10 using open addressing with hash function h(k) = k mod 10 and linear probing.
What is the resultant hash table and number of collisions?

(ii) Show the adjacency matrix representation of the following graph. Find the in degree and
out degree of every node from adjacency matrix.

(iii) Apply Depth First traversal on following graph. Mention the sequence of each visited node
using stack. Assume that Starting vertex is A and visit the vertices in alphabetical order.

(iv) Define the following terminologies:


1. Complete Graph 3. Perfect Binary tree
2. Weighted Graph 4. Complete Binary tree

Page 3 of 4
Candidate Seat no………….

Q–6 Attempt the following: (Any Three) [15]

(i) Preorder traversals of a binary search tree is given below: 45,11,23,41,39,85,77,68,96.


Construct a binary search tree and write down the postorder traversal.
(ii) What is the advantage of AVL tree over BST? Insert the following keys in an empty AVL
tree. Balance the tree wherever required.
89,67,55,54,34,33,32,22,12
(iii) Draw the recursion tree for preorder traversal of a following binary tree:

(iv) Find the level order traversal of a complete binary tree.


6,3,5,4,18,11,12,16,10,9
Apply the heap sort to arrange the numbers in ascending order.

***

Page 4 of 4

You might also like