wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Data Structures and Algorithms

Total questions: 100

Worksheet time: 59mins

Name
Class
Date
1.
Finite set of instructions that specify a sequence of operations to be carried out 
a)
Algorithms
b)
Procedure
c)
Flowcharting
d)
Pseudocodes
2.

Efficiency of an algorithm is measured by

a)

Time and Capacity complexity

b)

Time and Space complexity

c)

Speed and Space complexity

d)

Speed and Capacity complexity

3.

A container that can hold a fixed number of items and these items should be of the same type.

a)

Element

b)

Array

c)

Index

4.

What is an algorithm?

a)

Patterns and trends used to solve a problem

b)

A set of step-by-step instructions to resolve a problem

c)

A programming language

5.

How can an algorithm be represented?

a)

As a flowchart only

b)

As pseudocode only

c)

As a flowchart or pseudocode

6.

Which of these is not a data structure?

a)

Stack

b)

Array

c)

Integer

d)

List

7.
What is a data structure?
a)
A method of arranging data
b)
A way of keeping data without an order?
c)
A "stack" only
d)
There is no formal definition for "Data Structure"
8.

Data Structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.

a)

True

b)

False

9.

Example of Non-linear data structure.

a)

array

b)

tree

c)

queue

d)

stack

10.

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

11.

Act of adding values into a stack is called

a)

Popping

b)

Polling

c)

Pushing

d)

None

12.
Which of the following is NOT a Type of Data Structures?
a)
Arrays
b)
Tables
c)
Stacks
d)
Trees
13.

Which of these data structures is LIFO?

a)

Stack

b)

Queue

c)

Binary Tree

d)

Double linked list

14.

It is a type of queue where elements are processed based on their order either natural or custom.

a)

Priority Queue

b)

Array List

c)

Min Heap

d)

Max Heap

15.

Which of the following creates an empty set in Java?

a)

a = set()

b)

Set a = new HashSet ();

c)

A = set [ ]

d)

Set a = new TreeSet ();

16.

Which statement determine whether a map contains the value "Pre-final" with the PF identifier?

a)

thisMap.containsKey("Pre-final");

b)

thisMap.containsValue("PF");

c)

thisMap.containsKey("PF");

d)

thisMap.containsValue("Prefinal");

17.

It is a complete binary tree where the value of each parent node is either higher or lower than the value of its child nodes.

a)

Priority Queue

b)

Heap

c)

Array List

d)

Queue

18.

Priority Queues can be implemented in Java using the PriorityQueue class from the ___________ package.

a)

java.scanner

b)

Java.io

c)

java.linkedlist

d)

java.util

19.

A collection of elements where each element is unique.

a)

HashSet

b)

TreeSet

c)

Set

d)

LinkedHashSet

20.

This stores its elements in a hash table without a guaranteed order upon iteration.

a)

Set

b)

HashSet

c)

TreeSet

d)

LinkedHashSet

21.

This stores its elements in a special type of tree where elements are sorted either natural or custom during iteration.

a)

LinkedHashSet

b)

TreeSet

c)

HashSet

d)

Set

22.

A set of ordered pairs where elements are known as keys or identifiers and values or content.

a)

Set

b)

Map

c)

Priority Queue

d)

Array List

23.

A map can contain duplicate keys.

a)

True

b)

False

24.

Each key can map to several values.

a)

True

b)

False

25.

Maps in Python are known as dictionaries.

a)

True

b)

False

26.

Which statement maps the value "Pre-final" to the identifier named PF?

a)

thisMap.put("PF", "Pre-final");

b)

thisMap.put("Pre-final", "PF");

c)

thisMap.add("Pre-final", "PF");

d)

thisMap.add("PF", "Pre-final");

27.

Based on the following statements, which are the leaf nodes?

ArrayList<Integer> minHeap = new ArrayList<>();

Collections.addAll(minHeap, 2, 4, 5, 7, 8);

a)

5, 7, and 8

b)

4, 5, and 7

c)

2, 4, and 5

d)

7 and 8

28.

Set A = { 1, 3, 5, 7 }

Set B = { 2, 3, 4, 5 }

The difference of sets A and B (A - B) is _______?

a)

{ 3}

b)

{ 5 }

c)

{ 1, 7 }

d)

{ 3, 5}

29.

The number of edges from the node to the deepest leaf is called ___ of the tree.

a)

Height

b)

Depth

c)

Length

d)

Width

30.

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

31.

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 is filled 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

32.

Which of the following is not an advantage of trees?

a)

Hierarchical structure

b)

Faster search

c)

Router algorithms

d)

Undo/Redo operations in a notepad

33.

In a full binary tree if number of internal nodes is I, then number of leaves L are?

a)

L = 2*I

b)

L = I + 1

c)

L = I – 1

d)

L = 2*I – 1

34.

Which of the following highly uses the concept of an array?

a)

Binary Search tree

b)

Caching

c)

Spatial locality

d)

Scheduling of Processes

35.

Any node is the path from the root to the node is called

a)

Successor node

b)

Ancestor node

c)

Internal node

d)

None of the above

36.

Which of the following options is not true about the Binary Search tree?

a)

The value of the left child should be less than the root node

b)

The value of the right child should be greater than the root node

c)

The left and right sub trees should also be a binary search tree

d)

None of the above

37.

What is the maximum number of children that a node can have in a binary tree?

a)

3

b)

1

c)

4

d)

2

38.

The maximum number of nodes in a binary tree of depth 5 is

a)

31

b)

16

c)

32

d)

15

39.

In a min-heap:

a)

parent nodes have values greater than or equal to their Childs

b)

parent nodes have values less than or equal to their Childs

c)

both statements are true

d)

both statements are wrong

40.

n elements of a Queue are to be reversed using another queue. The number of "ADD" and "REMOVE"operations required to do so is:

a)

2*n

b)

4*n

c)

n

d)

The task cannot be accomplished

41.

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

42.

If two trees have same structure and but different node content,

then they are called

a)

Synonyms trees

b)

Joint trees

c)

Equivalent trees

d)

Similar trees

43.

If two trees have same structure and node content, then they are

called

a)

Synonyms trees

b)

Joint trees

c)

Equivalent trees

d)

Similar trees

44.

Which of the following is non-liner data structure?

a)

Stacks

b)

List

c)

Strings

d)

Trees

45.

To represent hierarchical relationship between elements, which data structure is suitable?

a)

Dequeue

b)

Priority

c)

Tree

d)

Graph

46.

The no of external nodes in a full binary tree with n internal nodes is?

a)

n

b)

n+1

c)

2n

d)

2n+1

47.

A Binary Tree can have

a)

Can have 2 children

b)

Can have 1 children

c)

Can have 0 children

d)

All of the above

48.

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

a)

Height

b)

Depth

c)

Length

d)

 Width

49.

Which of this pseudocode statement assigns a value to a variable?

a)

car <- bmw

b)

car is bmw

c)

car == bmw

d)

bmw -> car

50.

Which of this is a valid variable name?

a)

111abc

b)

abc111

c)

abc 111

d)

abc111!

51.

What is the difference between / and % operator?

a)

% operator gives the 'Quotient' from a division operation

AND

/ operator gives the 'Remainder' value from a division operation

b)

/ operator gives the 'Quotient' from a division operation

AND

% operator gives the 'Remainder' value from a division operation

c)

Both / and % operators are the same

52.

A Data Structure is:

a)

A C++ vector

b)

A way of organizing, storing and performing operations on data.

c)

A function in any programming language

d)

A sequence of steps to solve a problem.

53.

Which one is not a data structure?.

a)

Graph

b)

Index

c)

Binary Tree

d)

Record

54.

Which C++ Abstract Data Type is similar to a record?.

a)

Graph

b)

Function

c)

Struct

d)

Enum

55.

An Algorithm is:

a)

The process to transform the design into code.

b)

Braking a large problem into smaller ones

c)

A list of steps needed to solve a problem

d)

None of the above.

56.

Is the Data Structure used irrelevant for the creation of a program?.

a)

Yes

b)

No

57.

A list is:

a)

An ADT for storing items in which the order does not matter and duplicate items are allowed.

b)

An ADT for a collection of distinct items

c)

An ADT in which items are only inserted on or removed from the top of the stack.

d)

An ADT for holding ordered data

58.

Computational Complexity is:

a)

The amount of resources used by the algorithm.

b)

The amount of time taken by an algorithm.

c)

The amount of electricity used by an algorithm.

d)

The amount of bytes included in the algorithm.

59.

The efficiency of an algorithm is measured by:

a)

The run-time of the program.

b)

The length of the algorithm.

c)

The computational complexity of the algorithm.

d)

The speed of the CPU

60.

Abstraction means:

a)

Is an art type.

b)

An object that is hidden from the end user.

c)

A data type that only can be accessed by the developer.

d)

To have a user interact with an item at a high-level, with lower-level internal details hidden from the user.

61.

Does Abstracts Data Types support the programmer's efficiency?.

a)

Yes

b)

No

62.

What is an array?

a)

A linear collection of data elements with random access

b)

A linear collection of data elements with consecutive storage

c)

A dynamic data structure with elements stored in random locations

d)

A collection of linked nodes with consecutive storage

63.

How is memory allocated for a node in a linked list using malloc?

a)

malloc(sizeof(struct node))

b)

malloc(sizeof(struct node*)

c)

malloc(sizeof(struct node) + sizeof(struct node*)

d)

malloc(sizeof(struct node*) + sizeof(struct node)

64.

What is the purpose of the head pointer in a linked list?

a)

To point to the last node in the list

b)

To track the first element in the linked list

c)

To store the size of the linked list

d)

To allow random access of data in the linked list

65.

Which type of linked list allows elements to be added or removed from the middle of the list?

a)

Singly Linked List

b)

Doubly Linked List

c)

Circular Linked List

d)

All of the above

66.

What is a memory leak in dynamic memory allocation?

a)

Allocating memory without using malloc

b)

Not deallocating memory using free

c)

Allocating too much memory using malloc

d)

Deallocating memory multiple times using free

67.

Which function is used to deallocate memory in dynamic memory allocation?

a)

release()

b)

deallocate()

c)

free()

d)

clear()

68.

What is the main advantage of a linked list over an array?

a)

Random access of elements

b)

Efficient memory usage

c)

Fixed size

d)

Limited insertion and deletion operations

69.

Which type of linked list is both singly linked and doubly linked?

a)

Singly Linked List

b)

Doubly Linked List

c)

Circular Linked List

d)

All of the above

70.

How is a new node inserted at the beginning of a singly linked list?

a)

Update the next pointer of the new node to point to the current head of the list

b)

Set the head pointer of the linked list to point to the newly created node.

c)

Allocate space for the new node with malloc

d)

All of the above

71.

In a singly linked list, how is the insertion at the end performed when there is at least one node in the list?

a)

temp->next = ptr; ptr->next = NULL;

b)

ptr->next = temp; temp->next = NULL;

c)

temp = ptr; ptr->next = NULL;

d)

temp->next = NULL; ptr->next = temp;

72.

How is deletion performed in a singly linked list at the beginning?

a)

Set `head` to `NULL` and free the pointer pointing to the head node.

b)

Move `head` to the next node and free the pointer pointing to the original head.


c)

Free the pointer pointing to the head node and set `head` to `NULL`

d)

Move `head` to the next node and set the next of the original head to `NULL

73.

How is searching performed in a singly linked list?

a)

All of the above.

b)

By comparing the data of each node with the specified element.

c)

By using a binary search algorithm.

d)

By checking the next pointers of each node.

74.

How would you count the number of nodes in a singly linked list using recursion?

a)

return countnode(st->next);

b)

return countnode(st->next) - 1;

c)

return countnode(st) + 1;

d)

return countnode(st) - 1;

75.

 In traversing a singly linked list, what is the purpose of the `ptr` pointer?

a)

To point to the last node.


b)

To points to the node that is currently being accessed.


c)

To keep track of the head node.

d)

To count the number of nodes.

76.

What is the main difference between a singly linked list and a doubly linked list?

a)

Singly linked lists have a next pointer, while doubly linked lists have both next and previous pointers.

b)

Singly linked lists are dynamic, while doubly linked lists are static.

c)

Singly linked lists allow random access, while doubly linked lists do not.

d)

Singly linked lists store data in consecutive memory locations, unlike doubly linked lists.


77.

Example of linear data structure except

a)

array

b)

tree

c)

queue

d)

stack

78.
_________________ is a collection of elements used to store the same type of data.
a)
Array
b)
Switch
c)
Case
d)
Loop
79.

Which of these data structures is LIFO?

a)

Stack

b)

Queue

c)

Binary Tree

d)

Double linked list

80.

int nums[ ] =

{2, 3, 5, 8, 9, 11};

How would you access the fourth element in nums

a)

nums[8]

b)

nums[3]

c)

nums(4)

d)

nums(3)

81.
Which of the following is NOT a Type of Data Structures?
a)
Arrays
b)
Tables
c)
Stacks
d)
Trees
82.
Storage for data defined in terms of set of operations to be performed on the data 
a)
Arrays
b)
Variables
c)
Abstract Data Types
d)
Algorithms
83.

A FIFO structure implemented as a ring where the front and rear pointers can wrap around the end of the start of the array.

a)

Linear Queue

b)

Circular Queue

c)

Priority Queue

84.

It use pointer to link nodes.

a)

Variable

b)

Link List

c)

Pointer

d)

Trees

85.
What kind of Data structure would you expect to find utilised to store operations in a CPU?
a)
Stack
b)
Queue
c)
List
d)
Tree
86.

LIFO stands for

a)

List of Outputs

b)

Last in First Out

c)

First in Last Out

d)

None of them

87.

Act of adding values into a stack is called

a)

Popping

b)

Polling

c)

Pushing

d)

None

88.

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

89.

Consider the following operation performed on a stack of size 5.


Push(1);

Pop();

Push(2);

Push(3);

Pop();

Push(4);

Pop();

Pop();

Push(5);


After the completion of all operation, get the total number of element present in stack is

a)

1

b)

2

c)

3

d)

4

90.
a)

circular linked list

b)

linked list

c)

doubly circular linked list

d)

doubly linked list

91.

Test Driven Development (TDD) is a part of ____________.

a)

extreme programming

b)

Spiral Model

c)

Halstead Software Science

d)

COCOMO

92.

In Halstead theory of software science, volume is measured in bits. The bits are

a)

Number of bits required to store the program

b)

Actual size of a program if a uniform binary encoding scheme for vocabulary is used

c)

Number of bits required to execute the program

d)

Average Manning

93.

In which one of the following types of coupling, complete data structures are passed from one module to another?

a)

Control Coupling

b)

Stamp Coupling

c)

External Coupling

d)

Content Coupling

94.

Which one of the following is the correct ordering of the coupling of modules from strongest (least desirable) to weakest (most desirable)?

a)

content, common, control, stamp, data

b)

common, content, control, stamp, data

c)

content, data, common ,stamp, common

d)

data, control, common, stamp, content

95.

During the detailed design of a module, which one of the following is designed?

a)

Data structures and algorithms

b)

Control structure

c)

Data flow structure

d)

Module interfaces

96.

A data flow diagram represents which one of the following?

a)

The conditions based on which data items may be processed

b)

The order in which different activities are carried out

c)

The transformation of data through processing stations

d)

The order in which various functions of a program are invoked

97.

Consider the sentence: A book has one or more pages. Which of the following best characterizes the relationship between the Book class and the Page class?

a)

Inheritance

b)

Specialization

c)

Association

d)

Composition

98.

Which one of the following characteristics of a class implies that the same message can be interpreted by it differently.

a)

Encapsulation

b)

Polymorphism

c)

Information Hiding

d)

Inheritance

99.

________________ illustrate the dynamic nature of a system by modeling the flow of control form activity to activity.

a)

Activity Diagram

b)

Sequence Diagram

c)

State chart Diagram

d)

Class Diagram

100.

Temporal cohesion means

a)

Cohesion between temporary variables

b)

Cohesion between local variable

c)

Cohesion with respect to time

d)

Coincidental cohesion