0% found this document useful (0 votes)
224 views

DS MCQ

The document contains quiz questions and answers related to data structures and algorithms. It includes 10 questions each on topics like arrays, linked lists, stacks, queues, trees, and graphs. The questions test knowledge of data structure implementations, time complexities, operations, traversals, and applications. ________________________________________________#END#______________________ __________________________

Uploaded by

pavan
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)
224 views

DS MCQ

The document contains quiz questions and answers related to data structures and algorithms. It includes 10 questions each on topics like arrays, linked lists, stacks, queues, trees, and graphs. The questions test knowledge of data structure implementations, time complexities, operations, traversals, and applications. ________________________________________________#END#______________________ __________________________

Uploaded by

pavan
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/ 16

##__All Data Structure and Algorithm

Quiz Question and answer

#Quiz DS_1

#1. _____ algorithm follows divide and conquer strategy.

Answers
√1. Merge sort
2. Insertion sort
3. Bubble sort
4. All of the above

#2. In_____ sort largest element gets bouble out and then 2nd largest element gets bouble out
to get ascending ordered sorted list of elements.

Answers
1. Insertion Sort
2. Selection Sort
√3. Bubble Sort
4. None of the above

#3. How Many iterations will it takes to find 38 from an given array using binary search arr =
{10,20,38,57,100}.

Answers
1. 4
2. 2
3. 3
√4. 1

#4. What is the Worst case time complexity of bubble sort?

Answers
1. O(n log(n))
2. O(n n!)
√3. O(n^2)
4. Ω(n)

#5. What is the average case time complexity of selectoin sort?

Answers
1. O(n n!)
2. O(n log(n))
3. Ω(n)
√4. O(n^2)

#6. What is time complexity of Binary search?

Answers
√1. O( log(n))
2. O(n n!)
3. Ω(n)
4. O(n)

#7. The algorithm which repeatedly breaks down a list into several sublists until each sublist
consists of a single element.

Answers

1. Selection Sort

√2. Merge Sort

3. Bubble Sort

4. Heap Sort

#8. Which is not true about selection sort?

Answers
1. uses in-place algorithm at no extra cost of memory
2. maintains two partitions left for sorted and right for unsorted elements
3. both of the above
√4. It uses divide and conquer approach

#9. Binary search is commonly known as a --------------- or a ----------------.

Answers
1. half-interval search
2. logarithmic search
√3. Both of the Above
4. Fibonacci Search
#10. Big Theta (Θ)

Answers
√1. When an algorithm has a complexity with lower bound = upper bound
2. Describes the lower bound of a asymptotic function
3. Describes the worst-case of an algorithm
4. None of the above

________________________________________________#END#______________________
__________________________

#Quiz DS_2

#1. what is wrong about singly linked list?

Answers
1. Singly linked list is a collection of nodes linked together in a sequential way where each node
of singly linked list contains a data field
2. singly list is an address field which contains the reference of the next node.
3. Singly linked list can contain multiple data fields but should contain at least single address
field pointing to its connected next node.
√4. None Of Above

#2. What would be the asymptotic time complexity to add a node at the end of singly linked list,
if the pointer is initially pointing to the head of the list?

Answers
1. O(1)
2. O(n)
√3. θ(n)
4. Θ(1)

#3. which statement is True about circular linked list?

Answers
1. Entire list can be traversed from any node.
2. Circular lists are the required data structure when we want a list to be accessed in a circle or
loop.
3. Despite of being singly circular linked list we can easily traverse to its previous node, which is
not possible in singly linked list.
√4. All of Above

#4. What is the worst case time complexity of inserting a node in a doubly linked list?

Answers

1. O(nlogn)

2. O(logn)

√3. O(n)

4. O(1)

#5. Which of the following is false about a doubly linked list?

Answers

1. We can navigate in both the directions

2. It requires more space than a singly linked list

3. The insertion and deletion of a node take a bit longer

√4. Implementing a doubly linked list is easier than singly linked list

#6. Which of the following operations is performed more efficiently by doubly linked list than by
singly linked list?

Answers

√1. Deleting a node whose location in given

2. Searching of an unsorted list for a given item

3. Inverting a node after the node with given location


4. Traversing a list to process each node

#7. What is the output of the following code for start pointing to first node of the given list? 1->2-
>3->4->5->6
void Linkedlist(struct node* start)
{
if(start == NULL)
return;
printf("%d",start->data);

if(start->next != NULL)
Linkedlist(start->next->next);
printf("%d",start->data);
}

Answers
1. 1 4 6 6 4 1
2. 1 3 5 1 3 5
3. 1 2 3 5
√4. 1 3 5 5 3 1

#8. Which of the following data structure/s requires extra space to store n no. of elements?

Answers
1. Array
2. Structure
√3. LinkedList
4. Union

#9. Which of the following data structure/s is not suitable to implement Binary Search?

Answers
√1. LinkedList
2. Array
3. Tree
4. Both Options A & B

#10. .In a singly circular linked list, insertion of a node at first position requires modification of a?

Answers
1. One pointer
2. Two pointer
√3. Three pointer
4. None

________________________________________________#END#______________________
__________________________

#Quiz DS_3

#1. Which is the optimistic option for a circular queue?

Answers
1. easy for computation
√2. effective usage of memory
3. all of the mentioned
4. none of the mentioned

#2. _____ operation get the top data element of the stack, without removing it.

Answers
1. pop()
2. push()
3. IsEmpty()
√4. peek()

#3. Which of the following uses FIFO method

Answers
1. Dequeue
2. Linear Queue
3. Circular Queue
√4. Both B & C

#4. Which of the following is a non-linear data structure?


Answers
1. Stacks
2. Queues
√3. Hash Table
4. None of the above

#5. Stack can be implemented using _________ and ________ ?

Answers
1. Array and Binary Tree
2. Linked List and Graph
√3. Array and Linked List
4. Queue and Linked List

#6. In which data structure element is inserted at one end called Rear and deleted at other end
called Front.

Answers
1. Stack

√2. Queue

3. Both

4. Binary Tree

#7. Array implementation of Stack is not dynamic, which of the following statements supports
this argument?

Answers
√1. Space allocation for array is fixed and cannot be changed during run-time
2. User unable to give the input for stack operations
3. A runtime exception halts execution
4. Improper program compilation

#8. Find Infix Expression for the given postfix expression.


ABCD*-E/+F+GH/-

Answers
1. A / ((B - C * D) + E ) + F - G / H
2. A + ((B - C * D) / E ) + F - G / H
3. A + ((B - C * E) / D ) + F - G / H
√4. A + ((B - C * D) / E ) + F / G - H

#9. Circular queue is also known as

Answers
1. Standard Buffer
2. Cyclic Buffer
√3. Ring Buffer
4. Radius Buffer

#10. In Linear Queue add operation has ----- time complexity.

Answers
1. O(n)
2. O(n-1)
√3. O(1)
4. O(n-1)/2

________________________________________________#END#______________________
__________________________

#Quiz DS_4

#1. What is true about binary tree?

Answers
1. A binary tree is a type of tree in which every node has either no child node or one child node
or two child nodes.
2. A binary tree is an important class of a tree data structure in which a node can have at most
two children.
√3. Both A and B
4. None of above

#2. The post order traversal of binary tree is DEBFCA. Find out the pre order traversal.

Answers
1. ABFCDE
2. ADBFEC
√3. ABDECF
4. ABDCEF

#3. A binary tree whose every node has either zero or two children is called

Answers
√1. Complete binary tree
2. Binary search tree
3. Extended binary tree
4. None of above

#4. What is perfect binary tree?

Answers
1. In perfect binary tree all the internal nodes have 2 childrens?
2. All the leaf nodes are at same level.
√3. BOTH are TRUE
4. BOTH are FALSE

#5. Which of the following is true?

Answers
1. A graph may contain no edges and many vertices
√2. A graph may contain many edges and no vertices
3. A graph may contain no edges and no vertices
4. A graph may contain no vertices and many edges

#6. How to represent Adjancy Matrix in graph?

Answers
√1. It is Matrix a[v][v] where v is no of vertices. a[i][j] = 1 if i and j are adjacent = 0
otherwise
2. It is Matrix a[v][v] where v is no of edges. a[i][j] = 1 if i and j are not adjacent = 0 otherwise

3. Both A and B are correct

4. None of ABOVE

#7. find out Binary Search Tree by inserting following numbers from Left to Right? which is
correct?
11,6,8,19,4,10,5,17,43,49,31

Answers
1. image option 1
2. image option 2
√3. image option 3
4. None Of Above

#8. ----------- traversal is used to get a prefix expression from an expression tree.

Answers
1. PostOrder
√2. PreOrder
3. InOroder
4. All of the above

#9.Which of the following is not application of graph ?

Answers
1. Coloring of maps algorithms
2. Job scheduling
3. Web Page navigation
√4. Redo / Undo actions

#10. What is not true about Graph :

Answers
1. Graphs can be Cyclic or Acyclic.
2. Graph is a network model.
3. Graph can be linear
√4. graph can have unidirectional or bi-directional paths between nodes
________________________________________________#END#______________________
__________________________

#Quiz DS_MODULE__END.

#1. The balance Factor of a node in a binary tree is ?


Answers
1. Addition of left subtree and rigth subtree.
2. Height of right subtrees plus its subtrees.
√3. Height of left subtree minus height of right subtree.
4. Addition of all nodes.

#2. In _____________ type of expression operator succeeds its operands.

Answers
1. Infix
2. prefix
√3. postfix
4. transfix

#3. .___________________ are those structures that have one or more pointers which point to
the same type of structure, as their member.
Answers
√1. Self Referential structures
2. Circulre structures
3. Data structures
4. Pointer structures

#4. what does the following function do for a given linked list with with first node as head?
void function(struct node* head)
{
if(head == NULL)
return;
function(head -> next);
printf("%d", head-> data);
}

Answers
1. prints alternate node of linked list
2. prints alternate nodes in reverse order
3. prints only even places nodes values
√4. prints all nodes of linked list in reverse order

#5. The preorder traversal sequence of a binary search tree is 29, 18, 10, 15, 23, 21, 37, 35, 45.
Which one of the following is the postorder traversal sequence of the same tree?

Answers
1. 10, 18, 15, 21, 23, 35, 45, 37, 29
2. 15, 10, 23, 21, 18, 45, 35, 37, 29
3. 15, 18, 10, 21, 23, 45, 35, 37, 29
√4. 15, 10, 21, 23, 18, 35, 45, 37, 29

#6. The data structure required to evaluate a postfix expression is _________

Answers
1. queue
√2. stack
3. array
4. linked-list

#7. What would be solution to given postfix notation: 2 3 1 * + 9 -

Answers
1. 4
√2. -4
3. 3
4. -3

#8. Write a suitable line instead of /*******************/


void deleteList(struct node* head)
{
struct node* tmp;
while (head != NULL)
{
tmp = head;
head = head->next;
/**********************/
}
}

Answers
1. release(tmp)
√2. free(tmp);
3. create(tmp)
4. insert(tmp)

#9. How do you count the number of elements in the circular linked list?

Answers
1. int count(struct node *head) { int total = 0; struct node *current = head; do {
current = current->next; total++; } while (current != NULL); return total; }
√2. int count(struct node *head) { int total = 0; struct node *current = head; do {
current = current->next; total++; } while (current != head); return total; }
3. int count(struct node *head) { int total = 0; struct node *current = head; do {
current = current->next; total++; } while (current != head && temp != null); return total;
}
4. int count(struct node *head) { int total = 0; struct node *current = head; do {
current = current->next; total++; } while (current < head); return total; }

#10. Which of the following is/are not the advantages of Linked List over an array?

1-The size of a linked list can be incremented at runtime which is impossible in the case of the
array.

2-The List is not required to be contiguously present in the main memory, if the contiguous
space is not available, the nodes can be stored anywhere in the memory connected through the
links.

3-The number of elements in the linked list are limited to the available memory space while the
number of elements in the array is limited to the size of an array.

Answers
1. 1,2
2. 1
3. 1,2,3
√4. none of above

#11. The difference between stacks and queues is in ______________________.


Answers
√1. removing elements
2. adding elements at first position
3. inserting elements at given position
4. removing elements from given position

#12. Consider the following operation performed on a stack of size 7.


Push(22);
Push(23);
Push(33);
Pop();
Pop();
Push(62);
Pop();
Push(41);
Pop();
Pop();
Push(43);
Push(44);
Pop();
Push(6);
Pop();
After the completion of all operation, the no. of element present on stack are _________.

Answers
√1. 1
2. 2
3. 3
4. 4

#13. A ________ node is a special node that is found at the beginning of the linked list.

Answers
1. main
√2. header
3. start
4. beginer

#14. The prefix form of an infix expression p+q-r*t is?

Answers
1. + pq - *rt
2. - +pqr * t
√3. - +pq * rt
4. - + * pqrt

#15. What is the functionality of the following piece of code?


public int function(int data)
{
Node temp = head;
int var = 0;
while(temp != null)
{
if(temp.getData() == data)
{
return var;
}
var = var+1;
temp = temp.getNext();
}
return 0;
}

Answers
1. Find and delete a given element in the list.
√2. Find and return the position of the given element in the list.
3. Find and return the given element in the list.
4. Find and return the given element in the list.

#16. Which of the following statements is not true about Singly circular linked list?

Answers
√1. Time complexity to searching an element is o(1).
2. Every node in circular is successor.
3. Time complexity to inserting new node at the head in list is o(n).
4. Time complexity to deleting the last node is o(n).

#17. Evaluate Postfix expression from given infix expression.


A + B * (C + D) / (F + D) * E

Answers
1. ABCD+*/F+DE*
2. AB+CD*F/+D*E
√3. ABCD+*FD+/E*+
4. ABCD+*FD+E*/+
#18. .Which of the following is/are not correct.
Doubly circular linked list contains only one node, if _______________.
i-next part of first node contains address of last node
ii-next part of first node contains address of first node
iii-prev part of last node contains null value
iv-prev part of last node contains address of first node

Answers
1. i,iv
√2. iii
3. i
4. ii

#19. What is the time complexity of searching for an element in a circular linked list?

Answers
√1. O(n)
2. O(1)
3. O(n log n)
4. O(n log (n-1))

#20. In __________________ search start at the beginning of the list and check every element
in the list.

Answers
1. Binary search
√2. Linear search
3. Hash Search
4. Binary Tree search

________________________________________________#END#______________________
__________________________

You might also like