wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

A2 CS P2 - Knowledge check mmd

Total questions: 120

Worksheet time: 2hrs 55mins

Name
Class
Date
1.

Procedural programming lays stress on?

a)

Data

b)

Functions

c)

Object

d)

Class

2.

________ is wrapping of data into a single unit called class.

a)

Abstraction

b)

Polymorphism

c)

Encapsulation

d)

Inheritance

3.

__________ refers to the act of representing essential details.

a)

Polymorphism

b)

Abstraction

c)

Inheritance

d)

Encapsulation

4.

__________ is the process in which objects of one class can link and share some common properties from the objects of another class.

a)

Abstraction

b)

Inheritance

c)

Polymorphism

d)

Encapsulation

5.

__________ is the process of using a function for more than one purpose. It allows the use of different internal structures of the object by keeping the same external interface.

a)

Inheritance

b)

Polymorphism

c)

Abstraction

d)

Encapsulation

6.

An _________ is an instance or of a copy of a class.

a)

Class

b)

Object

c)

Attribute

7.

A ________ is blue print that defines certain characteristics and behavior. It is simply a representation of different types of objects.

a)

Class

b)

Object

c)

Attribute

d)

Characteristics

8.

Select all the given characteristic of OOP

a)

Data structures are designed such that they characterize the objects.

b)

C input/output is based on library and the processes are carried out by including functions.

c)

Programs are divided into what are known as objects.

d)

Emphasis is on data rather than procedure

9.

(from Greek meaning “many forms”) is the quality that allows one interface to access a general class of actions.

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Object-Oriented Programming

10.

Is the process by which one object can acquire the properties of another object.

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Object-Oriented Programming

11.

A programming mechanism that binds together code and the data it manipulates, and that keeps both safe from outside interference and misuse.

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Object-Oriented Programming

12.
Which of the following is the best definition of a recursive method?
a)
A method that iterates itself exactly 5 times.
b)
A method that invokes itself by name within the method.
c)
A method that will never iterate infinitely.
d)
A method that cannot be called more than once.
13.

What is the returned value of recMethod(5)?

a)

68

b)

70

c)

75

d)

82

14.

What is printed as a result of the call stringMaker("COMPSCI")?

a)

COMPSCI

COMPSC

COMPS

COMP

COM

CO

C

b)

COMPSCI

OMPSCI

MPSCI

PSCI

SCI

CI

I

c)

CO

COM

COMP

COMPS

COMPSC

COMPSCI

d)

C

CO

COM

COMP

COMPS

COMPSC

COMPSCI

15.

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

a)

2

b)

3

c)

4

d)

1

16.
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.
17.
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
18.
What is an algorithm?
a)
A sequence of instructions on how to solve a problem.
b)
The breaking down of a problem into smaller parts.
c)
Focusing on important parts and ignoring the irrelevant details
d)
The recipe for a cake
19.
What are the two main ways that we represent an algorithm?
a)
By drawing pictures 
b)
Using flowcharts and pseudo code
c)
Using python and small basic
d)
Using Scratch and python
20.
What is a flowchart?
a)
A visual representation of an algorithm using symbols
b)
Using 'fake code' to plan an algorithm
c)
Using a programming language to show an algorithm
d)
Uisng different types of charts to show an algorithm
21.

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

22.

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

23.

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

24.

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

25.

Indicate constant time complexity in terms of Big-O notation

a)

O(n)

b)

O(1)

c)

O(log n)

d)

O (n^2)

26.

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)

27.

Find the slowest time complexity

a)

O (n)

b)

O (n^2)

c)

O (n!)

d)

O (2^n)

28.

Which notation is consistent for every execution?

a)

O (n)

b)

O (n^2)

c)

O (1)

d)

O (2^n)

29.

The O (n!) is so inefficient, there is no practical use for it

a)

True

b)

False

30.

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)

31.

Which notation would you usually use for a nested loop?

a)

O (n)

b)

O (n^2)

c)

O (1)

d)

O (2^n)

32.

Indicate polynomial time complexity in terms of big-O notation

a)

O (n!)

b)

O (1)

c)

O (n^2)

d)

O (log n)

33.

When calculating the Big-O for an algorithm, which of the following rules is not true?

a)

Focus on the dominant term

b)

Disregard any constants

c)

Focus only on polynomials

d)

Count the number of assignments

34.

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

35.

A quadratic function takes the form

a)

f(n) = an + b

b)

f(n) = an2 +bn + c

c)

f(n) = alog2n

d)

f(n) = a + b

36.

A logarithmic function takes the form

a)

f(n) = an + b

b)

f(n) = an2 +bn + c

c)

f(n) = alog2n

d)

f(n) = a + b

37.
a)

1 + 3n + n

b)

3 + n

c)

3n

d)

1 + 3n

38.

Which line best represents the time complexity n!

a)

Orange

b)

Blue

c)

Green

d)

Red

e)

Pink

39.

Which line best represents the time complexity log n

a)

Orange

b)

Blue

c)

Green

d)

Red

e)

Pink

40.

Which line best represents the time complexity n

a)

Orange

b)

Blue

c)

Green

d)

Red

e)

Pink

41.

Which of the following usees FIFO method

a)

Queue

b)

stack

c)

linklist

d)

binary tree

42.

This form of access is used to add and remove nodes from a queue.

a)

LIFO, Last In First Out

b)

FIFO, First In First Out

c)

Both a and b

d)

none

43.
........ form of access is used to add remove nodes from a stack.
a)
LIFO
b)
Fifo
c)
none
d)
all
44.

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 number of elements present on stack are

a)

1

b)

2

c)

3

d)

4

45.

The following circular queue can accommodate a 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)

ront = 3 rear = 5

queue = L, M, N, O, ___

c)

front = 3 rear = 4

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

d)

ront = 2 rear = 4

queue = L, M, N, O, ___

46.

What method is used to add an element to a Queue?

a)

dequeue()

b)

enqueue()

c)

push()

d)

pop()

47.

What method is used to add an element to a Stack?

a)

dequeue()

b)

enqueue()

c)

push()

d)

pop()

48.

What method is used to remove an element from a Queue?

a)

dequeue()

b)

enqueue()

c)

push()

d)

pop()

49.

What method is used to view the next element to be removed from a stack?

a)

dequeue()

b)

NextItem()

c)

peek()

d)

pop()

50.

Which method is called in a PUSH() method

a)

IsEmpty()

b)

IsFull()

51.

Which method is called in a POP() method

a)

IsEmpty()

b)

IsFull()

52.

If I want to find out if an item is in a queue or a stack - what do I call?

a)

Contains(item)

b)

IsContains(item)

c)

Peek(item)

d)

Find(item)

53.

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

a)

running time of enqueue is improved

b)

reuse empty space

c)

you can traverse the elements more efficiently

d)

none of the above

54.

Circular queue is also known as

a)

circular buffer

b)

ring buffer

c)

curve buffer

d)

rotating buffer

55.

One difference between stack and queue?

a)

queues require dynamic memory,but stack do not

b)

stacks use two ends of the structure,queue use only one

c)

stacks requires dynamic memory ,but queues do not

d)

queues uses two ends of the structure,stack use only one

56.

If the element "A B C D" are placed in a stack and are deleted one at a time

in what order will they be removed?

a)

ABCD

b)

DBCA

c)

DCBA

d)

DABC

57.

If FRONT= REAR then the queue is?

a)

overflow

b)

underflow

c)

empty

d)

null

58.

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

59.

Consider Stack is implemented using the array.

#define MAX 10

struct STACK

{

int arr[MAX]

int top = ___________;

}

What will be the initial value with which top is initialized.

a)

0

b)

-1

c)

garbage

d)

1

60.

A data structure in which elements can be inserted or deleted at/from

both the ends but not in the middle is?

a)

queue

b)

circular queue

c)

dequeue

d)

priority queue

61.

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

a)

REAR is NULL

b)

FRONT is 1

c)

REAR is 1

d)

FRONT is NULL

62.

Which algorithm requires a pivot

a)

Flow chart

b)

Bubble sort

c)

Quick sort

d)

Bin packing

63.

Where every vertex is directly connected to all other vertices by a single edge is a....

a)

simple graph

b)

tree

c)

spanning tree

d)

complete graph

64.

Dijkstra's algorithm finds...

a)

Minimum spanning tree

b)

Minimum distance between two vertices

c)

Hamiltonian cycle

d)

Route through all the vertices

65.

When using Dijkstra's algorithm you must show all working values

a)

True - show all values

b)

True - unless they are higher

c)

False - only the final value is required

66.
Which of these is NOT a Sort algorithm
a)
Binary
b)
Merge
c)
Bubble
d)
Insertion
67.
Which one of the following is an advantage of a linear search?
a)
It takes a long time to find the item.
b)
It is a simple algorithm to write.
c)
It is more efficient than a binary search.
d)
It is a complex algorithm to write.
68.
Which of the following descriptions best describes a linear 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.
69.
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.
70.
A linear search is to be performed on the list:
12, 6, 8, 1, 3
How many searches would it take to find the number 1?
a)
1
b)
2
c)
3
d)
4
71.
What is a trace table?
a)
A technique used to test algorithms for logical errors.
b)
A technique used for drawing in art.
c)
A type of sort algorithm
d)
A type of search algorithm
72.

Which of these sorting algorithms is the most efficient?

a)

Merge sort

b)

Bubble sort

c)

Insertion sort

d)

Selection sort

73.

Which of these sorting algorithms uses recursion?

a)

Merge sort

b)

Bubble sort

c)

Insertion sort

d)

Selection sort

74.

For which algorithm would it be best to use a conditional loop?

a)

Finding largest number in a list

b)

Calculating average of a list of numbers

c)

Counting occurrences of an item in a list

d)

Checking if an item is in a list

75.

For which algorithm would it be best to use an unconditional loop?

a)

Validating username and password

b)

Adding up numbers in a list

c)

Finding first occurrence of a number in a list

d)

Validating user input for date of birth

76.

What would the list [9, 6, 12, 7, 3, 16, 10] look like after one iteration of the Bubble sort algorithm (smallest to biggest)?

a)

[6, 9, 7, 3, 12, 10, 16]

b)

[3, 9, 6, 12, 7, 16, 10]

c)

[3, 6, 7, 9, 10, 12, 16]

d)

[9, 6, 12, 3, 7, 16, 10]

77.

Which of these algorithms is an example of a divide-and-conquer type algorithm?

a)

Bubble sort

b)

Binary search

c)

Linear search

d)

Count occurrences

78.

What is the standard Scientific measurement for measuring algorithm efficiency?

a)

Big-O notation

b)

Scientific notation

c)

Floating-point

d)

Mbps

79.

This is the main loop from an algorithm (shown in pseudocode.) Which algorithm is it?

a)

Insertion sort

b)

Bubble sort

c)

Merge sort

d)

Binary search

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

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

a)

35

b)

24

c)

42

d)

20

83.

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

84.

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

85.

How many leaf are there in the tree?

a)

1

b)

3

c)

4

d)

7

86.
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"
87.

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

88.

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

89.

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

a)
b)
c)
90.

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

a)
b)
c)
91.

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.

92.

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

93.

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

94.

Hashing gives each item

a)

A sequential address

b)

A logarithmic address

c)

No address

d)

A unique address

95.

A hash table is

a)

an abstract data structure

b)

an array

c)

an integer

d)

made of pine

96.

Address <----- key MOD(numberOfSlots)

IF KEY = 5432 and numberOfSlots = 1000

Address = ?

a)

5

b)

432

c)

543

d)

5432

97.

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

a)

Knock

b)

Bang

c)

Collisions

d)

DoubleHash

98.

What is the status after adding 10

a)
b)
c)
d)
99.

What is the status after adding 7

a)
b)
c)
d)
100.

Which data structure cannot have elements of different data types?

a)

Array

b)

Tuple

c)

Record

d)

Stack

e)

Queue

101.

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

102.

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

a)

creating a new list at that index

b)

creating a new array

c)

creating a new hash table

d)

creating a new binary tree

103.

Which word describes lot of collisions with using hashing?

a)

contiguous

b)

traffic

c)

clustering

d)

mutable

104.

Linear Probing in relation to Hash Tables...

a)

is checking the length of a Hash Table

b)

is a process of going through each Index one by one looking for a desired value

c)

Assigning the next empty key value to resolve a collision

d)

a personal part of someones medical history

105.

Which of the following is/are the advantages of Linked list?

a)

Insertion and deletion of elements can be done efficiently

b)

It uses dynamic memory allocation

c)

Memory utilization is efficient compared to arrays

106.

Which of the following is/are not the dis-advantage of Linked list?

a)

Linked list does not support random access

b)

Memory is required to store next field

c)

Searching takes time compared to arrays

d)

None of the above

107.

Give syntax to create a node for Single linked list?

a)

newnode=(struct node *)malloc(sizeof(struct node*));

b)

newnode=(struct node )malloc(sizeof(struct node));

c)

newnode=(struct node *)malloc(sizeof(struct node));

d)

newnode=(struct node )malloc(sizeof(struct node*));

108.

Give routine to insert at the beginning in a linked list whose structure is by struct node, with list head as L and pointer variable as next

a)

newnode->next=next;

L=newnode;

b)

newnode->next=node;

L=newnode;

c)

newnode->next=L;

L=newnode;

d)

newnode->L=next;

L=newnode;

109.

How to insert a node after a position P in singly linked list?

a)

Newnode -> data = P ;

Newnode -> next = p ->next ;

P -> next = newnode ;

b)

Newnode -> data = x ;

Newnode -> next = p ->next ;

P -> next = L ;

c)

Newnode -> data = x ;

Newnode -> next = p ->node ;

P -> nextnode = next ;

d)

Newnode -> data = x ;

Newnode -> next = p ->next ;

P -> next = newnode ;

110.

Which of the following is application of Singly Linked List?

a)

moving pages forward and backward in browser

b)

Giving chance to each player in a multi player game

c)

Implementing Stack

111.

Which of the following is application of Doubly Linked List?

a)

moving pages forward and backward in browser

b)

Giving chance to each player in a multi player game

c)

Implementing Stack

112.

Which of the following is application of Cicularly Linked List?

a)

moving pages forward and backward in browser

b)

Giving chance to each player in a multi player game

c)

Implementing Stack

113.

The main advantage of using a _______ linked list is that it makes searching twice as efficient.

a)

a)Singly

b)

b)doubly

c)

c)circular

d)

d)None

114.

Choose the correct statement in the below comparison of an array and a linked list?


a)

a.The size of an array is similar to size of linked list is variable.

b)

b.In array, the data elements are stored in continuous memory locations but in linked list, it is non continuous memory locations.

c)

c. Addition, removal of data is tedious in linked list whereas in arrays it is easy.

d)

d. None

115.

What is the worst case time complexity of linear search algorithm?

a)

A - Ο(1)

b)

B - Ο(n)

c)

C - Ο(log n)

d)

D - Ο(n2)

116.

What data structure is used for breadth first traversal of a graph?

a)

A - queue

b)

B - stack

c)

C - list

d)

D - none of the above

117.

If the array is already sorted, which of these algorithms will exhibit the best performance

a)

A - Merge Sort

b)

B - Insertion Sort

c)

C - Quick Sort

d)

D - Heap Sort

118.

What about recursion is true in comparison with iteration?

a)

A - very expensive in terms of memory.

b)

B - low performance.

c)

C - every recursive program can be written with iteration too.

d)

D - all of the above are true!

119.

Quick sort running time depends on the selection of

a)

A - size of array

b)

B - pivot element

c)

C - sequence of values

d)

D - none of the above!

120.

A pivot element to partition unsorted list is used in

a)

A - Merge Sort

b)

B - Quick Sort

c)

C - Insertion Sort

d)

D - Selection Sort