Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DSA quiz

Total questions: 40

Worksheet time: 23mins

Name
Class
Date
1.

Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?

a)

Insertion sort

b)

Quick sort

c)

Heap sort

d)

Merge sort

2.

In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is..

a)

log(2*n)

b)

n\2

c)

log(2*n)-1

d)

n

3.

Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is the worst-case time complexity of the best known algorithm to delete the node Q from the list?

a)

O(n)

b)

O(log2n)

c)

O(log n)

d)

O(1)

4.

The minimum number of stacks needed to implement a queue is

a)

3

b)

2

c)

1

d)

0

5.

Which of the following correctly declares an array?

a)

int sparks[20];

b)

int spark;

c)

sparks{20};

d)

array sparks[20];

6.

Stack A has the entries a, b, c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An entry popped out of the stack B can be only be printed. In this arrangement, which of the following permutations of a, b, c are not possible?

a)

b a c

b)

b c a

c)

c a b

d)

a b c

7.

The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is

a)

A

b)

B

c)

C

d)

D

8.

The size of the array should always be _____

a)

POSITIVE

b)

NEGATIVE

c)

WHOLE NUMBER

d)

REAL NUMBER

9.

Which of these methods of class String is used to obtain the length of the String object?

a)

get()

b)

sizeof()

c)

lenghtof()

d)

lenght()

10.

In a circular linked list, the last node points to the____

a)

i don't know

b)

tail node

c)

first node

d)

middle pointer

11.

Nodes in a linked list contain two things:

a)

a pointer and a node

b)

a pointer and a reference

c)

direction and a pointer

d)

data and a pointer

12.

In a stack, if a user tries to remove an element from an empty stack it is called?

a)

empty collection

b)

garbage collection

c)

overflow

d)

underflow

13.

the list of data in which elements can be inserted and removed at the same end is called ____

a)

array

b)

string

c)

stack

d)

none

14.

two basic operation used in queue are

a)

push and pop

b)

enqueue and dequeue

c)

insert and remove

d)

none of these

15.

A tree data structure is a------ data structure

a)

hierarchical

b)

pre-defined

c)

primary

d)

none

16.

Errors that occur during the execution of a program are called?

a)

syntax error

b)

runtime error

c)

logical error

d)

linking error

17.

true definition of systematic error:

a)

Errors that occur because the compiler is unable to understand the written code

b)

those errors in which we think that our code is correct, the code compiles without any error and gives no error while it is running

c)

Errors that occur during the execution (or running) of a program

d)

the errors encountered when the executable file of the code can not be generated even though the code gets compiled successfully.....

18.

Which data structure is used for implementing recursion?

a)

stack

b)

queue

c)

linked list

d)

array

19.

In a depth-first search (DFS) of a graph, what data structure is typically used to keep track of visited vertices?

a)

stack

b)

queue

c)

linked list

d)

array

20.

What is the time complexity of the selection sort algorithm in the worst case?

a)

O(n)

b)

O(n log n)

c)

O(n^2)

d)

O(log n)

21.

I am a searching algorithm known for my efficiency when the data is sorted. What am I?

a)

linear search

b)

binary search

c)

quick search

d)

merge search

22.

Given an array of integers, how can you find the subarray with the maximum sum efficiently?

a)

divide and conquer

b)

dynamic programming

c)

greedy algorithm

d)

backtracking

23.

In the context of sorting algorithms, what is an "in-place" algorithm?

a)

An algorithm that doesn't use any extra memory

b)

An algorithm that sorts the elements in their original order

c)

An algorithm that is stable

d)

An algorithm that uses recursion

24.

What is a programmer's favorite kind of tree?

a)

birch tree

b)

pine tree

c)

binary tree

d)

oak tree

25.

What do you call a linked list that can sing?

a)

melody list

b)

node list

c)

singly linked list

d)

linked choir

26.

Why did the programmer break up with their data structure?

a)

it had too many issues

b)

it was unresponsive

c)

it wasn't their type

d)

they needed more space

27.

What do you call a snake that's good at algorithms?

a)

python

b)

c++

c)

java

d)

ruby

28.

Why do algorithms never argue?

a)

they always return the same result

b)

they have a common language

c)

they use binary logic

d)

they're too logical

29.

If you're stranded on an island and can only bring one algorithm with you for survival, which one would it be?

a)

breadth-first search(BFS)

b)

Depth-First search(DFS)

c)

dijkstra's algorithm

d)

A*Search algorithm

30.

What data structure is like a line at a grocery store, where the first one in is the first one out?

a)

stack

b)

queue

c)

linked list

d)

hash table

31.

What is the purpose of the algorithmic paradigm known as "Backtracking"?

a)

divide and conquer

b)

dynamic programming

c)

incremental

d)

recursive trial-and-error

32.

Which of the following is an NP-complete problem?

a)

shortest path problem

b)

travelling salesman problem

c)

binary search

d)

breadth-first search

33.

In a binary search tree, what is the time complexity for finding the kth smallest element?

a)

O(log n)

b)

O(n)

c)

O(n log n)

d)

O(n^2)

34.

I am a data structure that stores elements in a sorted order. Insertion and deletion are efficient in me. What am I?

a)

array

b)

linked list

c)

heap

d)

queue

35.

Which of the following is an example of a non-linear data structure?

a)

array

b)

linked list

c)

queue

d)

tree

36.

In a binary search tree, what is the key property that distinguishes it from other trees?

a)

nodes can have any number of children

b)

each node has at most two children

c)

all nodes have the same number of children

d)

nodes can have any type of data

37.

What is the purpose of a priority queue?

a)

sorting elements

b)

storing elements in a queue

c)

assigning priority to elements

d)

searching elements

38.

What is the purpose of hashing in data structures?

a)

searching

b)

sorting

c)

indexing

d)

all of the above

39.

What is the primary purpose of the Floyd-Warshall algorithm?

a)

finding the shortest path in a graph

b)

finding the minimum spanning tree in a graph

c)

searching for an element in an array

d)

sorting elements in a queue

40.

In a binary search tree, what is the minimum number of nodes in a tree with height 'h'?

a)

2^h

b)

h

c)

2^(h-1)

d)

h^2