0% found this document useful (0 votes)
2 views12 pages

Comprehensive DS Question Bank

The document is a comprehensive question bank covering various topics in data structures and algorithms, including tree structures, sorting algorithms, and complexity analysis. Each question is followed by multiple-choice answers, with the correct answer indicated. The content is designed for educational purposes, likely aimed at students preparing for exams or interviews in computer science.

Uploaded by

johnnywicklord
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views12 pages

Comprehensive DS Question Bank

The document is a comprehensive question bank covering various topics in data structures and algorithms, including tree structures, sorting algorithms, and complexity analysis. Each question is followed by multiple-choice answers, with the correct answer indicated. The content is designed for educational purposes, likely aimed at students preparing for exams or interviews in computer science.

Uploaded by

johnnywicklord
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Comprehensive-DS-Question-Bank

For more notes visit

https://rtpnotes.vercel.app

Qno Question Answer


1 The total no. of children of a node in a tree is known as C

a) Height b) Scale c) Degree d) Depth


2 Which data structure is required to convert the infix to prefix A
notation?
A) Stack B) linked list C) binary tree D) queue
3 How can we initialize an array in C language? C
A)int arr[2]=(10,20)
B)int arr(2)=(10,20)
C)int arr[2]={10,20}
D)int arr(2)={10,20}
4 Which of the following is non-linear data structure? A
[A] Trees
[B] Stacks
[C] Strings
[D] All of the above
5 One can convert a binary tree to its mirror image by C
traversing it in
A) Inorder
B) Preorder
C) Postorder
D) None of the above
6 Visiting root node after visiting left and right sub-trees is C
called
A - In-order Traversal
B - Pre-order Traversal
C - Post-order Traveral
7 Which of the following is the prefix form of A+B*C ? D
A. A+(BC*)
B. +AB*C
Qno Question Answer
C. ABC+*
D. +A*BC
8 Consider the following loop A
for i = 1 to n
for j = 1 to i
print “HELLO”
The asymptotic time complexity of above loop is

a) O(n^2)
b) O(nlogn)
c) O(n^3)
d) O(n)
9 Quick sort algorithm is an example of D

a) greedy approach. b) improved binary search. C) dynamic


programming d)divide and conquer
10 Merge sort uses which of the following technique to C
implement sorting?

a) backtracking
b) greedy algorithm
c) divide and conquer
d) dynamic programming
11 Consider the following C code. Assume that unsigned long B
int type
length is 64 bits.

unsigned long int fun(unsigned long int n)


{ unsigned long int i, j = 0, sum = 0;
for (i = n; i > 1; i = i/2)
j++;
for ( ; j > 1; j = j/2)
sum++;
return(sum); }

The value returned when we call fun with the input 2 40 is (A)
4 (B) 5
(C) 6 (D) 40
12 Which of the following has a search efficiency of O(1): C
A)Tree
B) Heap
Qno Question Answer
C) Hash Table
D) Linked List
13 Using division method, in a given hash table of size 157, the C
key of value
172 be placed at position

a) 19
b) 72
c) 15
d) 17
14 What is the time complexity of a Merge Sort Algorithm? A
a) O(n logn)
b) On3
c) On
d) On2
15 Which one of the below is not divide and conquer approach? B
A - Insertion Sort
B - Merge Sort
C - Shell Sort
D - Heap Sort
16 ___ is a pile in which items are added at one end and B
removed from
the other.
A) List
B) Queue
C) Stack
D) Array
17 A linear collection of data elements where the linear node is A
given
by means of pointer is called?
a) Linked list
b) Node list
c) Primitive list
d) Unordered list
18 Which of the following is not a disadvantage to the usage of D
array?

a) Fixed size
b) There are chances of wastage of memory space if
elements
inserted in an array are lesser than the allocated size
Qno Question Answer
c) Insertion based on position
d) Accessing elements at specified positions
19 The postfix expression for the infix expression B
A+B∗(C+D)/F+D∗E is:

a) AB+CD+∗F/D+E∗
b) ABCD+∗F/DE∗++
c) A∗B+CD/F∗DE++
d) A+∗BCD/F∗DE++

20 If the size of the stack is 10 and we try to add the 11th C


element in the
stack then the condition is known as ___
A)Underflow
B)Garbage collection
C)Overflow
D)None of the above
21 Out of the following tree structure which is efficient B
considering space
and time complexities.

a)Incomplete binary tree


b)Complete binary tree
c)Full binary tree
22 Minimum number of fields in each node of a doubly linked list B
is ____
(A) 2
(B) 3
(C) 4
(D) None of the above
23 If the array is already sorted, which of these algorithms will B
exhibit the best performance

A - Merge Sort
B - Insertion Sort
C - Quick Sort
D - Heap Sort

24 How can we describe an array in the best possible way? Container that
stores the elements
of similar types
25 What is the value of postfix expression 6324+-* D

A)Something between - 5 and 15


Qno Question Answer
B)Something between 5 and - 5
C)Something between 5 and 15
D)Something between 15 and 100
26 What is the output of the below code? A
# include <stdio.h>
int main()
{
int arr[5]={10,20,30,40,50};
printf("%d", arr[5]);
return 0;
}

a. Garbage value
b. 10
c. 50
d. None of the above
27 Which of the following is not the operation that can be D
performed on queue

a) Insertion
b) Deletion
c) Retrieval
d) Traversal
28 One can convert a binary tree to its mirror image by C
traversing it in

A) Inorder
B) Preorder
C) Postorder
D) None of the above
29 Which is the type of data structure where each node can A
have at most
two children ?

a) Binary Tree
b) Graph
c) Linked List
d) Array
30 Which of the following is not true about comparison based D
sorting
algorithms?

A)The minimum possible time complexity of a comparison


Qno Question Answer
based
sorting algorithm is O(nLogn) for a random input array

B)Any comparison based sorting algorithm can be made


stable by using position as a criteria when two elements are
compared

C)Counting Sort is not a comparison based sorting algortihm

D)Heap Sort is not a comparison based sorting algorithm


31 Which of the following are not a tree terminology D
a)root b)edge c)parent d)stem
32 Which data structure is mainly used for implementing the B
recursive
algorithm?
A) Queue
B) stack
C) binary tree
D) Linked list
33 Which of the following highly uses the concept of an array? C
A.Binary Search tree
B.Caching
C.Spatial locality
D.Scheduling of Processes
34 The time complexity of enqueue operation in Queue is __ A

a)O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
35 Which one of the below mentioned is linear data D
structure
A - Queue
B - Stack
C - Arrays
D - All of the above
36 Which of the following is false about a doubly linked list? D

a) We can navigate in both the directions


b) It requires more space than a singly linked list
c) The insertion and deletion of a node take a bit longer
Qno Question Answer
d) Implementing a doubly linked list is easier than singly
linked list
37 Time required to concatenate two doubly linked list is o(n) as we cannot
find the last element
in the time o(1)
38 Which of the following is the correct way of declaring an A
array?

int javatpoint[10];
int javatpoint;
javatpoint{20};
array javatpoint[10];
39 What is time complexity of heap sort algorithm? D
A) O(1) B) O(n) C) O(log n) D) O(nLogn)
40 Consider the basic block given below. A
a=b+c
c=a+d
d=b+c
e= d - b
a=e+b
The minimum number of nodes and edges present in the
DAG
representation of the above
basic block respectively are

(A) 6 and 6 (B) 8 and 10 (C) 9 and 12 (D) 4 and 4


41 The postfix form of the expression (A+ B)*(C*D- E)*F / G C
is?

A) AB+ CD*E – FG /**


B) AB + CD* E – F **G /
C) AB + CD* E – *F *G /
D) AB + CDE * – * F *G /
42 Which of the following algorithm is not stable? B
A) Bubble sort
B) Quick sort
C) Merge sort
D) Insertion sort
43 Which method can find if two vertices x & y have path C
between them?

A - Depth First Search


Qno Question Answer
B - Breadth First Search
C - Both A & B
D - None A or B
44 What is worst case time complexity of linear search B
algorithm?
B) O(1) B) O(n) C) O(log n) D) O(n^2)
45 Which of the following is an example for a postfix expression? B
a) a*b(c+d)
b) abc*+de-+
c) +ab
d) a+b-c
46 Which of the following that determines the need for the A
Circular Queue?

a. Avoid wastage of memory


b. Access the Queue using priority
c. Follows the FIFO principle
d. None of the above
47 You have an array of n elements. Suppose you implement a A
quick sort
by always choosing the central element of the array as the
pivot. Then
the tightest upper bound for the worst case performance is

(A) 0(n^2) (B) 0(n log n) (C) θ(n log n) (D) θ(n^2 )
48 B+ trees are preferred to binary tree in Database because 2.Disk
access is much
1.Disk capacity are greater than memory capacities slower than memory
2.Disk access is much slower than memory access access
3.Disk data transfer rates are much less than memory data
transfer
rate
4.Disks are more reliable than Memory
49 Minimum number of queues required for priority queue D
implementation?

A-5
B-4
C-3
D-2
51 In a min heap : B
(A) Parent nodes have values greater than or equal to their
Qno Question Answer
child
(B) Parent nodes have values less than or equal to their child
(C) both statements are true
(D) both statements are false
52 Q 1 - In order traversal of binary search tree will C
produce −

A - unsorted list
B - reverse of input
C - sorted list
D - none of the above
53 What is the worst case run-time complexity of binary search D
algorithm?
A - Ο(n2)
B - Ο(nlog n)
C - Ο(n3)
D - Ο(n
54 Which of the following uses memoization? C
A - Greedy approach
B - Divide and conquer approach
C - Dynamic programming approach
D - None of the above!
55 What is the time complexity of pop() operation when the A
stack is
implemented using an array?

a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)
56 The Inorder and Preorder traversal of a binary tree is d b e a debfgca
f c g and a b d e c f g respectively. Which among the
following is the correct Post Order Traversal Sequence for
this tree?
57 Which of the following is not the application of stack? Data Transfer
between two
asynchronous
processes
58 In the worst case, the number of comparisons needed to n
search a singly linked list of length n for a given element is?
59 To implement a stack using queue (with only enqueue and 2
dequeue operations), how many queues will you need?
Qno Question Answer
60 The optimal data structure used to solve Tower of Hanoi is Stack
_________

61 Assume that the operators +, -, X are left associative and ^ is abc X+ def ^^ –
right associative. The order of precedence (from highest to
lowest) is ^, X, +, -. The postfix expression for the infix
expression a + b X c – d ^ e ^ f is?
62 The time complexity of heap sort in worst case is O(nlogn)
63 Suppose we are sorting an array of eight integers using 2
heapsort, and we have just finished some
heapify (either maxheapify or minheapify) operations. The
array now looks like this:

16 14 15 10 12 27 28

How many heapify operations have been performed on root


of heap?
64 What is the number of edges present in a complete graph (n*(n-1))/2
having n vertices?
65 If several elements are competing for the same bucket in the Collision
hash table, what is it called?
66 Which data structure is used to store the undo history in a Stack
web browser?
67 When a pop operation is called on an empty queue, what is Underflow
the condition called?
68 Given a binary tree with the following elements Post order
50,25,75,10,30,60,90.

Which traversal technique will produce the following


sequence? 10,30,25,60,90,75,50
69 Which sorting algorithm has a time complexity of O(n log n) Quick sort
in the average and worst case?
70 Which of the following statements about a linked list is true? It consists of nodes
linked by pointers
a) It has a fixed size
b) Elements stored contiguously in memory
c) It allows for efficient random access
d) It consists of nodes linked by pointers
71 Which type of linked list has its last node pointing to the first Circular linked list
node?
72 Travelling salesman problem is an example of Greedy algorithm
Qno Question Answer
73 Time complexity of Depth First traversal is O(V + E)
74 Visiting root node after visiting left and right subtrees is called Post order traversal
75 How is the second element in an array accessed based on *a + 2
pointer notation
76 The worst case complexity of quick sort is C
a) O(n)
b) O(log n)
c) O(n^2)
d) O(n log n)
77 What is the output of following function for start pointing to 135531
the first node of following linked list?

1->2->3->4->5->6

void fun(struct node * start)


{
if(start == NULL)
return;
printf("%d",start->data)
if(start->next!=NULL)
fun(start->next->next);
printf("%d",start->data);
}
78 The prefix form of A-B(C*D Ʌ E) is -A/BC*ɅDE

79 Suppose we are sorting an array of eight integers using a) The pivot could
quicksort, and we have just finished the first partitioning with be either the 7 and 9
the array looking like this.

2 5 1 7 9 12 11 10

Which statement is correct?

a) The pivot could be either the 7 and 9


b) The pivot could be 8 but it is not 9
c) THe pivot is not 7 but it could be 9
d) Neither the 8 or 9 is the pivot
80 In a complete k-ary tree, every internal node has exactly k L=n⋅(k−1)+1
children or no child. The number of leaves in such a tree with
n internal nodes is
81 If a node in a binary search tree has 2 children, then its No right child
inorder predecessor has
Qno Question Answer
82 Using Bubble sort the number of interchanges required to 5
sort 5,1,6,2 and 4 in ascending order is....
83 Which of the following is a sequence container B
a) Stack
b) Dequeue
c) Queue
d) set
84 Minimum number of queues needed to implement the priority 1
queue is ....
85 The data structure used in breadth first search algorithm is .... Queue

You might also like