wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CSE214 Final Review

Total questions: 44

Worksheet time: 57mins

Name
Class
Date
1.

Order from least to greatest Time complexity

a)

O(3), O(log n), O(n log n), O(10n), O(n^2), O(n^10), O(2^n), O(n!), O(n^n)

b)

O(3), O(log n), O(10n), O(n^2), O(n log n), O(n^10), O(2^n), O(n!), O(n^n)

c)

O(3), O(log n), O(10n), O(n log n), O(n^2), O(2^n), O(n^10), O(n^n), O(n!)

d)

O(3), O(log n), O(10n), O(n log n), O(n^2), O(n^10), O(2^n), O(n!), O(n^n)

2.

Evaluate the time complexity

a)

O(N)

b)

O(N^2)

c)

O(N log N)

d)

O(1)

3.

For N=20, what will be printed?

(a)  

4.

Consider the following method, which is supposed to remove all nodes of a linked list containing a value and return the new head. Select the 2 test cases where the removeVal(head,1); performs as expected

a)

1 -> 2 -> 3 -> 4

b)

2 -> 1 -> 1 -> 2

c)

2 -> 2 -> 2 -> 2

d)

2 -> 1 -> 2 -> 2

5.

What are the benefits of using a DOUBLY linked list rather than a SINGLY

(You have access to head and tail)

a)

Remove Head becomes faster

b)

Remove Tail becomes faster

c)

Insert Tail becomes faster

d)

Doubly uses less space than singly

6.

For a stack implemented using a singly linked list with top = head and no tail reference, what are the time complexities?

a)

PUSH: O(1)

POP: O(1)

b)

PUSH: O(1)

POP: O(N)

c)

PUSH: O(N)

POP: O(1)

d)

PUSH: O(N)
POP: O(N)

7.

For a stack implemented using a singly linked list with bottom = head and top = tail, what are the time complexities?

a)

PUSH: O(1)

POP: O(1)

b)

PUSH: O(1)

POP: O(N)

c)

PUSH: O(N)

POP: O(1)

d)

PUSH: O(N)
POP: O(N)

8.

Evaluate the prefix expression of integers:
- / + 5 * 4 3 2 4

(a)  

9.

Evaluate the postfix expression of integers:

5 4 * 2 1 - - 3 /

(a)  

10.

Convert the infix to postfix:

A + (B + C / D) * E

a)

A B C + D / + E * +

b)

A B C D / + E + *

c)

A B + C + D / E *

d)

A B C D / + E * +

11.

Convert the postfix to infix:
A B + C / D E * -

a)

A + B / C - D * E

b)

(A + B) / C - D * E

c)

(A + B) / C * D - E

d)

A + B / C * D - E

12.

A normal queue, implemented using a circular array, gets FULL when?

a)

rear == CAPACITY

b)

rear == CAPACITY – 1

c)

(rear + 1) % CAPACITY == front

d)

None of Above

13.

A normal queue, implemented using a circular array, is empty when?

a)

front == −1 && rear == −1

b)

rear == front

c)

front = 0 && rear = 0

d)

None of above

14.

Which of the following traversals prints the elements out in ascending order?

a)

Preorder Traversal

b)

Inorder Traversal

c)

Postorder Traversal

d)

Breadth-first search

15.

What does the following method count?

a)

The number of internal nodes

b)

The number of leaves

c)

The number of nodes with a null reference

d)

The number of nodes without a null reference

16.

What is the worst case time complexity of Quick sort, and why?

a)

O(n^2) because the pivot always ends up being the maximum or minimum element in every partition.

b)

 O(n^2) because it effectively acts as bubble sort when the list is sorted in ascending or descending order.

c)

O(n log n) because the partitioning step efficiently divides the array into smaller segments, reducing the overall time complexity.

d)

O(n log n) because the algorithm recursively divides the array and combines the results using a divide-and-conquer strategy.

17.

Which of the following sorts does not have an O(N) best case?

a)

Quick sort

b)

Bubble sort

c)

Insertion sort

d)

Counting sort

18.

Which sequence of numbers creates this BST?

a)

7, 26, 1, 5, 29, 31, 22, 9, 11

b)

7, 26, 5, 1, 31, 29, 22, 11, 9

c)

7, 1, 5, 26, 31, 29, 22, 9, 11

d)

7, 26, 1, 5, 31, 29, 9, 22, 11

19.

Postorder:

a)

1, 5, 7, 9, 11, 22, 26, 29, 31

b)

7, 1, 5, 26, 22, 9, 11, 31, 29

c)

5, 1, 11, 9, 22, 29, 31, 26, 7

d)

7, 1, 26, 5, 22, 31, 9, 29, 11

20.

Inorder

(a)  

21.

A binary tree has 1000 nodes. How many null references does it have?

(a)  

22.

A full tree has a depth of 4. How many nodes does it have?

(a)  

23.

All (a) trees are (b), and all (b) trees are (c).

What is a, b, and c?

a)

Balanced, complete, full

b)

Full, balanced, complete

c)

Balanced, full, complete

d)

Full, complete, balanced

24.

Full?

Complete?

Balanced?

Heap?

BST?

a)

Full NO

Complete NO

Balanced YES

Heap NO

BST YES

b)

Full NO

Complete NO

Balanced YES

Heap NO

BST NO

c)

Full NO

Complete NO

Balanced NO

Heap NO

BST NO

d)

Full NO

Complete NO

Balanced NO

Heap NO

BST YES

25.

Remove node 22 from BST

a)

b)

c)

26.

IF a 2-3-4 Tree has a height of 2, What is the maximum number of ELEMENTS it can contain?

a)

63

b)

48

c)

51

d)

64

27.

Assuming Root is at index 0 and node is at index i.

What are the correct formulas for accessing members of a heap?

a)

Parent: i/2

Left Child: 2i+1

Right Child: 2i+2

b)

Parent: (i-1)/2

Left Child: 2i-1

Right Child: 2i-2

c)

Parent: (i-1)/2

Left Child: 2i

Right Child: 2i+1

d)

Parent: (i-1)/2

Left Child: 2i+1

Right Child: 2i+2

28.

Heap sort's time complexity is O(N log N) because...

a)

Heapify: O(N)

Remove all elements from heap: O(N log N)

b)

Heapify: O(N log N)

Remove all elements from heap: O(N)

c)

Heapify: O(N log N)

Remove all elements from heap: O(N log N)

d)

Heapify: O(N)

Remove all elements from heap: O(log N)

29.

Insert 55 into the following heap: [100, 19, 36, 17, 3, 25]

Which array index will it be in?

(a)  

30.

Time complexity to find the minimum value in a max-heap is (and why)

a)

O(log n) - Need to search every leaf

b)

O(n log n) - Need to remove every element until finding that value

c)

O(n) - Need to search every element in the heap

d)

O(n) - Need to search every leaf in the heap

31.

Select all of the following that is sufficient for reconstructing an unique binary tree

a)

Preorder and inorder

b)

Inorder and postorder

c)

Preorder and postorder

32.

What is the minimum number of nodes that a red black tree with depth 2 can have?

(a)  

33.

Create the Binary Tree:
Inorder: DBEAFC

Preorder: ABDECF

a)

b)

c)

d)

34.

Perform first outer loop iteration of selection sort on

25 20 30 15 45 50 10 13

(a)  

35.

Perform first outer loop iteration of insertion sort on

25 20 30 15 45 50 10 13

(a)  

36.

Perform first outer loop iteration of bubble sort on

25 20 30 15 45 50 10 13

Please answer in the same format as the question

(a)  

37.

Given: 25, 20, 30, 15, 45, 50, 10, 13

Perform the first partition of Quick Sort

Assume first element is choosen as the pivot

a)

10, 13, 15, 20, 25, 30, 45, 50

b)

20, 13, 15, 10, 25, 50, 45, 30

c)

13, 20, 10 15, 25, 50, 45, 30

d)

20, 30, 15, 25, 45, 50, 10, 13

38.

Which of the following are NOT a property of red-black trees?

a)

All root to null paths must have the same number of black nodes

b)

It is a binary search tree

c)

The left and right subtree depths cannot differ by more than 1

d)

Red nodes cannot have red children

39.

Perform these Operations on this original heap:

Remove()

Add(14)

Add(26)


Now, What Data is stored at the parent of index 4 of the array representation?

(a)  

40.

Which Sort does NOT sort in place?

a)

Heap Sort

b)

Selection Sort

c)

Bubble Sort

d)

Counting Sort

41.

Sequential and binary search time complexities?

a)

Sequential: O(log N)
Binary: O(N)

b)

Sequential: O(N)
Binary: O(N^2)

c)

Sequential: O(log N)
Binary: O(log N)

d)

Sequential: O(N)
Binary: O(log N)

42.

Which search is better if the array is unsorted

a)

Sequential

b)

Binary

43.

Which search is better when the target is the first element

a)

Sequential

b)

Binary

44.

Which search is better for very large lists

a)

Sequential

b)

Binary