0% found this document useful (0 votes)
46 views9 pages

Data Structure Test Questions and Answers

The document contains 30 multiple choice questions about data structures and algorithms. It tests knowledge on topics like time complexity of sorting algorithms, applications of stacks, queues and linked lists. The questions have options to choose from for the right answer.

Uploaded by

santhiya
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)
46 views9 pages

Data Structure Test Questions and Answers

The document contains 30 multiple choice questions about data structures and algorithms. It tests knowledge on topics like time complexity of sorting algorithms, applications of stacks, queues and linked lists. The questions have options to choose from for the right answer.

Uploaded by

santhiya
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

Professor Academy

Data Structure Test

DATE: Fri Jul 5 [Link] 2024 TIME: 50 mins

1 The average case time complexity of heap sort is


( A ) O (n) ( B ) O (n2)

(C) O (n log n) (D) O (log n)

Correct Option: ( C, )

Solution:

2 The average and worst-case time complexity of merge sort algorithm is


( A ) O (n), O (n2) ( B ) O (n2), O (log n)

(C) O (n log n), O (n log n) (D) None of the above

Correct Option: ( C, )

Solution:

3 Bucket sort and Radix sort is a stable sort method


( A ) True, False ( B ) True , True

(C) False, True (D) False, False

Correct Option: ( B, )

Solution:

4 Which of the following algorithm does not have a worst case time
complexity of O (n2)
( A ) Insertion sort ( B ) Merge sort

(C) Quick sort (D) Bubble sort

Correct Option: ( B, )

Solution:

5 The running time complexity of quick sort is depends on


( A ) Number of inputs ( B ) Arrange of elements in an array

(C) Size of element (D) Pivot element

Correct Option: ( D )

Solution:

Professor Academy No.42, Railway Border road, Kodambakkam, Chennai, State - Tamil Nadu, Pin Code - 600024 ,+91 9150567983
6 Which of the following algorithm using recursion method
( A ) Heap sort, Quick sort ( B ) Merge sort, Quick sort

(C) Bubble sort, Heap sort (D) None of the above

Correct Option: ( B, )

Solution:

7 The worst-case time complexity of quick sort is


( A ) O (n) ( B ) O (n2)

(C) O (n log n) (D) O (log n)

Correct Option: ( B, )

Solution:

8 The worst-case time complexity of insertion sort is


( A ) O (n) ( B ) O (n2)

(C) O (n log n) (D) O (log n)

Correct Option: ( B, )

Solution:

9 In which of the following searching algorithm requires a sorted array


( A ) Radix search ( B ) Binary search

(C) Hash search (D) None of the above

Correct Option: ( B, )

Solution:

10 The most suitable data structure for radix sort is


( A ) Stack ( B ) Binary search tree

(C) Linked list (D) Tree

Correct Option: ( C, )

Solution:

11 Which sorting algorithm needs the minimum number of swaps


( A ) Merge sort ( B ) Quick sort

(C) Heap sort (D) Selection sort

Correct Option: ( D )

Solution:

Professor Academy No.42, Railway Border road, Kodambakkam, Chennai, State - Tamil Nadu, Pin Code - 600024 ,+91 9150567983
12 The average case occurs in the linear search algorithm when
(A) (B)
The item to be searched is in somewhere The item to be searched is not in the
middle of the array array
(C) (D)
The item to be searched is in the last of The item to be searched is either in the
the array last or not in the array

Correct Option: ( A, )

Solution:

13 Which one of the following is not the stable sorting algorithm


( A ) Insertion sort ( B ) Radix sort

(C) Selection sort (D) Merge sort

Correct Option: ( C, )

Solution:

14 Which one of the following is the unstable sorting algorithm


(A)Insertion sort ( B ) Radix sort

(C) Selection sort (D) Merge sort

Correct Option: ( C, )

Solution:

15 Which one of the following algorithms based on the counting-based sorting


technique
( A ) Insertion sort ( B ) Bubble sort

(C) Heap sort (D) Radix sort

Correct Option: ( D )

Solution:

16 The worst-case running time of insertion sort, merge sort and quick sort
respectively are
( A ) O (nlogn), O(n logn), and O(n2) ( B ) O(n2), O(n logn), and O(n2)

(C) O(n logn), O(n), and O(n2) (D) None of the above

Correct Option: ( B, )

Solution:

17 What is the worst-case and average-case time complexity of the Binary


Search?
( A ) O(n2) ( B ) O(1)

(C) O(n log n) (D) O(log n)

Correct Option: ( D )

Solution:

Professor Academy No.42, Railway Border road, Kodambakkam, Chennai, State - Tamil Nadu, Pin Code - 600024 ,+91 9150567983
18 What is the advantage of bubble sort over other sorting techniques?
( A ) It is faster ( B ) Consumes less memory

(C)
Detects whether the input is already (D) All of the above
sorted

Correct Option: ( C, )

Solution:

19 Which of the following sort algorithms has execution time that is least
dependent on initial ordering of the input
( A ) Insertion sort ( B ) Quick sort

(C) Merge sort (D) Selection sort

Correct Option: ( C, )

Solution:

20 In the process of evaluating the prefix expression - / * 2 * 5 + 3 6 6 3 the


4th popped value from stack is --------------
(A) 9 ( B ) 45

(C) 12 (D) 5

Correct Option: ( A, )

Solution:

21 In the process of evaluating the prefix expression - / * 2 * 5 + 3 6 6 3 the


result is
(A) 9 ( B ) 45

( C ) 12 (D) 5

Correct Option: ( C, )

Solution:

22 Considering 0-address instructions machine, what will be the top of the


stack after executing the following sequence of instructions?
Push 10, Push 15, Push 6, Mult, push 30, Add, Add
( A ) 69 ( B ) 130

(C) 120 (D) 100

Correct Option: ( B, )

Solution:

23 Choose the correct output for the following sequence of operation


Push (5) Push (7) Pop Push (4) Push (6) Pop Pop Pop Push (3) Pop
(A) 7 6 4 5 3 (B) 7 4 5 6 3

(C) 73465 (D) None of the above

Correct Option: ( A, )

Solution:

Professor Academy No.42, Railway Border road, Kodambakkam, Chennai, State - Tamil Nadu, Pin Code - 600024 ,+91 9150567983
24 Which of the following is not an inherent application of stack?
( A ) Implementation of recursion ( B ) Evaluation of a postfix expression

(C) Job scheduling (D) Reverse a string

Correct Option: ( C, )

Solution:

25 For which of the following is not a stack application?


Well-formed parenthesis Breadth first search Implementing function calls
Process scheduling
( A ) i and iii ( B ) ii and iii

(C) ii and iv (D) i and iv

Correct Option: ( C, )

Solution:

26 Which one of the following applications may use a stack?


Parenthesis balancing program Process scheduling operating system
Conversion of infix arithmetic expression to postfix form
( A ) i and ii only ( B ) i and iii only

(C) All of the above ( D ) None of the above

Correct Option: ( B, )

Solution:

27 - + 5 / * 6 2 3 4 evaluate the expression the result is


(A) 6 (B) 8

(C) 9 (D) 5

Correct Option: ( D )

Solution:

28 Which of the following are applications of queue --------------


(A) Spooling (B) Scheduling of processes
(C) Simulation of real-life problem (D) All the above

Correct Option: ( D )

Solution:

29 When linked list are implemented through pointer then, data is stored in a
node. Each node contains data and a pointer to the
(A) Next node (B) Previous node
(C) Last node (D) First node

Correct Option: ( A, )

Solution:

Professor Academy No.42, Railway Border road, Kodambakkam, Chennai, State - Tamil Nadu, Pin Code - 600024 ,+91 9150567983
30 Which of the following is application of linked list?
(B)
(A) implementation of doubly linked list implementation of linear list of an
integer
(C) Both of the above (D) None of these

Correct Option: ( C, )

Solution:

31 The data structure required for Breadth First Traversal on a graph is


(A) Stack (B) Array
(C) Tree (D) Queue

Correct Option: ( D )

Solution:

32 For the size of the structure and the data in the structure are constantly
changing this process is best suited in ------------

(A) Array (B) Stack


(C) Queue (D) Linked list

Correct Option: ( D )

Solution:

33 In linked list implementation of a queue, front and rear pointers are


tracked which of these pointers will change during an insertion into empty
queue
( A ) Only rear pointer ( B ) Only front pointer

(C) Both of the above (D) None of the above

Correct Option: ( C, )

Solution:

34 Consider an implementation of unsorted singly linked list. Suppose it has


its representation with a head and tail pointer. Given the representation,
which of the following operation can be implemented in O (1) time?
Insertion at the front of the linked list Insertion at the end of the linked list
Deletion of the front node of the linked list
Deletion of the last node of the linked list Select the correct option

(A) i and iii only (B) ii and iv only


(C) i, ii, iii only (D) All of the above

Correct Option: ( C, )

Solution:

35 In linked lists, there are no NULL links in -------


( A ) Linear doubly linked list ( B ) circular linked list

(C) Single linked list (D) linked list

Professor Academy No.42, Railway Border road, Kodambakkam, Chennai, State - Tamil Nadu, Pin Code - 600024 ,+91 9150567983
Correct Option: ( B, )

Solution:

36 Which of the following operation is performed more efficiently by doubly


linked list than by linear linked list?
(A) (B)
Deleting a node whose location is given Inserting a node after the node with a
given location
(C) (D)
Traversing the list to process each node Searching an unsorted list for a given
item

Correct Option: ( A, )

Solution:

37 Given below as two statements, select which is correct


Insertion of an element should be done at the last node in a circular list
Deletion of an element should be done at the last node of the circular list
( A ) Both are true ( B ) Both are false

(C) Statement I is true, II is false (D) None of the above

Correct Option: ( B, )

Solution:

38 What is the minimum number of stacks of size n required to implement a


queue of size n?
(A) 1 (B) 2

(C) 3 (D) 4

Correct Option: ( B, )

Solution:

39 Which of the followings are applications of queue?


( A ) Expression evaluation ( B ) Parsing

(C) Simulation of recursion (D) Job scheduling

Correct Option: ( D )

Solution:

40 Which of the following operation you can’t perform on the dynamic queue?
( A ) Enqueue ( B ) Dequeue

(C) Empty (D) Full

Correct Option: ( D )

Solution:

Professor Academy No.42, Railway Border road, Kodambakkam, Chennai, State - Tamil Nadu, Pin Code - 600024 ,+91 9150567983
41 If you are trying to delete elements from empty queue then you will get an
error as -----------
( A ) Empty queue ( B ) Overflow of queue

(C) Underflow of queue (D) None of the above

Correct Option: ( C, )

Solution:

42 Which of the following are applications of queue --------------


( A ) Spooling ( B ) Scheduling of processes

(C) Memory Management (D) All the above

Correct Option: ( D )

Solution:

43 When linked list are implemented through pointer then, data is stored in a
node. Each node contains data and a pointer to the
( A ) Next node ( B ) Previous node

(C) Last node (D) First node

Correct Option: ( A, )

Solution:

44 Which of the following is application of linked list?


(B)
(A) implementation of doubly linked list implementation of linear list of an
integer
(C) Both of the above (D) None of these

Correct Option: ( C, )

Solution:

45 The data structure required for Breadth First Traversal on a graph is


( A ) Stack ( B ) Array

(C) Tree (D) Queue

Correct Option: ( D )

Solution:

46 For the size of the structure and the data in the structure are constantly
changing this process is best suited in ------------
( A ) Array ( B ) Stack

(C) Queue (D) Linked list

Correct Option: ( D )

Solution:

Professor Academy No.42, Railway Border road, Kodambakkam, Chennai, State - Tamil Nadu, Pin Code - 600024 ,+91 9150567983
47 Which of the following points is not true about linked list data structure
when it is compared with array?
(A) (B)
Arrays have better cache locality that can It is easy to insert and delete elements in
make them better in terms of linked list
performance
(C) (D)
Random access is not allowed in a typical Access of elements in linked list takes
implementation of linked lists less time than compared to arrays

Correct Option: ( D )

Solution:

48 Which of the following is true with respect to a doubly linked list


It can be traversed in both forward and backward directions
Insertion is easily possible No extra space is needed for a previous pointer
( A ) ii and iii only ( B ) iii only

(C) i and ii only (D) None of the above

Correct Option: ( C, )

Solution:

49 Linked list is not suitable for ----------------- because we can’t jump directly
to the required node while searching
( A ) Binary search ( B ) Insertion sort

(C) Polynomial (D) None of the above

Correct Option: ( A, )

Solution:

50 The classic way to implement a priority queue is using a data structure


called a -----------
( A ) Binary heap ( B ) Binary tree

(C) AVL tree (D) Red – black tree

Correct Option: ( A, )

Solution:

Professor Academy No.42, Railway Border road, Kodambakkam, Chennai, State - Tamil Nadu, Pin Code - 600024 ,+91 9150567983

You might also like