wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

A2 CS Paper 2 MAR 21- mmd

Total questions: 139

Worksheet time: 2hrs 32mins

Name
Class
Date
1.

A procedure that calls itself is called

a)

illegal call

b)

reverse polish

c)

recursive

d)

none of the above

2.

Queue data structure works on

a)

LIFO

b)

FIFO

c)

FILO

d)

none of the above

3.

The following formular is of

left_subtree (keys) ≤ node (key) ≤ right_subtree (keys)

a)

Binary Tree

b)

Complete Binary Tree

c)

Binary Search Tree

d)

All of the above

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

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

a)

35

b)

24

c)

42

d)

20

7.

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./

8.

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./

9.

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

10.

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

11.

The decision tree structure begins at a node called the _____.

a)

span

b)

top

c)

root

d)

branch

12.

How many leaf are there in the tree?

a)

1

b)

3

c)

4

d)

7

13.
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"
14.

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

15.

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

16.

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

a)
b)
c)
17.

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

a)
b)
c)
18.

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.

19.

Given a sequence of number below:

50,60,40,70,45,55,30,80,65,35,25,75,85


When creating a binary search tree, what is the height of the tree?

a)

3

b)

4

c)

5

d)

6

20.

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

21.
A Balanced Tree has equal number of items on each subtree.
a)
True
b)
False
22.
Root has more left descendants than the right descendants or vice versa.
a)
Balanced Tree
b)
Perfect Tree
c)
Right Tree
d)
Unbalanced Tree
23.

Choose the correct statement

a)

A data structure is a specialised format for organising and storing data

b)

A data structure is a specialised format for organising and storing information

c)

A data structure is a format for organising and storing only one data type

d)

A data structure is too complicated to truly understand or use

24.

What is the degree of vertex 4?

a)

3

b)

4

c)

5

d)

7

25.

Which two vertices are adjacent vertices?

a)

5 is adjacent to 6

b)

3 is adjacent to 6

c)

4 is adjacent to 1

d)

3 is adjacent to 2

26.

The graph represents the following vocabulary term.

a)

Cycle

b)

Path

c)

Complete Graph

d)

Complete Bipartite Graph

27.

What is the weight of the shortest path from A to F?

a)

5

b)

7

c)

9

d)

11

28.

Which vertices are adjacent to E?

a)

B and C

b)

B, C, D, and A

c)

B

d)

A, B, C, D, F, G

29.

Which is an example of a disconnected graph?

a)
b)
c)
d)
e)

None are disconnected graphs

30.

Which of the following is not a style of graph traversal in computing?

a)

Breadth-First

b)

Depth-First

c)

Height-First

31.

Which method of graph traversal makes use of a stack?

a)

Depth-First

b)

Breadth-First

32.

Which method of graph traversal makes use of a queue?

a)

Depth-First

b)

Breadth-First

33.

Which order of traversal is correct using depth-first?

a)

A B C G D E F

b)

A B D C E C G

34.

Which of the following beginnings to a graph traversal would not be correct for depth-first?

a)

A B C G

b)

A D F

c)

A E D F

d)

A B D C

35.

Which order of traversal is correct using breadth-first?

a)

A B D E C F G

b)

A B C G D E F

36.

A has been visited what happens next

a)

Visit B

b)

Visit D

c)

Visit E

d)

Visit C

37.

With breadth-first traversal, which node will be visited next?

a)

C

b)

F

c)

G

38.

With breadth-first traversal, which node will be visited next?

a)

C

b)

F

c)

G

39.

A _________ is a simple path is which the first and last vertices are same

a)

Cycle

b)

Circular

40.

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

41.

In linked list implementation of a queue, where does a new element be inserted?

a)

At the head of link list

b)

At the centre position in the link list

c)

At the tail of the link list

d)

None of the mentioned

42.

In linked list implementation of a queue, from where is the item deleted?

a)

At the head of link list

b)

At the centre position in the link list

c)

At the tail of the link list

d)

None of the mentioned

43.

In linked list implementation of a queue, the important condition for a queue to be empty is?

a)

FRONT is null

b)

REAR is null

c)

LINK is empty

d)

None of the mentioned

44.

In a circular queue, how do you increment the rear end of the queue?

a)

rear++

b)

(rear+1) % Number of Item

c)

(rear % Number of Item)+1

d)

rear–

45.

What is the term for inserting into a full queue known as?

a)

overflow

b)

underflow

c)

null pointer exception

d)

all of the mentioned

46.

Let the following circular queue can accommodate maximum six elements with the following data


front = 2 rear = 4

queue = _______; L, M, N, ___, ___


What will happen after ADD O operation takes place?

a)

front = 2 rear = 5

queue = ______; L, M, N, O, ___

b)

front = 3 rear = 5

queue = L, M, N, O, ___

c)

front = 3 rear = 4

queue = ______; L, M, N, O, ___

d)

front = 2 rear = 4

queue = L, M, N, O, ___

47.

A circular queue is implemented using an array of size 10. The array index starts with 0, front is 6, and rear is 9. The insertion of next element takes place at the array index.

a)

0

b)

7

c)

9

d)

10

48.

What is the reason for using a "circular queue" instead of a regular one?

a)

running time of enqueue() is improved

b)

reuse empty spaces

c)

you can traverse all the elements more efficiently

d)

none of the above

49.

In Queue Insertion & Deletion take place at ________________.

a)

same end

b)

first end

c)

different end

d)

last end

50.

One difference between a queue and a stack is:

a)

Queues require dynamic memory, but stacks do not

b)

Stacks require dynamic memory, but queues do not.

c)

Queues use two ends of the structure; stacks use only one.

d)

Stacks use two ends of the structure, queues use only one.

51.

If the numbers 5, 10, 3, 42 are enqueued onto a queue in that order, what does dequeue return?

a)

5

b)

10

c)

3

d)

42

52.

Queue can be implemented using a list?

a)

True

b)

False

53.

What is the term for inserting into a full queue known as?

a)

underflow

b)

overflow

c)

front

d)

rear

54.

The essential condition which is checked before insertion in a linked queue is?

a)

Underflow

b)

Overflow

c)

Front value

d)

Rear value

55.

A queue of characters currently contained a,b,c,d. What would be the contents of queue after the following operationDELETE, ADD W, ADD X, DELETE, ADD Y.

a)

A,B,C,W,Y

b)

A,B,C,D,W

c)

C,D,W,X,Y

d)

W,Y,X,C,D

56.

If front=rear ,then the queue is?

a)

full

b)

undeflow

c)

overflow

d)

empty

57.

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.

58.

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

59.

The situation when in a linked list Head==NULL

is

a)

Full

b)

Empty

c)

Half full

d)

saturated

60.

In the above image what will be printed when Head->next->data?

a)

83

b)

9

c)

27

d)

Error

61.

What is the operation of the below statements?

a)

Insert a new node to the front of a linked list

b)

Create a new node for a linked list

c)

Insert a new node to the end of the linked list

d)

Calculate the size of a linked list

62.
Which of the following best describes a binary search:
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.
63.
A binary search is to be performed on the list:
3, 5, 9, 10, 23
How many comparisons would it take to find the number 9?
a)
0-1
b)
2-3
c)
4-5
d)
It can't be found
64.
Which of the following is a search algorithm?
a)
A word search
b)
A binary search
c)
A number search
d)
A search engine
65.
Which of the following is a sort algorithm?
a)
A linear sort
b)
A bubble sort
c)
A ordered sort
d)
A binary sort
66.
Which of the following describes a merge sort?
a)
Compares each pair and swaps
b)
List is split in two and merged together in order
c)
List is split into 2 and kept seperate
d)
None of the above
67.

A recursive function is

a)

A function that calls other functions in a recursive way.

b)

Any function that calls itself is called recursive

c)

A function that has a base case or termination condition

d)

None of the above

68.

Recursion is:

a)

is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls itself in a step having a termination condition.

b)

is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls other function in a step.

c)

is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls itself in a step having no termination condition.

d)

None of the above

69.

The program may run out of memory in a

a)

non-recursive function call

b)

recursive function call

c)

condition when too many variables are declared

d)

none of the above

70.

Which of the following condition is true?

a)

Recursion is always better than iteration.

b)

Recursion uses more memory as compared to iteration.

c)

Recursion uses less memory as compared to iteration.

d)

Iteration is always better and simpler than recursion.

71.

Which of the following problems can be solved using recursion?

a)

finding Nth number of the Fibonacci sequence

b)

finding the factorial of a number

c)

finding the length of a string

d)

all of the above

72.

Recursion is similar to which of the following?

a)

if-else

b)

switch-case

c)

loops

d)

none of the above

73.

What would happen if the base case if not defined in the recursive method?

a)

Stack Overflow

b)

Stack Underflow

c)

Program Crashes

d)

None of the above

74.

The number of recursive calls is limited to the ____ of the stack.

a)

time

b)

ability

c)

quality

d)

size

75.

Which of the following sorting algorithms use recursion?

a)

Selection Sort

b)

Insertion Sort

c)

Mergesort

76.

What is the returned value of recmethod(5)?

a)

68

b)

70

c)

75

d)

82

77.

What is returned as a result of the call mystery(4,6)?

a)

2

b)

3

c)

4

d)

1

78.
What is the Big-O notation of a linear search algorithm?
a)
O(n)
b)
O(log(n))
c)
O(n2)
79.
What is the Big-O notation of a binary search algorithm?
a)
O(log(n))
b)
O(n)
c)
O(n2)
80.
What is the Big-O notation of a bubble sort algorithm?
a)
O(n2)
b)
O(log(n))
c)
O(n)
81.
What does the big-O notation show?
a)
The effectiveness of an algorithm
b)
The amount of time required to solve a particular problem
c)
How difficult a problem is to solve
d)
How many lines of code are required to solve a problem
e)
How quickly a solution can be developed
82.
What two pieces of information allow you to analyse an algorithm?
a)
Time Complexity
b)
Space Complexity
c)
Size Complexity
d)
Complex Complexity
e)
Simplicity Complex
83.

What order of complexity does this graph represent?

a)

Exponential

b)

Polynomial

c)

Linear

d)

Logarithmic

84.
_________________ is a collection of elements used to store the same type of data.
a)
Array
b)
Switch
c)
Case
d)
Loop
85.
What is returned by values[5]?
a)
9
b)
12
c)
6
d)
8
86.
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)
87.
Which of these data structures is FIFO
a)
Stack
b)
Queue
c)
Binary Tree
d)
Double linked list
88.
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
89.

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)

0

b)

1

c)

2

d)

3

90.

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)

0

b)

1

c)

2

d)

3

91.

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

92.

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

93.

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 if a deQueue operation is performed.

a)

Bert

b)

Cynthia

c)

Cedric

d)

Albert

94.

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 if a deQueue operation is performed.

a)

Bert

b)

Cynthia

c)

Cedric

d)

Albert

95.

Which is NOT an elementary data type?

a)

String

b)

Char

c)

Boolean

d)

Int

e)

Float

96.

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

97.

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.

98.

Which data structure cannot have elements of different data types?

a)

Array

b)

Tuple

c)

Record

d)

Stack

e)

Queue

99.

In terms of data structures, what does mutable mean?

a)

A mutable structure is one which can only have data added to it

b)

A mutable structure is one which is fixed in size

c)

A mutable structure is one which allows data to be added, edited, deleted or moved

100.

Which of the following is not a valid array?

a)

names=("Tom","Ali","22","Connie")

b)

scores=(2,3,5,4,2,1)

c)

names=("Tom", "Ali", 22, "Connie")

101.

Which is NOT an operation performed on a queue?

a)

Add

b)

Remove

c)

isFull

d)

isEmpty

e)

push

102.

Which is NOT a type of queue?

a)

Priority

b)

Linear

c)

Circular

d)

Semaphore

103.

In a dynamic data structure where is the memory allocated from to hold the data structure?

a)

Heap

b)

Cache

c)

Secondary Storage

d)

ROM

e)

Virtual Memory

104.

What is an advantage of a circular queue?

a)

Free space can be reused

b)

Easy to program

c)

Gives preference to important items

d)

It is static

105.

A data structure which consists of a collection of elements, typically in fixed number and sequence and typically indexed by names.

a)

Array

b)

Record

c)

Queue

d)

List

e)

Stack

106.

Which of these data structures is LIFO?

a)

Stack

b)

Queue

c)

Binary Tree

d)

Double linked list

107.

In a Hash Table what happens if the hashing algorithm generates the same address for different primary keys?

a)

this situation is impossible

b)

collisions

c)

errors

d)

the hashing algorithm is run again

108.

In a Hash Table, what ideally should the size of the table be?

a)

same size as the amount of data to hold

b)

an odd number

c)

an even number

d)

a prime number

109.

Which mathematical function do all hashing algorithms use?

a)

MOD

b)

DIV

c)

EXP

d)

COS

e)

RAND

110.
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
111.

Which of these data structures is LIFO?

a)

Stack

b)

Queue

c)

Binary Tree

d)

Double linked list

112.

What is the name of the function to add an item to a stack?

a)

push()

b)

pop()

c)

peek()

d)

isFull()

e)

isEmpty()

113.

What is the name of the function to remove an item from a stack?

a)

push()

b)

pop()

c)

peek()

d)

isFull()

e)

isEmpty()

114.
State the advantages of procedural programming
a)
Can be applied to a wide range of problems.
b)
Relatively easy to write and interpret.
c)
Reuse of code through inheritance
d)
Flexibility through polymorphism
115.
Identify the main programming structures used in structured programming
a)
Sequence
b)
Selection
c)
Iteration
d)
Recursion
e)
Encapsulation
116.
What is a class?
a)
A template for an object that defines the state and behaviour of an object. An object is an instance of a class.
b)
a variable, a data structure, a function, or a method, and as such, is a value in memory referenced by an identifier.
c)
a procedure associated with a message and an object
d)
a class is a specification that defines a property of an object, element, or file.
117.
Identify disadvantages of Object Oriented Languages
a)
Requires a different style of thinking which can be difficult for programmers accustomed to other paradigms to pick up.
b)
OOP may not be suited to all types of problems.
c)
Generally unsuitable for smaller problems
d)
inability to reuse code
118.

An item of data which is passed to a procedure or function.

a)

Local variable

b)

Parameter

c)

Global variable

d)

Selection

119.

What does inheritance mean in python?

a)

The transfer of the characteristics of a class to other classes that are derived from it.

b)

A variable that is defined inside a method and belongs only to the current instance of a class

c)

The creation of an instance of a class.

d)

It is what you sometimes get when a relative passes away

120.

What is an instance in python?

a)

A special kind of function that is defined in a class definition.

b)

The creation of an instance of a class.

c)

An individual object of a certain class. An object obj that belongs to a class Circle, for example, is an instance of the class Circle.

d)

A moment in time

121.

What is instantiation in python?

a)

The creation of an instance of a class.

b)

The transfer of the characteristics of a class to other classes that are derived from it.

c)

A variable that is defined inside a method and belongs only to the current instance of a class.

d)

A unique instance of a data structure that's defined by its class. An object comprises both data members (class variables and instance variables) and methods.

122.

What is a method in python?

a)

a way of doing something

b)

a special kind of function that is defined in a class definition

c)

the creation of an instance of a class

d)

orderliness of thought or behavior; systematic planning or action

123.

What is an object in python?

a)

A unique instance of a data structure that's defined by its class. An object comprises both data members (class variables and instance variables) and methods.

b)

A special kind of function that is defined in a class definition.

c)

The assignment of more than one function to a particular operator.

d)

An individual object of a certain class. An object obj that belongs to a class Circle, for example, is an instance of the class Circle.

124.
Which of the following concepts of OOPS means exposing only necessary information to client?
a)
Encapsulation
b)
Abstraction
c)
Data hiding
d)
Data binding
125.
How many objects can be made from a class? 
a)
None, you make classes from objects
b)
one
c)
As many as you want
d)
All of the above
126.
What is the difference between a class and an object?
a)
A class is a blueprint to make an object
b)
An object is a blueprint to make a class
c)
A blueprint is an object to make a class
d)
Blueprint class is an object make a
127.
These have identitystate, and behavior.
a)
class
b)
object
c)
method
d)
void
128.
The process by which objects of one class acquire the properties of objects of another class is known as
a)
Polymorphism
b)
Inheritance
c)
Data Hiding
d)
None of the above.
129.
The wrapping up of data and functions into a single unit is called
a)
overloading
b)
class
c)
object
d)
encapsulation 
130.
What does decomposition mean?
a)
focuses on the important information only, ignoring irrelevant detail
b)
Step by step instructions on solving a problem.
c)
Thinking like a computer
d)
This is the breaking down of a complex problem into smaller parts
131.
What is abstraction?
a)
A painting
b)
A programming language
c)
This means focusing on the important details and ignoring the irrelevant information
d)
Abstraction is the breaking down of a big problem into smaller parts.
132.

Which of the following is not done by decomposition?

a)

Allows multiple people to work on the problem together

b)

Disregards non-essential information

c)

Breaks the problem down into smaller tasks

133.

Which of the following is not done by abstraction?

a)

Identifies essential details

b)

Disregards non-essential information

c)

Breaks the problem down into smaller tasks

134.

When drawing a dog, which of the following characteristics is non-essential?

a)

Dogs have 4 paws

b)

Dogs have fur

c)

Dogs have brown fur

135.

When designing a building that must be accessible for wheelchairs, which of the following characteristics is non-essential?

a)

Number of doors

b)

Number of walls

c)

Number of wall paintings

136.

Decomposition allows the entire task to be completed as _____

a)

A Team

b)

A Whole

c)

Quickly as possible

137.

A school database has lots of information on students, the data manager needs to use abstraction. What data should she leave out?

a)

Age

b)

Guardian's phone numbers

c)

Classes

d)

Eye colour

138.
How many times will Boo print?
a)
none
b)
4
c)
5
d)
1
139.

What is a parameter in a function?

a)

input value to a function for the function’s execution

b)

a variable used to send information to a function

c)

the name of the function

d)

the name of the main program calling the function