Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Exploring Data Structures

Total questions: 110

Worksheet time: 2hrs 45mins

Name
Class
Date
1.

What is a data structure?

a)

A data structure is a programming language.

b)

A data structure is a type of computer program.

c)

A data structure is a specialized format for organizing, processing, and storing data.

d)

A data structure is a method for writing code.

2.

Name three types of linear data structures.

a)

Arrays, Linked Lists, Queues

b)

Stacks

c)

Trees

d)

Graphs

3.

What is the difference between an array and a linked list?

a)

An array can only store integers, while a linked list can store any data type.

b)

An array allows for fast access and fixed size, while a linked list allows for dynamic size and easier insertions/deletions.

c)

An array is always larger than a linked list.

d)

A linked list has a fixed size and allows for fast access.

4.

Explain the concept of a stack and its operations.

a)

A stack can only hold integer values and has no operations.

b)

A stack is a FIFO data structure with operations: enqueue and dequeue.

c)

A stack is a LIFO data structure with operations: push, pop, peek, and isEmpty.

d)

A stack is a data structure that allows random access to elements.

5.

What is a queue and how does it differ from a stack?

a)

A queue is a FIFO data structure, while a stack is a LIFO data structure.

b)

A queue is a LIFO data structure, while a stack is a FIFO data structure.

c)

A queue is a data structure that only allows insertion at the front.

d)

A queue allows random access, while a stack does not.

6.

Define a binary tree and its properties.

a)

A binary tree is a data structure where each node has at most two children.

b)

A binary tree is a type of graph that can have cycles.

c)

A binary tree is a linear data structure with a single parent node.

d)

A binary tree is a data structure where each node can have any number of children.

7.

What is a hash table and how does it work?

a)

A hash table is a physical table used in restaurants for serving food.

b)

A hash table is a type of database used for storing large amounts of data.

c)

A hash table is a data structure that uses a hash function to map keys to values for efficient data retrieval.

d)

A hash table is a programming language used for web development.

8.

Explain the concept of a graph and its types.

a)

A graph is a type of chart used for statistical data.

b)

Graphs only consist of points without any connections.

c)

A graph is a collection of vertices connected by edges, with types including directed, undirected, weighted, unweighted, cyclic, and acyclic.

d)

A graph is a linear sequence of numbers without any structure.

9.

What are the advantages of using a linked list over an array?

a)

Slower access time for elements

b)

Fixed size allocation

c)

Advantages of linked lists over arrays include dynamic size, efficient insertions/deletions, and ease of implementing complex data structures.

d)

More memory overhead for storage

10.

Describe the time complexity of accessing an element in an array.

a)

O(n)

b)

O(1)

c)

O(log n)

d)

O(n^2)

11.

Which sorting algorithm makes one swap per pass (possibly swapping an element with itself)?

a)

Selection Sort

b)

Bubble Sort

c)

Insertion Sort

12.

Which sorting algorithm may make multiple swaps per pass?

a)

Bubble Sort

b)

Selection Sort

c)

Insertion Sort

13.

Which sorting algorithm shifts elements instead of swapping elements if needed in each pass.

a)

Bubble Sort

b)

Selection Sort

c)

Insertion Sort

14.

The following lists represent 3 passes of a sorting algorithm. Which algorithm is being used to sort the list?
 
4    8    6    2    5    7 
4    8    6    2    5    7 
4    6    8    2    5    7

a)

Bubble Sort

b)

Selection Sort

c)

Insertion Sort

15.

We are sorting the following list in ascending order:
 
1    4    2    9    3    8    5
 
What does the list look like after one pass of the bubble sort algorithm. 

a)

1 2 4 3 8 5 9

b)

1 4 2 5 3 8 9

c)

4 2 9 3 8 5 1

16.

Time complexity of bubble sort in best case is

a)

a) θ (n)

b)

b) θ (nlogn)

c)

c) θ (n2)

d)

d) θ (n(logn) 2)

17.

Which of these algorithms sorts items by first splitting the list of items down into smaller and smaller groups?

a)

Bubble sort

b)

Merge sort

c)

Linear search

d)

Binary search

18.

What algorithm does this image represent?

a)

Bubble sort

b)

Merge sort

c)

Linear search

d)

Binary search

19.

Which type of sort algorithm is this?

a)

Insertion

b)

Merge

c)

Bubble

20.

Partition a list A[] into two non-empty parts.

in left part the values should be:

a)

A [ ] <= pivot

b)

A [ ] > pivot

c)

A[] >= pivot

d)

A [ ] < pivot

21.

Partition a list A[] into two non-empty parts.

in right part the values should be:

a)

A [ ] > pivot

b)

A [ ] >= pivot

c)

A [ ] < pivot

d)

A [ ] <= pivot

22.

Which algorithm matches this description: "a sorting algorithm that repeatedly partitions the input into low and high parts (each part unsorted), and then recursively sorts each of those parts."

a)

Selection Sort

b)

Insertion Sort

c)

Shell Sort

d)

Quicksort

23.

Which of the following is a max-heap?

a)
b)
c)
d)
24.

Consider a binary max-heap implemented using an array. Which one of the following array represents a binary max-heap?

a)

25,12,16,13,10,8,14

b)

25,12,16,10,13,8,14

c)

25,14,16,13,10,8,12

d)

25,14,12,13,10,8,16

25.

The elements 32, 15, 20, 30, 12, 25, 16 are inserted one by one in the given order into a Max Heap. The resultant Max Heap is.

a)
b)
c)
d)
26.

Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap is

a)

40, 30, 20, 10, 15, 16, 17, 8, 4, 35

b)

40, 35, 20, 10, 30, 16, 17, 8, 4, 15

c)

40, 30, 20, 10, 35, 16, 17, 8, 4, 15

d)

40, 35, 20, 10, 15, 16, 17, 8, 4, 30

27.

Given a binary-max heap. The elements are stored in an arrays as 25, 14, 16, 13, 10, 8, 12. What is the content of the array after two delete operations?

a)

14,13,8,12,10

b)

14,12,13,10,8

c)

14,13,12,8,10

d)

14,13,12,10,8

28.

The 2 properties of a min heap are _____.

a)

Tree must be full.

b)

Tree must be complete.

c)

Node values are always smaller than their children's values.

d)

Node values are always greater than their children's values.

29.

How many swaps are made in the min heap when inserting the value 18?

a)

0

b)

1

c)

2

d)

3

30.

When removing the root from a min heap, what is the first step?

a)

Replace the root with the next smallest value from the tree

b)

Replace the root with the leaf furthest to the left on the bottom level of the tree

c)

Replace the root with the leaf furthest to the right on the bottom level of the tree

d)

Replace the root with the smallest of its children

31.

When adding a value to a min heap, the first step is to ______.

a)

Add the new node at the next open leaf.

b)

Replace the root's value with the new value.

c)

Replace the roots smallest child with the new value.

d)

Add the new node as far right as possible on the bottom level of the tree.

32.

Select the best description to explain what a linear search algorithm is.

a)

Put the elements in order, check each item in turn.

b)

Put the elements in order, compare with the middle value, split the list in order and repeat.

c)

Elements do not need to be in order, check each item in turn.

d)

Elements do not need to be in order, compare to the middle value, split the list in order and repeat

33.

Select the best description to explain what a binary search algorithm is.

a)

Put the elements in order, check each item in turn.

b)

Put the elements in order, compare with the middle value, split the list in order and repeat.

c)

Elements do not need to be in order, check each item in turn.

d)

Elements do not need to be in order, compare to the middle value, split the list in order and repeat

34.

A linear search is to be performed on the list:
12   6   8  1  3
How many comparisons would it take to find number 1?

a)

1

b)

2

c)

3

d)

4

35.

A binary search is to be performed on the list:
3  5  9  10  23
How many comparisons would it take to find number 9?

a)

0-1

b)

2-3

c)

4-5

d)

I can't find the number 9

36.

A binary search is to be performed on the list:
1  5  10  13  48  68  100  101
How many comparisons would it take to find number 101?

a)

0-1

b)

1-2

c)

3-4

d)

4-5

37.

Describe an advantage of a binary search algorithm

a)

Data does not need to be in order.

b)

Performs well over large ordered lists.

c)

Can only work on an ordered list.  If unordered must use a linear search.

d)

Slow with large data sets.

38.

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)

39.

Which of the following is NOT a Type of Data Structures?

a)

Arrays

b)

Tables

c)

Stacks

d)

Trees

40.

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

41.

LIFO stands for

a)

List of Outputs

b)

Last in First Out

c)

First in Last Out

d)

None of them

42.

Act of adding values into a stack is called

a)

Popping

b)

Polling

c)

Pushing

d)

None

43.

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

44.

In some languages, arrays are also called ___

a)

groups or arrows

b)

roots or leaves

c)

lists or vectors

d)

lines or strings

45.

A data type that can be used to group items of possibly different types into a single type is called ___

a)

a root

b)

a struct

c)

a tree

d)

a pointer

46.

A flexible data structure that can store many nodes is called ___

a)

a tree

b)

a linked list

c)

a pointer

d)

a queue

47.

When linked lists are used as stacks, what kind of behaviour is implemented?

a)

First-In First-Out, or FIFO

b)

First-In Last-Out, or FILO

c)

Last-In Last-Out, or LILO

d)

Last-In First-Out, or LIFO

48.

In a tree data structure, the top most node is called ___

a)

the peak

b)

the apex

c)

the crown

d)

the root

49.

In a tree data structure, any nodes that hang from other nodes are called ___

a)

branched nodes

b)

leaf nodes

c)

children nodes

d)

daughter nodes

50.

In a tree data structure, any nodes that have no children (where the tree ends) are called ___

a)

boundary nodes

b)

leaf nodes

c)

orphan nodes

d)

terminal nodes

51.

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

a)

35

b)

24

c)

42

d)

20

52.

Root

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)

the starting node in a rooted tree structure from which all other nodes branch off./

53.

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)

the starting node in a rooted tree structure from which all other nodes branch off./

54.

How many leaf are there in the tree?

a)

1

b)

3

c)

4

d)

7

55.

Which Time and Space Complexity uses the O(n2) notation?

a)

Quadratic

b)

Linear

c)

Exponential

d)

Logarithmic

56.

What is the time complexity of this code

int a = 0, i = N;

while (i > 0)

{

a += i;

i /= 2;

}

a)

O(N)

b)

O(Sqrt(N))

c)

O(N / 2)

d)

O(log N)

57.

The complexity of Binary search algorithm is

a)

O(n)

b)

O(log n)

c)

O(n2)

d)

O(n log n)

58.

What is the time complexity of following code:

int a = 0;

for (i = 0; i < N; i++) {

for (j = N; j > i; j--) {

a = a + i + j;

}

}

a)

O(N)

b)

O(N*log(N))

c)

O(N * Sqrt(N))

d)

O(N*N)

59.

What is the time complexity of following code:

int i, j, k = 0;

for (i = n / 2; i <= n; i++) {

for (j = 2; j <= n; j = j * 2) {

k = k + n / 2;

}

}

a)

O(n)

b)

O(nLogn)

c)

O(n^2)

d)

O(n^2Logn)

60.

A linear function takes the form

a)

f(n) = an + b

b)

f(n) = an2 +bn + c

c)

f(n) = alog2n

d)

f(n) = a + b

61.

Find the slowest algorithm:

a)

O (n)

b)

O (n^2)

c)

O (n!)

d)

O (2^n)

62.

The number of executions grows extremely quickly as the size of the input increases

a)

Exponential Time

b)

Linear Time

c)

Polynomial Time

d)

Constant Time

63.

What does it mean when we say that an algorithm X is asymptotically more efficient than Y?

a)

X will be a better choice for all inputs

b)

X will be a better choice for all inputs except possibly small inputs

c)

X will be a better choice for all inputs except possibly large inputs

d)

Y will be a better choice for small inputs

64.
Consider this list of numbers: 3 4 6 7 8 9. If the number 9 was to be found using a linear search, how many comparisons need to be made?
a)
6
b)
3
c)
8
d)
4
65.
What is the main disadvantage of a binary search compared to a linear search?
a)
It requires the data to be in order
b)
It requires more memory
c)
It does not execute as quickly with larger data sets
d)
Not all CPUs are capable of executing the algorithm
66.
Consider this list of numbers L: 3 4 5 6 7 8 9. Which number would be checked first in a binary search?
a)
6
b)
3
c)
9
d)
4
67.

What is the worst case running time of the above pseudo code?

a)

O(n)

b)

O(n log n)

c)

O(n2)

d)

O(n3)

68.
What is the worst case running time of the above pseudo code?
a)
O(n)
b)
O(n log n)
c)
O(n2)
d)
O(n3)
69.

asymptotic notations represents

a)

space complexity of algo

b)

time complexity of algo

c)

both a and b

d)

none of the above

70.

Big

Ω\Omega defines

a)

lower bound

b)

upper bound

c)

middle bound

d)

none of the above

71.

What is the worst case complexity of selection sort?

a)

O(n log n)

b)

O(log n)

c)

O(n)

d)

O(n2)

72.

The stack is also known as?

a)

Last in first out

b)

First in last out

c)

First in first out

d)

.none of these

73.

define the name of the process in which items are added at one end and removed from another side?

a)

stack

b)

Queue

c)

List

d)

Tree

74.

Define the value of r in a circular queue?

a)

r=r+1

b)

r=(r+1)%[QUEUE_SIZE=1]

c)

r=(r+1)% QUEUE_SIZE

d)

r=(r-1)% QUEUE_SIZE

75.

What is the worst case complexity of bubble sort?

a)

O(nlogn)

b)

O(logn)

c)

O(n)

d)

O(n2)

76.

The measure of the longest amount of time possibly taken to complete an algorithm is expressed as __.

a)

Little-O

b)

Little-Omega

c)

Big-Omega

d)

Big-O

77.

___ of an algorithm is the amount of time required for it to execute.

a)

Time complexity

b)

Space complexity

c)

Compiling time

d)

Best case

78.

___ is the maximum amount of time an algorithm takes to execute a specific set of inputs.

a)

Running time

b)

Average case time complexity

c)

Worst case time complexity

d)

Best case time complexity

79.

Which one of the following helps in calculating the longest amount of time taken for the completion of the algorithm?

a)

Theta notation

b)

Big-Oh notation

c)

Omega notation

d)

Time complexity

80.

Which method is practical to perform a single search in an unsorted list of elements?

a)

Sequential search

b)

Bubble sort

c)

Horspool’s method of string matching

d)

Brute force method of string matching

81.

Which of the following best describes the useful criterion for comparing the efficiency of algorithms?

a)

Time

b)

Memory

c)

Both of the above

d)

None of the above

82.

What does it mean when we say that an algorithm X is asymptotically more efficient than Y?

a)

X will always be a better choice for small inputs

b)

X will always be a better choice for large inputs

c)

Y will always be a better choice for small inputs

d)

X will always be a better choice for all inputs

83.

If for an algorithm time complexity is given by O(1) then complexityof it is:

a)

constant

b)

polynomial

c)

exponential

d)

none of the mentioned

84.

If for an algorithm time complexity is given by O(n) then complexityof it is:

a)

constant

b)

linear

c)

exponential

d)

none of the mentioned

85.

What is the time complexity of following code:

int a = 0, i = N;

while (i > 0)

{

a += i;

i /= 2;

}

a)

O(N)

b)

O(Sqrt(N))

c)

O(N / 2)

d)

O(log N)

86.

The asymptotic upper-bound of f(n)=20n2+100n+2f\left(n\right)=20n^2+100n+2 is  O(n2)O\left(n^2\right)   

a)

True

b)

False

87.

The asymptotic upper-bound of f(n)=2n+2nf\left(n\right)=2n+2^n  is  O(n2)O\left(n^2\right)  

a)

True

b)

False

88.

If for an algorithm time complexity is given by O(1) then complexity of it is

a)

constant

b)

polynomial

c)

exponential

d)

none of the mentioned

89.

If for an algorithm time complexity is given by O(n) then complexity of it is

a)

constant

b)

linear

c)

exponential

d)

none of the mentioned

90.

What is the time complexity of following code

int a = 0, i = N;

while (i > 0) {

a + = i;

i / = 2;

}

a)

O(N)

b)

O(Sqrt(N))

c)

O(N / 2)

d)

O(log N)

91.

The linear/sequential search method to search an element in an array has the complexity of BigO(?)

a)

n

b)

n-1

c)

n^2

d)

n logn

92.

Indicate exponential time complexity in terms of big-O notation

a)

O (n)

b)

O (n^2)

c)

O (2^n)

d)

O (log n)

93.

Find the slowest time complexity

a)

O (n)

b)

O (n^2)

c)

O (n!)

d)

O (2^n)

94.

Which notation is consistent for every execution?

a)

O (n)

b)

O (n^2)

c)

O (1)

d)

O (2^n)

95.

Which notation grows in proportion to the size of the input

a)

O (n)

b)

O (n^2)

c)

O (1)

d)

O (2^n)

96.

Which notation would you usually use for a nested loop?

a)

O (n)

b)

O (n^2)

c)

O (1)

d)

O (2^n)

97.

The number of executions grows extremely quickly as the size of the input increases

a)

Exponential Time

b)

Linear Time

c)

Polynomial Time

d)

Constant Time

98.

The number of executions remains the same regardless of the input size

a)

Exponential Time

b)

Linear Time

c)

Polynomial Time

d)

Constant Time

99.

The number of executions grows quickly by the input being multiplied by the input

a)

Exponential Time

b)

Linear Time

c)

Polynomial Time

d)

Constant Time

100.

For every element, you are doing a constant number of operations, such as comparing each element to a known value.

a)

Quadratic

b)

Linear

c)

Logarithmic

d)

Constant

e)

Exponential

101.

What is the correct Big O notation for an algorithm where the number of operations (steps) can be expressed as:

4n3 +3n log⁡2n  + 2734n^3\ +3n\ \log_2n\ \ +\ 273   n is the size of the input.

a)

O(n2)O\left(n^2\right)  

b)

O(3n)O\left(3n\right)  

c)

O(log⁡2n)O\left(\log_2n\right)  

d)

O(273)O\left(273\right)  

e)

O(n3)O\left(n^3\right)  

102.

What is the big-Oh runtime of A()?

a)

O(nlog⁡n)O\left(n\log_{ }n\right)

b)

O(n2)O\left(n^2\right)

c)

O(n)O\left(n\right)

d)

O(10⋅n)O\left(10\cdot n\right)

103.

What is true for f(n)=log⁡nf\left(n\right)=\log_{ }n and g(n)=ng\left(n\right)=n ?

a)

f(n)=O(g(n))f\left(n\right)=O\left(g\left(n\right)\right)

b)

f(n)=θ(g(n))f\left(n\right)=\theta\left(g\left(n\right)\right)

c)

f(n)=Ω(g(n))f\left(n\right)=\Omega\left(g\left(n\right)\right)

104.

What is the maximum number of comparisons that a binary search will apply for an array of length 30.

a)

30

b)

15

c)

5

d)

3

e)

2

105.

What is the big-Oh runtime of B()?

a)

O(n2)O\left(n^2\right)

b)

O(n3)O\left(n^3\right)

c)

O(30⋅n)O\left(30\cdot n\right)

d)

O(n)O\left(n\right)

106.

Which of these is true for f(n)=5n3+7n+13f\left(n\right)=5n^3+7n+13 and g(n) = n5g\left(n\right)\ =\ n^5 ?

a)

f(n)=θ(g(n))f\left(n\right)=\theta\left(g\left(n\right)\right)

b)

f(n)=Ω(g(n))f\left(n\right)=\Omega\left(g\left(n\right)\right)

c)

f(n)=O(g(n))f\left(n\right)=O\left(g\left(n\right)\right)

107.

What is the big-Oh runtime of C(n)?

a)

O(10)O\left(10\right)

b)

O(n)O\left(n\right)

c)

O(n2)O\left(\frac{n}{2}\right)

d)

O(log⁡n)O\left(\log_{ }n\right)

108.

Which of the following is the time complexity of insertion sort?

a)

O(n2)O(n^2)

b)

O(log⁡n)O(\log n)

c)

O(n)O(n)

d)

O(nlog⁡n)O(n\log n)

109.

Which is true for f(n)=2nf\left(n\right)=2^n and g(n)=n!g\left(n\right)=n! ?

a)

f(n)=O(g(n))f\left(n\right)=O\left(g\left(n\right)\right)

b)

f(n)=θ(g(n))f\left(n\right)=\theta\left(g\left(n\right)\right)

c)

f(n)=Ω(g(n))f\left(n\right)=\Omega\left(g\left(n\right)\right)

110.

What is the big-Oh runtime of D(n)?

a)

O(n⋅log⁡n)O\left(n\cdot\log_{ }n\right)

b)

O(n2)O\left(n^2\right)

c)

O(log⁡n)O\left(\log_{ }n\right)

d)

O(2n)O\left(2n\right)