wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Data structure A2 mmd

Total questions: 111

Worksheet time: 1hrs 10mins

Name
Class
Date
1.

Which of these is not a data structure?

a)

Stack

b)

Array

c)

Integer

d)

List

2.

Which of these are operations of a stack?

a)

Push

b)

Add

c)

Remove

d)

Pop

3.

A stack is last in, "what" out?

(a)  

4.

A queue is what?

a)

Last in, first out

b)

First in, first out

c)

First in, last out

d)

Last in, last out

5.
A tree is composed of ____ connected by edges or lines.
a)
Fruit 
b)
Leaf Node
c)
Root Node
d)
Nodes
6.
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
7.

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

a)

35

b)

24

c)

42

d)

20

8.

In this tree, where would the new value "7" be placed?

a)

On the left branch of "4"

b)

On the right branch of "6"

c)

On the left branch of "15"

d)

Over the top of the current number "5"

9.

What is returned by values[5]?

a)

9

b)

12

c)

6

d)

8

10.
int nums[ ] =
{2, 3, 5, 8, 9, 11};
How would you access the fourth element in nums
a)
nums[4]
b)
nums[3]
c)
nums(4)
d)
nums(3)
11.

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

a)

ABCD

b)

DCBA

c)

DCAB

d)

ABDC

12.

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, the no of element present on stack are

a)

1

b)

3

c)

2

d)

4

13.

Records allow you to store more than one data type

a)

True

b)

False

14.

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)

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

c)

The linked list doesn't have a size limit

d)

All of these are true.

15.

A hash table is

a)

an abstract data structure

b)

an array

c)

an integer

d)

made of pine

16.

when an algorithm generates the same address for different primary keys it is known as

a)

Knock

b)

Bang

c)

Collisions

d)

DoubleHash

17.

Hashing gives each item

a)

A sequential address

b)

A logarithmic address

c)

No address

d)

A unique address

18.

When a collision occurs with a hashing function, what is one method for dealing with the collisions?

a)

creating a new linked list at that index

b)

creating a new array

c)

creating a new hash table

d)

creating a new binary tree

19.

If the insertion and deletion happens from both the ends then the queue is called a______Queue

a)

a) Deque

b)

b) Header

c)

c) Queue

d)

d) Circular Queue

20.

Process of inserting an element in stack is called ____________

a)

Create

b)

Push

c)

Evaluation

d)

Pop

21.

Entries in a stack are “ordered”. What is the meaning of this statement?

a)

A collection of stacks is sortable

b)

Stack entries may be compared with the ‘<‘ operation

c)

The entries are stored in a linked list

d)

There is a Sequential entry that is one by one

22.

Which of the following applications may use a stack?

a)

a) A parentheses balancing program

b)

b) Tracking of local variables at run time

c)

c) Compiler Syntax Analyzer

d)

d) Data Transfer between two asynchronous process

23.

The data structure required to check whether an expression contains balanced parenthesis is?

a)

a) Stack

b)

b) Queue

c)

c) Array

d)

d) Tree

24.

What does the following function do for a given Linked List with first node as head?

void fun1(struct node* head)

{

if(head == NULL)

return;

fun1(head->next);

printf("%d ", head->data);

}

a)

a) Prints all nodes of linked lists

b)

b) Prints all nodes of linked list in reverse order

c)

c) Prints alternate nodes of Linked List

d)

d) Prints alternate nodes in reverse order

25.

Linked list data structure offers considerable saving in _____________

a)

a) Computational Time

b)

b) Space Utilization

c)

c) Space Utilization and Computational Time

d)

d) Speed Utilization

26.

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

a)

Dequeue

b)

Priority

c)

Tree

d)

Graph

27.

Match the following.


a) Completeness i) How long does it take to find a solution

b) Time Complexity ii) How much memory need to perform the search.

c) Space Complexity iii) Is the strategy guaranteed to find the solution when there in one.

a)

a-iii, b-ii, c-i

b)

a-i, b-ii, c-iii

c)

a-iii, b-i, c-ii

d)

a-i, b-iii, c-ii

28.

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

29.

Almost all programming languages start arrays at ___

a)

index 0

b)

index 1

c)

index 2

d)

the null character

30.

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

a)

the peak

b)

the apex

c)

the crown

d)

the root

31.

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

32.

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

33.

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

a)

3

b)

1

c)

4

d)

2

34.

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

a)

31

b)

16

c)

32

d)

15

35.

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

36.

Which of the following is non-liner data structure?

a)

Stacks

b)

List

c)

Strings

d)

Trees

37.

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

38.

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

39.
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"
40.
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
41.
What would 'leaving' a queue be called?
a)
"Dequeue"
b)
"Enqueue"
c)
"Leave queue"
d)
"Delete 'system 32' folder"
42.
In this tree, where would the new value "7" be placed?
a)
On the left "leaf" of "4"
b)
On the right "leaf" of "6"
c)
On the left "leaf" of "15"
d)
Over the top of the current number "5"
43.
What would a dynamic data structure entail?
a)
Memory is allocated to the data structure as the program executes.
b)
Memory is allocated to the data structure at compile time.
c)
The size of the structure is fixed
d)
The data structure can also double as TNT
44.
Which of these sorting methods uses "divide and conquer"?
a)
Bubble Sort
b)
Quick Sort
c)
Cocktail Sort
d)
Selection Sort
45.
Which of these describes the operation of a bubble sort?
a)
The lowest valued un-ordered item will move quickest during a bubble sort
b)
The Highest valued un-ordered item will move quickest during a bubble sort 
c)
The list will be divided again and again, then re-build in to the correct order
d)
The list will be divided by a pivot, then ordered in smaller groups
46.
For a ordered list of 11 items, how many comparisons will a linear search need before it knows that a value in NOT in the list?
a)
12
b)
11
c)
6
d)
4
47.
For a ordered list of 11 items, how many comparisons will a Binary search need before it knows that a value in NOT in the list?
a)
12
b)
11
c)
6
d)
4
48.
For a linked list, what meta-data will need to be stored with each data entry?
a)
The Name of the list
b)
The address of the current data entry
c)
The address of the next data entry in the list
d)
The meaning of life
49.

Which of these tree traversal methods is used to output the contents of a binary tree in ascending order?

a)

Pre-Order

b)

In-Order

c)

Post-Order

d)

Monastic Orders

50.

In preorder traversal of a binary tree the second step is ____________

a)

traverse the right subtree

b)

traverse the left subtree

c)

traverse right subtree and visit the root

d)

visit the root

51.

What does the term immutable mean?

a)

unable to be changed

b)

unable to speak

c)

can be modified

d)

can be increased in size

52.

What is a tuple?

a)

A data value which can be modified.

b)

A data value which cannot be modified.

c)

An immutable data structure that contains related elements.

d)

A data structure that can only hold 3 elements.

53.

Which data structure cannot have elements of different data types?

a)

Array

b)

Tuple

c)

Record

d)

Stack

e)

Queue

54.

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

55.

There are two types of data structures, they are

a)

Static and dynamic

b)

Fast and slow

c)

Large and small

d)

Ascending and descending

56.

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

a)
b)
c)
57.

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

a)
b)
c)
58.

What is caused by attempting to push another item onto the top of a full stack?

a)

Underflow error

b)

Overload error

c)

Overflow error

d)

Catastrophic error

59.

Look at the diagram of the stack. What would the stack look like after the following operations were called:

peek()

pop()

push("yellow")

a)
b)
c)
d)
60.

If you have a stack containing 'A' 'D' 'G' . What will happen if you push 'C' into the stack?

a)

'C' Will be added on top of the stack

b)

'C' Will be added from the bottom of the stack

c)

'C' Will be removed from the stack

d)

'C' Will not be added to the stack

61.

A stack containing 'Dog' 'Cat' & 'Rat' . What will happen if you carry out a pop operation on the stack ?

a)

Noting

b)

Cat will be removed

c)

Dog will be removed

d)

Rat will be removed

62.

If you carry out a pop operation on this stack what will you be left with?

a)
b)
c)
63.

What will happen if you carry out a push operation with the word 'Bill'?

a)
b)
c)
64.

When an interrupt is dealt with, what operation takes place to the last added instruction.

a)

Pop

b)

Pull

c)

Multiplied

d)

Added

65.

What two operations do Queues require?

a)

Add

b)

Push

c)

Remove

d)

Pop

66.

Given a binary search tree, insert 27, 15, 63, 99, 70 and 85 (in this order) into the binary search tree. What is the post-order traversal?

a)

5,15,27,34,47,54,63,70,72,75,83,85,88,94,99,101

b)

72,54,34,5,27,15,47,63,70,83,75,88,85,101,94,99

c)

15,27,5,47,34,70,63,54,75,85,99,94,101,88,83,72

d)

15,27,5,47,34,63,54,70,75,85,99,94,101,88,83,72

e)

none of the above

67.

Consider two Deques with the same element type, A and B, and let B be empty.


To move everything from A to B and reverse order, which of these can be used in a loop? Select all that apply.

a)

B.offerFirst(A.pollFirst());

b)

B.offerFirst(A.pollLast());

c)

B.offerLast(A.pollFirst());

d)

B.offerLast(A.pollLast());

68.

Consider two Deques with the same element type, A and B, and let B be empty.


To move everything from A to B and preserve order, which of these can be used in a loop? Select all that apply.

a)

B.offerFirst(A.pollFirst());

b)

B.offerFirst(A.pollLast());

c)

B.offerLast(A.pollFirst());

d)

B.offerLast(A.pollLast());

69.

Deque<Integer> d = [1,2,3].

d.offerFirst(d.pollLast());


What is the value of d?

a)

[1,2,3]

b)

[2,3,1]

c)

[3,1,2]

d)

[3,2,1]

70.

What is the time complexity of this algorithm?

a)

O(n)

b)

O(2n)

c)

O(log n)

d)

O(n2)

e)

O(1)

71.

What is the time complexity of this algorithm?

a)

O(n)

b)

O(2n)

c)

O(log n)

d)

O(n2)

e)

O(1)

72.

What is the time complexity of this algorithm?

a)

O(n)

b)

O(2n)

c)

O(log n)

d)

O(n2)

e)

O(1)

73.

What is the time complexity of this algorithm?

a)

O(n)

b)

O(2n)

c)

O(log n)

d)

O(n2)

e)

O(1)

74.

What is the time complexity of this algorithm?

a)

O(n)

b)

O(2n)

c)

O(log n)

d)

O(n2)

e)

O(1)

75.

What is the Big-O Notation of "Divide & Conquer" Algorithms?

a)

O(n)

b)

O(2n)

c)

O(log n)

d)

O(n2)

e)

O(1)

76.

What is the Big-O Notation of a combination lock with 4 digits, each digit having 1 of 10 possible values?

a)

O(n)

b)

O(10n)

c)

O(log n)

d)

O(n2)

e)

O(1)

77.

What is the Big-O Notation of picking a sequence of 10 balls from a bag of 10 different coloured balls (the ball is not put back into the bag after being picked)?

a)

O(n)

b)

O(n!)

c)

O(log n)

d)

O(n2)

e)

O(1)

78.

What order of complexity does this graph represent?

a)

Exponential

b)

Polynomial

c)

Linear

d)

Logarithmic

79.

What order of complexity does this graph represent?

a)

Exponential

b)

Polynomial

c)

Linear

d)

Logarithmic

80.

What order of complexity does this graph represent?

a)

Exponential

b)

Polynomial

c)

Linear

d)

Logarithmic

81.

What order of complexity does this graph represent?

a)

Exponential

b)

Polynomial

c)

Linear

d)

Logarithmic

82.

Which of these problems are solved by algorithms?

a)

Routing

b)

Encryption

c)

Sorting

d)

Searching

e)

All of the other four.

83.

What order of complexity does this graph represent?

a)

Exponential

b)

Polynomial

c)

Linear

d)

Constant

84.

Which of these is an example of decomposition?

a)

Break a program into procedures and functions

b)

Break a complex problem into modules using top down design

c)

Use a pre-written library of procedures and functions to perform operations such as sorting and searching.

d)

Subdividing a problem into smaller tasks that different teams can work on independently.

e)

Ignore the colour of a player token in a snakes ladder game model.

85.

Which of these is an example of abstraction?

a)

The layers in a network protocol stack

b)

Break a complex problem into modules using top down design

c)

Use a pre-written library of procedures and functions to perform operations such as sorting and searching.

d)

Subdividing a problem into smaller tasks that different teams can work on independently.

e)

Ignore the colour of a player token in a snakes ladder game model.

86.

Which of these is true about abstraction?

a)

The relevant details depend on what is being modeled.

b)

The unimportant details are ignored

c)

The relevant details depend on your opinion.

d)

An 8 bit integer is an abstraction of a whole number.

e)

Logic gates are an abstraction of transistor logic circuits.

87.

Which of these are true about algorithms?

a)

The steps/instructions can be ambiguous

b)

The lowest level of the algorithm can be expressed any way as long as the instruction/step is clear and can be treated as a simple computational process.

c)

Algorithms rely heavily on syntax

d)

Algorithms are about expressing thinking steps not syntax

e)

Python like code cannot be used to write an algorithm

88.

Define the term computational thinking

a)

Using a computer

b)

Developing an algorithm to solve a problem

c)

Making a computer use artificial intelligence

d)

Google is computational thinking

e)

Solving a problem using a computer

89.

Define the term abstraction within computational thinking

a)

Adding numbers together

b)

Taking a real world problem and designing a computer program that exactly replicates every part of that problem in the computer

c)

Representing real world problems in a computer program, using symbols and removing unnecessary element

d)

Performing multiple calculations on a list of variables

90.

What is the correct Big O notation for an algorithm where the number of operations (steps) can be expressed as:
4, n, cubed, plus, 3, n, log, base, 2, n, plus, 273,

4n3 +3n log2n  + 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(log2n)O\left(\log_2n\right)  

d)

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

e)

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

91.

What is the goal of a hash table?

a)

To compare items in a data set

b)

To store all the data items

c)

To immediately find an item without comparing other items

d)

To implement a dictionary data structure

92.

What is a hashing function used for?

a)

To calculate the position of an item in a hash table

b)

To determine the size of a hash table

c)

To compare items in a data set

d)

To implement a dictionary data structure

93.

What is chaining in a hash table?

a)

Storing items in a linked list

b)

Using a two-dimensional hash table

c)

Searching sequentially in an overflow table

d)

Finding an alternative position for items in the hash table

94.

What is the typical use of a hash table?

a)

Linking a file name to the file path

b)

Sorting a large dataset

c)

Performing calculations on a data set

d)

Creating a dictionary data structure

95.

What are the three basic operations that can be performed on a hash table?

a)

Adding a value, deleting a value, retrieving a value

b)

Sorting a value, searching a value, updating a value

c)

Copying a value, moving a value, renaming a value

d)

Creating a value, reading a value, updating a value

96.

What is the advantage of using a larger hash table?

a)

It reduces the chance of collisions

b)

It speeds up the hashing function

c)

It allows for more efficient linear probing

d)

It minimizes the memory footprint

97.

What is the purpose of a two-dimensional hash table?

a)

To store multiple items at the same position

b)

To prevent collisions in a hash table

c)

To speed up the hashing function

d)

To reduce the memory footprint

98.

What is the purpose of a linked list in a hash table?

a)

To store items that cannot be placed in the hash table

b)

To prevent collisions in a hash table

c)

To speed up the hashing function

d)

To reduce the memory footprint

99.

What is the purpose of an overflow table in a hash table?

a)

To store items that cannot be placed in the hash table

b)

To prevent collisions in a hash table

c)

To speed up the hashing function

d)

To reduce the memory footprint

100.

address = key MOD(numberOfSlots)


If key = 5432 and numberOfSlots = 1000

address = ?

a)

5

b)

432

c)

543

d)

5432

101.

What is the status after adding 10

a)
b)
c)
d)
102.

Which mathematical function do all hashing algorithms use?

a)

MOD

b)

DIV

c)

EXP

d)

COS

e)

RAND

103.

The goal of hashing is to produce a search that takes

a)

O(1) time

b)

O(n2 )time

c)

O(log n ) time

d)

O(n log n ) time

104.

Divide the item into equal-size pieces

Add the pieces together

Perform the mod step to get an address

Which hashing method does this describe

a)

folding method

b)

alphanumeric

c)

mid-square

d)

mod

105.

What is the worst-case runtime of lookUp/get in a binary search tree?

a)

O(n)

b)

O(logn)

c)

O(1)

d)

O(n2)

106.
When deleting from a binary search tree, if the node being deleted has 2 children, we replace the entry with ____.
a)
the inorder successor
b)
null
c)
the left child
d)
the right child
e)
the parent
107.

An array with 16 elements is input to a binary search algorithm. How many maximum number of comparisons are performed?​

a)

1

b)

2

c)

3

d)

4

e)

5

108.

If I deleted the root from the Binary Search Tree what could I replace it with?

a)

7

b)

14

c)

3

d)

1

109.
One difference between Dijkstra's shortest path and the A* algorithm is that:
a)
A* uses a heuristic
b)
Dijkstra's shortest path uses a heuristic
c)
A* finds a path between the start node and all others
d)
Dijkstra's shortest path uses divide and conquer
110.
Comparing a merge sort to a quicksort, which is the better algorithm in terms of time complexity on average?
a)
They are both similar
b)
Quicksort
c)
Merge sort
d)
It is not possible to determine
111.
How can a search on a binary tree result in linear time complexity O(n) when it makes use of divide and conquer?
a)
The binary tree is unbalanced with all items stored on a left or right pointer
b)
The binary tree is balanced with an equal height for all leaf nodes
c)
The binary tree is a graph with some nodes having more than two children
d)
The binary tree only has one item, a single root node