wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Major Data Structures and Algorithm

Total questions: 80

Worksheet time: 2hrs 31mins

Name
Class
Date
1.

What is an algorithm?

a)

A way to store and organize data

b)

A well-defined computational procedure

c)

A collection of data values

d)

An operation used to measure time complexity

2.

What is a data structure?

a)

A way to store and organize data

b)

A well-defined computational procedure

c)

A collection of data values

d)

An operation used to measure time complexity

3.

Which of the following is NOT a common data structure?

a)

Array

b)

Linked List

c)

Stack

d)

Database

4.

What is the time complexity of an algorithm?

a)

The number of operations used by the algorithm

b)

The size of the input and the use of many structures in a program

c)

The comparison of integers and different algorithms in a program

d)

The addition of integers

5.

What is the purpose of algorithm analysis?

a)

To define and familiarize algorithms

b)

To measure the time complexity of algorithms

c)

To store and organize data

d)

To solve a problem

6.

What is the purpose of big-Θ notation?

a)

To define and familiarize algorithms

b)

To measure the time complexity of algorithms

c)

To store and organize data

d)

To solve a problem

7.

What is a linked list?`

a)

A linear collection of data elements

b)

A data structure consisting of a group of nodes

c)

A sequence of nodes

d)

A collection of elements with linear order

8.

Nodes in a linked list contain two things

a)

Direction and a pointer

b)


Data and a pointer

c)

A Pointer and a reference

d)

A pointer and a node

9.

What advantage does a linked list have over an array?

a)

Size of the list doesn't need to be mentioned at the beginning of the program

b)

The linked list doesn't have a size limit

c)

You can add or remove elements from the middle of the list.

d)

All of these are true.

10.

A linked list contains a list pointer variable _____that stores the address of the first node of the list.

a)

Head

b)

NULL

c)

NEXT

d)

LAST

11.

What is the time complexity to count the number of elements in the linked list?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

none of these

12.

Each Node contain minimum two fields one field called data field to store data. Another field is of type _________.

A

a)

pointer to an integer

b)

pointer to a node

c)

pointer to a class

d)

pointer to a character

13.

What is the time complexity to adding an elements in front of the linked list?

a)

O(1)

b)

O(n)

c)

O(log n)

d)

none of these

14.

The situation when in a linked list START=NULL is

a)

underflow

b)

overflow

c)

list full

d)

saturated

15.

A linear dynamic data structure to store data items is called

a)

Linked list

b)

Stack

c)

Tree

d)

Queue

16.

An item in linked list is called

a)

Node

b)

Head

c)

Tail

d)

Pointer

17.

The first and last node is called

a)

Head and tail

b)

Head and leg

c)

Eye and tail

d)

Eye and leg

18.

Which one is the advantage of linked list:

-         1 Linked list random access is not allowed

-          Linked lists need more memory

-          Linked lists have dynamic size

a)

3

b)

1

c)

2 and 3

d)

1, 2, and 3

19.

Which one is the disadvantage of linked list:

-          Linked lists have dynamic size

-          Linked lists cannot randomly access

-          Linked lists are linked with pointer

a)

2

b)

1

c)

1 and 3

d)

1, 2, and 3

20.

Which one of these pictures is the insertion in the middle of linked list

a)

b)

c)

d)

21.

Which are the correct statements?

- Linked List insertion of new element is expensive

- Linked list random access is not possible

- Linked List need extra memory space for next pointer

a)

1 and 2

b)

1 and 3

c)

2 and 3

d)

1

22.

Stacks have LIFO ordering

a)

TRUE

b)

FALSE

23.

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

a)

AB + CDE * - * F *G /

b)

AB+ CD*E - FG /**

c)

AB + CD* E - F **G /

d)

AB + CD* E - *F *G /

24.

Which of them is an abstract data structure (ADT)?

a)

Stacks

b)

Functions

c)

Queues

d)

Both A and C

25.

LIFO stands for

a)

List of Outputs

b)

Last in First Out

c)

First in Last Out

d)

None of them

26.

Act of adding values into a stack is called

a)

Popping

b)

Polling

c)

Pushing

d)

None

27.

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

a)

*AB/CD+

b)

AB*CD/+

c)

A*BC+/D

d)

ABCD+/*

28.

The prefix form of A-B/ (C * D ⋀ E) is?

a)

-/*⋀ACBDE

b)

-ABCD*⋀DE

c)

-A/B*C⋀DE

d)

-A/BC*⋀DE

29.

Which of the following statement(s) about stack data structure is/are NOT correct?

a)

Stack data structure can be implemented using linked list

b)

New node can only be added at the top of the stack

c)

Stack is the FIFO data structure

d)

The last node at the bottom of the stack has a NULL link

30.

If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, in what order will they be removed?

a)

ABCD

b)

DCBA

c)

DCAB

d)

ABDC

31.

What will be the postfix form of the above expression -

(A+B)∗(C∗D-E)∗F/G

a)

None of these

b)

A B + C D ∗ E − F G ∗ / ∗

c)

A B + C D E ∗ − F G / ∗ ∗

d)

A B + C D ∗ E − F G / ∗ ∗

32.

A queue is called a FIFO data structure?

a)

True

b)

False

33.

a QUEUE in a computer acts just like people queuing for a bus - the first person in queue is going to be the first to get on the bus.

a)

True

b)

False

34.

A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Front" pointer point?

a)

Bert

b)

Cynthia

c)

Cedric

d)

Albert

35.

A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Rear" pointer point?

a)

Bert

b)

Cynthia

c)

Cedric

d)

Albert

36.

is a linear structure that follows a particular order in which the operations are performed. The order is First In First Out (FIFO).

a)

Queue

b)

Stack

c)

Array

d)

tabulation

37.

Which is the correct operation for:

"Add a item to the rear of the queue."

a)

enQueue(item)

b)

Append.Queue(item)

c)

enQueue()

d)

AddItem(EnQueue())

38.

In queue, an element can be inserted in location pointed by

a)

top

b)

front (or head)

c)

rear (or tail)

d)

none of the above

39.
A tree is composed of ____ connected by edges or lines.
a)
Fruit 
b)
Leaf Node
c)
Root Node
d)
Nodes
40.
A Kind of tree where every node in a tree can have at most two children.
a)
Binary Tree
b)
Binary Expression Tree
c)
Tree
d)
Binary Search Tree
41.

What is the value of the ROOT node in this Tree?

a)

35

b)

24

c)

42

d)

20

42.

Binary TREE

a)

data structure similar to a graph, with no loops.

b)

an object in a graph also known as a vertex

c)

a join of relationship between nodes - also know as an arc

d)

a tree where each node can only have 2 child nodes attached to it

43.

How many leaf are there in the tree?

a)

1

b)

3

c)

4

d)

7

44.

What are the 3 depth traversals for a tree data structure?

a)

Pre-, In- and Post-order

b)

Pro-, In- and Past-order

c)

Pre-, Out- and Post-order

d)

Pre-, In- and New-order

45.

When traversing a binary tree, which diagram is post-order?

a)

b)

c)

46.

What is the degree of a vertex in an undirected graph?

a)

The number of edges incident on the vertex

b)

The number of vertices connected to the vertex

c)

The length of the shortest path to the vertex

d)

The weight of the vertex

47.

It is a graph in which edges do not have any direction

a)

Connected graph

b)

Trivial graph

c)

Undirected graph

d)

null graph

48.

A graph in which edge has direction. That is the nodes are ordered pairs in the definition of every edge.

a)

Directed graph

b)

undirected graph

c)

Connected graph

d)

Regular graph

49.

A graph in which vertex can be divided into two sets such that vertex in each set does not contain any edge between them.

a)

Weighted graph

b)

bipartite graph

c)

Cyclic graph

d)

connected graph

50.

What is a cycle in a graph?

a)

A path that visits each vertex exactly once

b)

A path that starts and ends at the same vertex

c)

A path with the minimum possible weight

d)

A path with the minimum possible weight

51.

When is a walk considered open?

a)

.When there are no repeated edges  

b)

When the starting and ending vertices are the same

c)

When the starting and ending vertices are the same

d)

When the starting and ending vertices are different

52.

What is a trail in a graph?

a)

A closed walk with repeated edges

b)

An open walk with no repeated edges

c)

An open walk with no repeated vertices

d)

A closed walk with no repeated vertices

53.

How is a circuit different from a trail?

a)

A circuit has repeated edges, while a trail does not

b)

A circuit has repeated vertices, while a trail does not

c)

A circuit is always open, while a trail is always closed

d)

A circuit is always closed, while a trail is always open

54.

When is a cycle formed in a graph?

a)

When there are repeated vertices but no repeated edge

b)

When there are repeated edges but no repeated vertices

c)

When both vertices and edges are repeated, and the starting and ending vertices are the same

d)

When both vertices and edges are repeated, and the starting and ending vertices are different

55.

What is the purpose of Dijkstra's Algorithm?

a)

Finding cycles in a graph     

b)

Finding the minimum spanning tree

c)

Finding the shortest paths from a source vertex to all vertices

d)

Detecting disconnected subgraphs

56.

In Dijkstra's Algorithm, how is the shortest path tree (SPT) generated?

a)

By including vertices with maximum distance values

b)

By including vertices with minimum distance values

c)

By including vertices randomly

d)

By including vertices with maximum weight

57.

What does BFS stand for in the context of graphs?

a)

Best-First Search

b)

Breadth-First Search

c)

Binary-First Search

d)

Balanced-First Search

58.

When using Dijkstra's Algorithm, what is the purpose of the set "sptSet"?

a)

To keep track of vertices included in the shortest path tree

b)

To store the distances between vertices

c)

To identify disconnected subgraphs

d)

To maintain a list of all vertices in the graph

59.

In Dijkstra's Algorithm, what does the distance value of a vertex represent?

a)

The weight of the vertex

b)

b The number of edges to reach the vertex from the source

c)

The maximum distance to any vertex in the graph

d)

The sum of distances from the source to that vertex

60.

What is the primary purpose of a sorting algorithm?

a)

To delete elements from an array     

b)

To search for a specific element in an array

c)

To find the maximum element in an array

d)

To rearrange elements based on a comparison operator

61.

How does the Selection Sort algorithm work?

a)

By repeatedly swapping adjacent elements

b)

By dividing the array into two halves

c)

By selecting the smallest element and moving it to the sorted portion

d)

By recursively merging subarrays

62.

What is an advantage of the Selection Sort algorithm?

a)

It has a time complexity of O(N logN)

b)

It works well on large datasets

c)

It is stable   

d)

It is simple and easy to understand

63.

How does Insertion Sort work?

a)

By repeatedly swapping adjacent elements of the array

b)

By recursively dividing the array

c)

By selecting the smallest element     

d)

By splitting the array into sorted and unsorted parts

64.

What is a drawback of Merge Sort?

a)

It requires additional memory for the merged subarrays

b)

It has a worst-case time complexity of O(N logN)

c)

It is not stable

d)

It is not suitable for large datasets

65.

What is a characteristic of Quick Sort?

a)

It is always a stable sort

b)

It is not suitable for large datasets 

c)

It uses a divide-and-conquer approach

d)

It requires additional memory for sorting

66.

In the Partition Algorithm of Quick Sort, what is the role of the pivot?

a)
To remove the pivot element from the array
b)
To sort the array in descending order
c)
To merge the sub-arrays after sorting
d)
To divide the array into two sub-arrays based on the pivot element
67.

What is an advantage of Quick Sort over other algorithms?

a)
Faster average time complexity
b)
Slower average time complexity
c)
More difficult to implement
d)
Less efficient memory usage
68.

Which sorting algorithm works by repeatedly swapping adjacent elements if they are in the wrong order?

a)

Selection Sort

b)

Bubble Sort

c)

Insertion Sort       

d)

Quick Sort

69.

What is a characteristic of Merge Sort that makes it stable?

a)

It uses a divide-and-conquer approach

b)

It maintains the relative order of equal elements

c)

It works well for large datasets

d)

It has low time complexity for average cases

70.

What characteristic makes Insertion Sort adaptive?

a)

It is naturally parallelizable  

b)

It is stable  

c)

It is suitable for partially sorted datasets    

d)

It is suitable for partially sorted datasets    

71.

Consider a situation where swap operation is very costly. Which of the following sorting algorithms should be preferred so that the number of swap operations are minimized in general?

a)
Quick Sort
b)
Bubble Sort
c)

Selection Sort

d)
Insertion Sort
72.

Which of the following is not true about comparison-based sorting algorithms?

a)
They are not affected by the input data
b)
They have a time complexity of O(n)
c)
They are always faster than non-comparison-based sorting algorithms
d)
They always have a space complexity of O(n)
73.

Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the array looking like this: [5 1 7 9 12 11 10] Which statement is correct?

a)
C. The pivot element is 10
b)
A. The pivot element is 7
c)
B. The pivot element is 5
d)
D. The pivot element is 1
74.

Which of the following sorting algorithms has the lowest worst-case complexity?

a)
Merge Sort
b)
Selection Sort
c)
Insertion Sort
d)
Bubble Sort
75.

Which sorting algorithms is most efficient to sort string consisting of ASCII characters?

a)
Insertion Sort
b)
Quick Sort
c)
Bubble Sort
d)

none of the options

76.

For the given graph(G), which of the following statements is true?

a)
The graph is a tree.
b)
The graph has no vertices.
c)
The graph is connected.
d)
The graph is disconnected.
77.

A connected planar graph having 6 vertices, 7 edges contains _____________ regions.

a)
3
b)
5
c)
8
d)
2
78.

Which of the following properties does a simple graph not hold?

a)
Directed edges
b)
Weighted edges
c)
Disconnected vertices
d)
Parallel edges or self-loops
79.

Which of the following ways can be used to represent a graph?

a)

Adjacency List and Adjacency Matrix

b)

Incidence Matrix

c)

Adjacency List, Adjacency Matrix as well as Incidence Matrix

d)

All of the choices

80.

What is the maximum number of edges in a bipartite graph having 10 vertices?

a)

24

b)

21

c)

25

d)

16