You are on page 1of 4

Sample A

Computer & AI Engineering Program


Level 100
Data Structures: CAE Total Marks: 60
Time: 3 Hrs. Final Exam
Q1. Choose the best answer to the following Questions (70 x 0.75 each = 52.5 marks)
1) Disadvantage(s) of arrays is/are: C) abc*+de-+ A) Ο(n)
A) Index value of an array cannot be D) a*b(c+d) B) Ο(n2)
negative 8) Which data structure do we use C) Ο(n3)
B) Elements are sequentially accessed for testing a palindrome? D) None of the above
C) Data structure like queue or stack A) Heap 16) Time required to merge two
cannot be implemented B) Tree sorted lists of size m and n, is
D) There are chances of wastage of C) Priority queue A) Ο(m | n)
memory space if elements inserted in D) Stack B) Ο(m + n)
an array are lesser than the allocated 9) The evaluation of the postfix C) Ο(m log n)
size expression 7 9 3 + 4 / * is: D) Ο(n log m)
2) Which data structure is used for A) 10 17) In the deletion operation of
implementing recursion? B) 49 linked list, the root is replaced by
A) Stack C) 9 A) next available value in the left sub-
B) Queue D) 21 tree.
C) List 10) Which type of data structure B) next available value in the right
D) Array stack is it? sub-tree.
3) The data structure required to A) Linear C) any random value from the heap.
check whether an expression B) Non-Linear D) last element of the last level
contains a balanced parenthesis is? C) Nonconsecutive 18) Can you tell the advantage of
A) Queue D) None of these using the array data structure among
B) Stack 11) Trying to add an element to a full the following statements?
C) Tree stack result in an exception called A) The entities of mixed type of data
D) Array A) overflow types could be easily stored
4) Which data structure is needed to B) inflow B) The access to the elements present
convert infix notation to postfix C) outflow in the array is a little easy
notation? D) underflow C) Always the index number of the
A) Tree 12) __ notation is used for writing an first element present starts from the
B) Branch expression in which binary operators number 1
C) Stack are written in between the operands. D) None of the above
D) Queue A) Infix 19) Which among the following is
5) What is the value of the postfix B) Prefix the queue data structure’s
expression 6 3 2 4 + – *? C) Postfix applications?
a) 74 D) None of the above A) When among the many or
b) -18 13) ___ can be used to check if a multiple users, a resource is shared.
c) 22 syntax has balanced parentheses. B) Balancing of the load.
d) 40 A) queue C) When the transferring of the data
6) Which of the following B) tree is asynchronous
statement(s) about stack data C) list D) All the above
structure is/are NOT correct? D) stack 20) Name the type of data structure
A) Top of the Stack always contain 14) Minimum number of moves among the following that could be
the new node required to solve a Tower of Hanoi used to implement queues?
B) Stack is the FIFO data structure puzzle is A) Linked List type of data structure
C) Null link is present in the last node A) 2n^2 B) Arrays type of data structure
at the bottom of the stack B) 2^n-1 C) Stack type of data structure
D) Linked List are used for C) 2^n - 1 D) All the above
implementing Stacks D) 2^(n - 1) 21) Among the following options,
7) Which of these is a postfix 15) Binary search tree has best case which of the following type of data
expression? run-time complexity Ο(log n). What structure is used in recursion?
A) a+b-c could be the worst case? (where BST A) Queues type of data structure
B) +ab is left or right intended) B) Array type of data structures
Page 1|4
C) List type of data structures B) four D) Multiple other data structures can
D) Stack type of data structures C) one be implemented using arrays.
22) The data structure that allows the D) two 37) What is the output of the
insertion, as well as the deletion from 31) What is time complexity in data following code snippet?
both the ends, are: structure? void solve() {
A) String type of data structure A) The amount of data loss in stack<int> s;
B) Queue type of data structure performing an operation on a data s.push(1);
C) Stack type of data structure structure s.push(2);
D) Dequeue type of data structure B) Time it takes for a data structure s.push(3);
for(int i=1; i<=3; i++)
23) Among the following, what all to perform an operation { cout << s.top() << “ “;
could be done on Linkedlist? C) The cost paid by a data structure s.pop();}}
A) For the binary trees to be in performing an operation A) 3 2 1
implemented D) None of these B) 1 2 3
B) For the stacks and queues to be 32) What is space complexity? C) 3
implemented A) The amount of computer memory D) 1
C) Dynamic Array space freed up for the storage and 38) Which of the following is the
D) All the above operation of a data structure advantage of the array data structure?
24) A full binary tree having n leaves B) The amount of memory space A) Elements of mixed data types can
will have nodes? used for the storage and operation of be stored.
A) 2n-1 nodes a data structure B) Easier to access the elements in an
B) 2n2 nodes C) The amount of memory space array
C) n nodes used for only the operation of a data C) Index of the first element starts
D) log n nodes structure from 1.
25) Postfix form of M*NP+/Q will D) None of these D) Elements of an array cannot be
be. 33) __ is main operations on deque. sorted
A) MN*PQ/+ A) Add item at the front/rear. 39) Which one of the following is an
B) M*NP+P/Q B) Delete an item from front/rear. application of queue data structure
C) *MN/PQ+ C) insert items in position i A) When a resource is shared among
D) MNPQ+/* D)All the above multiple consumers.
26) In which of the following data 34) Which of the following is not the B) When data is transferred
structures can elements be deleted type of queue? asynchronously
easily? Priority queue C) Load Balancing
A) stack Single-ended queue D) All of the above
B) queue Circular queue 40) When a pop() operation is called
C) array Ordinary queue on an empty queue, what is the
D) tree 35) From following which is not the condition called?
27) __ data structures MUST store operation of data structure? A) Overflow
homogeneous data items? A) Operations that manipulate data B) Underflow
A) pointer in a random way C) Syntax Error
B) array B) Operations that perform a D) Garbage Value
C) record computation 41) What is the time complexity of
D) None of these C) Operations that check for syntax the following code snippet in C++?
28) Dynamic memory area. errors void solve() {
A) Stack D) Operations that monitor an string s = "scaler";
B) heap object for the occurrence of a int n = s.size();
C) Hard Disk controlling event for(int i=0; i<n; i++)
D) None of these 36) What is the disadvantage of array { s = s + s[i];} //append
29) If font = rear then queue is. data structure? cout << s << endl;}
A) full A) The amount of memory to be A) O(n)
B) half full allocated should be known B) O(n^2)
C) empty beforehand. C) O(1)
D) None of these B) Elements of an array can be D) O(log n)
30) How many pointers does a accessed in constant time. 42) Which data structures can be
doubly linked list use? C) Elements are stored in contiguous used to implement queues?
A) three memory blocks. A) Stack
Page 2|4
B) Arrays C) O(logn) 54) What would be the number of
C) LinkedList D) O(n * logn) zeros in the adjacency matrix of the
D) All of the Above 48) Which of the implementations given graph?
43) What will be the output of the can be done with LinkedList?
following code snippet? A) Stacks and Queues
void solve() { B) Binary Trees
int dq[10]; C) Data Structures that can simulate
int front = 4; Dynamic Arrays
int rear = 5; D) All the above
for (int i=1; i<=5; i++){ 49) Which represents the Postorder
if (i % 2 == 0) { A) 10
Traversal of a Binary Tree?
dq[rear] = i; rear++;} B) 6
else {front--; A) Left -> Right -> Root
C) 12
dq[front] = i; }} B) Left -> Root -> Right
C) Right -> Left -> Root D) 0
for (int 55) What are the internal nodes of a
i=front;i<rear;i++) { D) Right -> Root -> Left
50) Which statements is true about tree?
cout << dq[i]); }}
A) 1 2 3 4 5 AVL Trees? A) A node has no children.
B) 5 4 3 2 1 A) The difference between the B) A node has at least one child.
C) 1 3 5 2 4 heights of left and right nodes cannot C) A node has a parent.
D) 5 3 1 2 4 be more than 1. D) Any of the above
44) Consider we have a function, B) The height of an AVL Tree always 56) In a tree, N nodes are connected
getLCA(), which returns us the remains of the order of O(logn) with __ edges.
Lowest Common Ancestor between C) AVL Trees are a type of self- A) N
2 nodes of a tree. Using this getLCA() balancing Binary Search Trees. B) N+1
function, how can we calculate the D) All of the above. C) N-1
distance between 2 nodes, given that 51) Which of the following D) Not known
distance from the root, to each node algorithms are used to find the 57) In an AVL tree, what is the
is calculated? shortest path from a source node to maximum allowed height difference
A) dist(u) + dist(v) - 2 * all other nodes in a weighted graph? (balance factor) between the left and
dist(getLCA(u, v)) A) BFS. right subtrees of any node?
B) dist(u) + dist(v) + 2 * B) Djikstra’s Algorithm. A) 0
dist(getLCA(u, v)) C) Prims Algorithm. B) 1
C) dist(u) + dist(v) D) Kruskal’s Algorithm. C) 2
D) dist(u) + dist(v) - dist(getLCA(u, 52) Stack A has the entries a, b, and D) 3
v)) c (with a on top). Stack B is empty. 58) What is the time complexity of
45) Kruskal’s Algorithm for finding An entry popped out of stack A can basic operations (insertion, deletion,
the Minimum Spanning Tree of a be printed immediately or pushed to and search) in an AVL tree?
graph is a kind of a? stack B. An entry popped out of stack A) O(log n)
A) DP Problem. B can only be printed. In this B) O(n)
B) Greedy Algorithm. arrangement, which of permutations C) O(n log n)
C) Adhoc Problem. of a, b, and c are not possible? D) O(1)
D) None of the above. A) b a c 59) Which operation is responsible
46) What is the time complexity to B) c b a for restoring the balance in an AVL
insert an element to the front of a C) c a b tree after an insertion or deletion?
LinkedList (head pointer given)? D) a b c A) Rotation
A) O(n) 53) 1. The number of elements in the B) In-order traversal
B) O(1) adjacency matrix of a graph having 7 C) Breadth-first traversal
C) O(logn) vertices is D) Depth-first traversal
D) O(n * logn) A) 7 60) Which of the following is a
47) What is the time complexity to B) 14 disadvantage of AVL trees compared
insert an element to the rear of a C) 36 to regular binary search trees?
LinkedList(head pointer given)? D) 49 A) Simplicity in implementation.
A) O(n) B) Faster average case operations.
B) O(1) C) Higher space complexity.
D) More complex search operations.
Page 3|4
61) In AVL trees, what is the else{ C) Topmost node is called root node.
minimum number of nodes in a while(head->next!=NULL) D) known as recursive data structure.
height-balanced tree of height hh? {PrevNode=head; 69) What is meant by a Linked List is
A) 2^h head=head->next; } a dynamic data structure?
B) 2^(h−1) PrevNode->next=NULL;}} A) memory is allocated, and its size
C) 2^h−1 A) Deletion of the first node can be changed at compile time
D) h^2 B) Deletion of the last node B) memory is allocated, and its size
62) Which operation in a BST is C) Adding a node at the beginning can be changed at run time
responsible for ensuring the BST D) Adding a node at the end C) memory is allocated at run time,
property is maintained? 66) These steps represent: but its size can be changed at compile
A) Insertion 1. Check if the queue is empty or not. time
B) Deletion 2. If it is not empty, access the data D) memory is allocated at compile
C) Searching where the front is pointing. time, but its size can be changed at
D) Rotation 3. Increment the front pointer to run time
63) In a BST, what is the minimum point to the next available data
70) A double‐ended queue (dequeue)
value in the tree? element. supports adding and removing items
A) The leftmost leaf node A) Enqueue Operation
from both the ends of the queue. The
B) The root node B) Dequeue Operation operations supported by dequeue are
C) The rightmost leaf node C) Isfull() operation
AddFront(adding item to front of the
D) Any leaf node D) peek() operation queue), AddRear(adding item to the
64) What is this function for in 67) Which one is WRONG about
rear of the queue),
linked list Graph? RemoveFront(removing item from
void A(Node* head){ A) is nonlinear and static data
the front of the queue), and
if (head==NULL){ structure that consists of vertices (or RemoveRear(removing item from
cout<<"list is empty"; nodes) and edges.
the rear of the queue). You are given
return;} B) is used to solve the most only stacks to implement this data
else challenging and complex
structure. You can implement only
Head=head->next;} programming problems push and pop operations. What’s the
A) Deletion of the first node C) A social network is also one real-
time complexity of performing
B) Deletion of the last node world example of a graph where AddFront() and AddRear() assuming
C) Adding a node at the beginning every person on the network is anode
m is the size of the stack and n is the
D) Adding a node at the end D) One of the most common real- number of elements?
65) What is this function for in world examples of a graph is Google
A) O(m) and O(n)
linked list Maps
void B(Node* head){ B) O(1) and O(n)
68) Which one is wrong about Tree?
Node* PrevNode; C) O(n) and O(1)
A) has an index like arrays.
if (head==NULL){ D) O(n) and O(m)
B) is a non-linear and hierarchal data
cout<<"list is empty"; structure where the elements are
return;}
arranged in a tree-like structure.

Q2. What do the following functions do? Describe with an example for each one (8 marks)
A. B.
void fun1(struct LL* head){ void fun2(struct LL* head){
if (head == NULL) if (head == NULL)
return; return;
cout << head->data << " ";
fun1(head->next); if (head->next != NULL)
cout << head->data << " ";} fun2(head->next->next);
cout << head->data << " ";}

Q3. What are the functions of studying data structures? (in brief and specific points, no examples)
(4 marks)

Page 4|4

You might also like