Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Review Quiz

Total questions: 24

Worksheet time: 12mins

Name
Class
Date
1.

What is a stack?

a)

a. a type of map

b)

b. a FIFO (First In, First Out) data structure

c)

c. a LIFO (Last In, First Out) data structure

d)

d. None of the above

2.

Which function adds an element to the top of a stack?

a)

a. push()

b)

b. pop()

c)

c. top()

d)

d. insert()

3.

What does 'count()' do in a map?

a)

a. Counts the number of maps

b)

b. Checks if a key exists

c)

c. Counts the number of values

d)

d. Returns the size of the map

4.

Which of the following has the BEST time complexity for searching?

a)

a. Linear Search

b)

b. Binary Search

c)

c. Selection Sort

d)

d. Insertion Sort

5.

In recursion, what is the base case?

a)

a. The case that repeats

b)

b. The case that calls itself

c)

c. The initial call to the function

d)

d. The case that ends the recursion

6.

How do you access the value in a map using a key?

a)

map[key]

b)

map.value(key)

c)

map.get(key)

d)

map.find(key)

7.

What is the Big O time complexity of a binary search?

a)

a. O(n)

b)

b. O(nlogn)

c)

c. O(n^2)

d)

d. O(2^n)

8.

Which pointer operation is used to access the value at a memory address?

a)

&

b)

[]

c)

*

d)

->

9.

What is the time complexity of selection sort?

a)

O(n)

b)

O(nlogn)

c)

O(n^2)

d)

O(2^n)

10.

What does the keyword 'throw' do in C++?

a)

a. Declares an exception

b)

b. Catches an exception

c)

c. Raises an exception

d)

d. Non of the above

11.

Which of the following correctly describes Big O notation?

a)

a. It measures the best-case complexity for an algorithm

b)

b. It measures the worst-case complexity for an algorithm

c)

c. It measures the average-case complexity for an algorithm

d)

d. It measures the exact number of operations for an algorithm

12.

In a linked list, what does each node contain?

a)

Data and a pointer to the next node

b)

Only data

c)

Data and a pointer to the previous node

d)

A pointer to the previous and next node

13.

What is the purpose of 'assert' in debugging?

a)

a. To catch exceptions

b)

b. To print debugging information

c)

c. To test assumptions and stopping the program if they're false

d)

d. To handle exceptions that were caught

14.

How do you declare a pointer to an integer in C++?

a)

int ptr

b)

int* ptr

c)

int &ptr

d)

int[] ptr

15.

What does the keyword 'new' do in C++?

a)

Allocates memory

b)

Deallocates memory

c)

Initializes a variable

d)

Creates an object

16.

Which of the following is an example of a runtime error in C++?

a)

a. Missing semicolon

b)

b. Type in variable name

c)

c. Division by zero

d)

d. Syntax error

17.

What is the time complexity of searching for an element in a linked list?

a)

a. O(1)

b)

b. O(logn)

c)

c. O(n)

d)

d. O(n^2)

18.

What is the difference between a recursive function and a iterative function?

a)

A recursive function uses arrays, an iterative function uses arrays

b)

A recursive function calls itself, an iterative function uses loops

c)

A recursive function uses loops, an iterative function uses two loops

d)

There is no difference

19.

Why would you not want to use a binary search?

a)

It is the slowest search algorithm

b)

It takes a lot of memory to use

c)

It takes too long to write

d)

It requires a sorted data set

20.

What does the keyword 'delete' do in C++?

a)

Allocates memory

b)

Deallocates memory

c)

Initializes a variable

d)

Creates an object

21.

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

a)

Faster sorting

b)

It's simpler to write

c)

Dynamic sizing

d)

Accessing elements is faster

22.

What is the main drawback of using recursion?

a)

High memory usage

b)

Increased time complexity

c)

Cannot solve complex problems

d)

There is no drawback

23.

How is dynamic programming primarily used?

a)

a. Solving problems by recursion

b)

b. Solving problems by iteration

c)

c. Solving problems by splitting and combining sub-problems

d)

d. Solving problems by multithreading

24.

What is the difference between a class and a struct?

a)

Classes cannot have member functions

b)

Structs cannot have member functions

c)

Classes can inherit, structs cannot

d)

By default, members of a class are private, members of a struct are public