wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DSA QUIZ

Total questions: 50

Worksheet time: 3hrs 30mins

Name
Class
Date
1.

1. What is a data structure?

a)

a) A programming language

b)

b) A collection of algorithms

c)

c) A way to store and organize data

d)

d) A type of computer hardware

2.

2.What is the value of the postfix expression 6 3 2 4 + – *?

a)

a) 74

b)

b) -18

c)

c) 22

d)

d) 40

3.
  1. Which of the following is not the application of stack?

a)

a) Data Transfer between two asynchronous process

b)

b) Compiler Syntax Analyzer

c)

c) Tracking of local variables at run time

d)

d) A parentheses balancing program

4.

4.The data structure required for Breadth First Traversal on a graph is?

a)

a) Array

b)

b) Stack

c)

c) Tree

d)

d) Queue

5.

5.Which of the following application makes use of a circular linked list?

a)

a) Recursive function calls

b)

b) Undo operation in a text editor

c)

c) Implement Hash Tables

d)

d) Allocating CPU to resources

6.

Which of the following is not the type of queue?

a)

a) Priority queue

b)

b) Circular queue

c)

c) Single ended queue

d)

d) Ordinary queue

7.

7.What is the need for a circular queue?

a)

a) easier computations

b)

b) implement LIFO principle in queues

c)

c) effective usage of memory

d)

d) to delete elements based on priority

8.

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)

a) yrdnuof nas

b)

b) foundry nas

c)

c) sanfoundry

d)

d) san foundry

9.

8.The optimal data structure used to solve Tower of Hanoi is _________

a)

a) Tree

b)

b) Heap

c)

c) Priority queue

d)

d) Stack

10.

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)

a) display the list

b)

b) reverse the list

c)

c) reverse the list excluding top-of-the-stack-element

d)

d) display the list excluding top-of-the-stack-element

11.

10.What is the advantage of a hash table as a data structure?

a)

a) easy to implement

b)

b) faster access of data

c)

c) exhibit good locality of reference

d)

d) very efficient for less number of entries

12.

11.What is a dequeue?

a)

a) A queue implemented with both singly and doubly linked lists

b)

b) A queue with insert/delete defined for front side of the queue

c)

c) A queue with insert/delete defined for both front and rear ends of the queue

d)

d) A queue implemented with a doubly linked list

13.

12. In simple chaining, what data structure is appropriate?

a)

a) Doubly linked list

b)

b) Circular linked list

c)

c) Singly linked list

d)

d) Binary trees

14.

13.How do you initialize an array in C?

a)

a) int arr[3] = (1,2,3);

b)

b) int arr(3) = {1,2,3};

c)

c) int arr[3] = {1,2,3};

d)

d) int arr(3) = (1,2,3);

15.

14.Elements in an array are accessed _____________

a)

a) randomly

b)

b) sequentially

c)

c) exponentially

d)

d) logarithmically

16.

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)

a.1

b)

b.2

c)

c.3

d)

d.4

17.

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

a)

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

b)

b) AB + CD* E – F **G /

c)

c) AB + CD* E – F G /

d)

d) AB + CDE F *G /

18.

17.The postfix form of A*B+C/D is?

a)

a) *AB/CD+

b)

b) AB*CD/+

c)

c) A*BC+/D

d)

d) ABCD+/*

19.

18.Which of the following is not an inherent application of stack?

a)

a) Reversing a string

b)

b) Evaluation of postfix expression

c)

c) Implementation of recursion

d)

d) Job scheduling

20.

19.The type of expression in which operator succeeds its operands is?

a)

a) Infix Expression

b)

b) Prefix Expression

c)

c) Postfix Expression

d)

d) Both Prefix and Postfix Expressions

21.

20.The data structure required for Breadth First Traversal on a graph is?

a)

a) Stack

b)

b) Array

c)

c) Queue

d)

d) Tree

22.

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)

a) ABCD

b)

b) DCBA

c)

c) DCAB

d)

d) ABDC

23.

22.A normal queue, if implemented using an array of size MAX_SIZE, gets full when?

a)

a) Rear = MAX_SIZE – 1

b)

b) Front = (rear + 1)mod MAX_SIZE

c)

c) Front = rear + 1

d)

d) Rear = front

24.

23.Which of the following c code is used to create new node?

a)

a) ptr = (NODE*)malloc(sizeof(NODE));

b)

b) ptr = (NODE*)malloc(NODE);

c)

c) ptr = (NODE*)malloc(sizeof(NODE*));

d)

d) ptr = (NODE)malloc(sizeof(NODE));

25.

24.Linked lists are not suitable for the implementation of ___________

a)

a) Insertion sort

b)

b) Radix sort

c)

c) Polynomial manipulation

d)

d) Binary search

26.

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)

a) Prints all nodes of linked lists

b)

b) Prints all nodes of linked list in reverse order

c)

c) Prints alternate nodes of Linked List

d)

d) Prints alternate nodes in reverse order

27.

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)

a) 1 4 6 6 4 1

b)

b) 1 3 5 1 3 5

c)

c) 1 2 3 5

d)

d) 1 3 5 5 3 1

28.

27.Which of the following real world scenarios would you associate with a stack data structure?

a)

a) piling up of chairs one above the other

b)

b) people standing in a line to be serviced at a counter

c)

c) offer services based on the priority of the customer

d)

d) tatkal Ticket Booking in IRCTC

29.

28.What is the need for a circular queue?

a)

a) effective usage of memory

b)

b) easier computations

c)

c) to delete elements based on priority

d)

d) implement LIFO principle in queues

30.

29.In linked list implementation of a queue, where does a new element be inserted?

a)

a) At the head of link list

b)

b) At the centre position in the link list

c)

c) At the tail of the link list

d)

d) At any position in the linked list

31.

30.Which of the following graph traversals closely imitates level order traversal of a binary tree?

a)

a) Depth First Search

b)

b) Breadth First Search

c)

c) Depth & Breadth First Search

d)

d) Binary Search

32.

32.In a binary search tree, which of the following traversals would print the numbers in the ascending order?

a)

a) Level-order traversal

b)

b) Pre-order traversal

c)

c) Post-order traversal

d)

d) In-order traversal

33.

33.The number of edges from the root to the node is called __________ of the tree.

a)

a) Height

b)

b) Depth

c)

c) Length

d)

d) Width

34.

34.What is a full binary tree?

a)

a) Each node has exactly zero or two children

b)

b) Each node has exactly two children

c)

c) All the leaves are at the same level

d)

d) Each node has exactly one or two children

35.

35.What is a complete binary tree?

a)

a) Each node has exactly zero or two children

b)

b) A binary tree, which is completely filled, with the possible exception of the bottom level, which isfilled from right to left

c)

c) A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right

d)

d) A tree In which all nodes have degree 2

36.

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)

a) Preorder traversal

b)

b) Inorder traversal

c)

c) Postorder traversal

d)

d) Level order traversal

37.

37.What is a hash table?

a)

a) A structure that maps values to keys

b)

b) A structure that maps keys to values

c)

c) A structure used for storage

d)

d) A structure used to implement stack and queue

38.

38.If several elements are competing for the same bucket in the hash table, what is it called?

a)

a) Diffusion

b)

b) Replication

c)

c) Collision

d)

d) Duplication

39.

39.In a hash table of size 10, where is element 7 placed?

a)

a) 6

b)

b) 7

c)

c) 17

d)

d) 16

40.

40.1. Minimum number of fields in each node of a doubly linked list is

a)

(A) 2

b)

(B) 3

c)

(c) 4

d)

(d) none of the above

41.

41.A graph in which all vertices have equal degree is known as ____

a)

(A) Complete graph

b)

(B) Regular graph

c)

(C) Multi graph

d)

(D) Simple graph

42.

42.A vertex of in-degree zero in a directed graph is called a/an

a)

(A) Root vertex

b)

(B) Isolated vertex

c)

(C) Sink

d)

(D) Articulation point

43.

43. A graph is a tree if and only if graph is

a)

(A) Directed graph

b)

(B) Contains no cycles

c)

(C) Planar

d)

(D) Completely connected

44.

44.The elements of a linked list are stored

a)

(A) In a structure

b)

(B) In an array

c)

(C) Anywhere the computer has space for them

d)

(D) In contiguous memory locations

45.

45.A parentheses checker program would be best implemented using

a)

(A) List

b)

(B) Queue

c)

(C) Stack

d)

(D) Any of the above

46.

46.To perform level-order traversal on a binary tree, which of the following data structure will be required?

a)

(A) Hash table

b)

(B) Queue

c)

(C) Binary search tree

d)

(D) Stack

47.

47.Which of the following data structure is required to convert arithmetic expression in infix to its equivalent postfix notation?

a)

(A) Queue

b)

(B) Linked list

c)

(C) Binary search tree

d)

(D) None of above

48.

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)

(A) Threaded tree

b)

(B) Complete binary tree

c)

(C) M-way search tree

d)

(D) Full binary tree

49.

49.Which of following data structure is more appropriate for implementing quick sort iteratively?

a)

(A) Deque

b)

(B) Queue

c)

(C) Stack

d)

(D) Priority queue

50.

50.The number of edges in a complete graph of n vertices is

a)

(A) n(n+1)/2

b)

(B) n(n-1)/2

c)

(C) n2/2

d)

(D) n