WorksheetsDSA QUIZ
Total questions: 50
Worksheet time: 3hrs 30mins
1. What is a data structure?
a) A programming language
b) A collection of algorithms
c) A way to store and organize data
d) A type of computer hardware
2.What is the value of the postfix expression 6 3 2 4 + – *?
a) 74
b) -18
c) 22
d) 40
Which of the following is not the application of stack?
a) Data Transfer between two asynchronous process
b) Compiler Syntax Analyzer
c) Tracking of local variables at run time
d) A parentheses balancing program
4.The data structure required for Breadth First Traversal on a graph is?
a) Array
b) Stack
c) Tree
d) Queue
5.Which of the following application makes use of a circular linked list?
a) Recursive function calls
b) Undo operation in a text editor
c) Implement Hash Tables
d) Allocating CPU to resources
Which of the following is not the type of queue?
a) Priority queue
b) Circular queue
c) Single ended queue
d) Ordinary queue
7.What is the need for a circular queue?
a) easier computations
b) implement LIFO principle in queues
c) effective usage of memory
d) to delete elements based on priority
8.What will be the output of the following program?
main()
{
char str[]="san foundry";
int len = strlen(str);
int i;
for(i=0;i<len;i++)
push(str[i]); // pushes an element into stack
for(i=0;i<len;i++)
pop(); //pops an element from the stack
}
a) yrdnuof nas
b) foundry nas
c) sanfoundry
d) san foundry
8.The optimal data structure used to solve Tower of Hanoi is _________
a) Tree
b) Heap
c) Priority queue
d) Stack
9.What is the functionality of the following piece of code?
public void display()
{
if(size == 0)
System.out.println("underflow");
else
{
Node current = first;
while(current != null)
{
System.out.println(current.getEle());
current = current.getNext();
}
}
}
a) display the list
b) reverse the list
c) reverse the list excluding top-of-the-stack-element
d) display the list excluding top-of-the-stack-element
10.What is the advantage of a hash table as a data structure?
a) easy to implement
b) faster access of data
c) exhibit good locality of reference
d) very efficient for less number of entries
11.What is a dequeue?
a) A queue implemented with both singly and doubly linked lists
b) A queue with insert/delete defined for front side of the queue
c) A queue with insert/delete defined for both front and rear ends of the queue
d) A queue implemented with a doubly linked list
12. In simple chaining, what data structure is appropriate?
a) Doubly linked list
b) Circular linked list
c) Singly linked list
d) Binary trees
13.How do you initialize an array in C?
a) int arr[3] = (1,2,3);
b) int arr(3) = {1,2,3};
c) int arr[3] = {1,2,3};
d) int arr(3) = (1,2,3);
14.Elements in an array are accessed _____________
a) randomly
b) sequentially
c) exponentially
d) logarithmically
15.Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation. The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression?
a.1
b.2
c.3
d.4
16.The postfix form of the expression (A+ B)*(C*D- E)*F / G is?
a) AB+ CD*E – FG /**
b) AB + CD* E – F **G /
c) AB + CD* E – F G /
d) AB + CDE – F *G /
17.The postfix form of A*B+C/D is?
a) *AB/CD+
b) AB*CD/+
c) A*BC+/D
d) ABCD+/*
18.Which of the following is not an inherent application of stack?
a) Reversing a string
b) Evaluation of postfix expression
c) Implementation of recursion
d) Job scheduling
19.The type of expression in which operator succeeds its operands is?
a) Infix Expression
b) Prefix Expression
c) Postfix Expression
d) Both Prefix and Postfix Expressions
20.The data structure required for Breadth First Traversal on a graph is?
a) Stack
b) Array
c) Queue
d) Tree
21.If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what order will they be removed?
a) ABCD
b) DCBA
c) DCAB
d) ABDC
22.A normal queue, if implemented using an array of size MAX_SIZE, gets full when?
a) Rear = MAX_SIZE – 1
b) Front = (rear + 1)mod MAX_SIZE
c) Front = rear + 1
d) Rear = front
23.Which of the following c code is used to create new node?
a) ptr = (NODE*)malloc(sizeof(NODE));
b) ptr = (NODE*)malloc(NODE);
c) ptr = (NODE*)malloc(sizeof(NODE*));
d) ptr = (NODE)malloc(sizeof(NODE));
24.Linked lists are not suitable for the implementation of ___________
a) Insertion sort
b) Radix sort
c) Polynomial manipulation
d) Binary search
25.What does the following function do for a given Linked List with first node as head?
void fun1(struct node* head)
{
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data);
}
a) Prints all nodes of linked lists
b) Prints all nodes of linked list in reverse order
c) Prints alternate nodes of Linked List
d) Prints alternate nodes in reverse order
26.What is the output of following function for start pointing to 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);
}
a) 1 4 6 6 4 1
b) 1 3 5 1 3 5
c) 1 2 3 5
d) 1 3 5 5 3 1
27.Which of the following real world scenarios would you associate with a stack data structure?
a) piling up of chairs one above the other
b) people standing in a line to be serviced at a counter
c) offer services based on the priority of the customer
d) tatkal Ticket Booking in IRCTC
28.What is the need for a circular queue?
a) effective usage of memory
b) easier computations
c) to delete elements based on priority
d) implement LIFO principle in queues
29.In linked list implementation of a queue, where does a new element be inserted?
a) At the head of link list
b) At the centre position in the link list
c) At the tail of the link list
d) At any position in the linked list
30.Which of the following graph traversals closely imitates level order traversal of a binary tree?
a) Depth First Search
b) Breadth First Search
c) Depth & Breadth First Search
d) Binary Search
32.In a binary search tree, which of the following traversals would print the numbers in the ascending order?
a) Level-order traversal
b) Pre-order traversal
c) Post-order traversal
d) In-order traversal
33.The number of edges from the root to the node is called __________ of the tree.
a) Height
b) Depth
c) Length
d) Width
34.What is a full binary tree?
a) Each node has exactly zero or two children
b) Each node has exactly two children
c) All the leaves are at the same level
d) Each node has exactly one or two children
35.What is a complete binary tree?
a) Each node has exactly zero or two children
b) A binary tree, which is completely filled, with the possible exception of the bottom level, which isfilled from right to left
c) A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right
d) A tree In which all nodes have degree 2
36.What does the following piece of code do?
public void func(Tree root)
{
func(root.left());
func(root.right());
System.out.println(root.data());
}
a) Preorder traversal
b) Inorder traversal
c) Postorder traversal
d) Level order traversal
37.What is a hash table?
a) A structure that maps values to keys
b) A structure that maps keys to values
c) A structure used for storage
d) A structure used to implement stack and queue
38.If several elements are competing for the same bucket in the hash table, what is it called?
a) Diffusion
b) Replication
c) Collision
d) Duplication
39.In a hash table of size 10, where is element 7 placed?
a) 6
b) 7
c) 17
d) 16
40.1. Minimum number of fields in each node of a doubly linked list is
(A) 2
(B) 3
(c) 4
(d) none of the above
41.A graph in which all vertices have equal degree is known as ____
(A) Complete graph
(B) Regular graph
(C) Multi graph
(D) Simple graph
42.A vertex of in-degree zero in a directed graph is called a/an
(A) Root vertex
(B) Isolated vertex
(C) Sink
(D) Articulation point
43. A graph is a tree if and only if graph is
(A) Directed graph
(B) Contains no cycles
(C) Planar
(D) Completely connected
44.The elements of a linked list are stored
(A) In a structure
(B) In an array
(C) Anywhere the computer has space for them
(D) In contiguous memory locations
45.A parentheses checker program would be best implemented using
(A) List
(B) Queue
(C) Stack
(D) Any of the above
46.To perform level-order traversal on a binary tree, which of the following data structure will be required?
(A) Hash table
(B) Queue
(C) Binary search tree
(D) Stack
47.Which of the following data structure is required to convert arithmetic expression in infix to its equivalent postfix notation?
(A) Queue
(B) Linked list
(C) Binary search tree
(D) None of above
48.A binary tree in which all its levels except the last, have maximum numbers of nodes, and all the nodes in the last level have only one child it will be its left child. Name the tree.
(A) Threaded tree
(B) Complete binary tree
(C) M-way search tree
(D) Full binary tree
49.Which of following data structure is more appropriate for implementing quick sort iteratively?
(A) Deque
(B) Queue
(C) Stack
(D) Priority queue
50.The number of edges in a complete graph of n vertices is
(A) n(n+1)/2
(B) n(n-1)/2
(C) n2/2
(D) n
