Algorithms and Data Structures Review

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/21

flashcard set

Earn XP

Description and Tags

Flashcards covering asymptotic notation, sorting algorithms (Selection, Bubble, Heapsort), BST traversals and construction, RPN, Graph theory, Hashing, Huffman coding, and algorithmic complexities based on the exam answer key.

Last updated 5:35 PM on 6/25/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

22 Terms

1
New cards

Using the definition of asymptotic notation, what specific values of c1c_1, c2c_2, and n0n_0 prove that n22n=Θ(n2)n^2 - 2n = \Theta(n^2)?

c1=1/3c_1 = 1/3, c2=1c_2 = 1, and n0=3n_0 = 3 (Note: 1/2,1,41/2, 1, 4 is also valid)

2
New cards

Order the following functions from slowest-growing to fastest-growing: (1) nlog(n)n \cdot \log(n), (2) 11, (3) nn, (4) n0.9n^{0.9}, (5) n!n!, (6) log3(n)\log^3(n)

2, 6, 4, 3, 1, 5 (11; log3(n)\log^3(n); n0.9n^{0.9}; nn; nlog(n)n \cdot \log(n); n!n!)

3
New cards

What is the result of the first pass of ascending Selection Sort on the sequence: 3,5,4,6,1,2,03, 5, 4, 6, 1, 2, 0?

0,5,4,6,1,2,30, 5, 4, 6, 1, 2, 3

4
New cards

What is the result of the first pass of Bubble Sort on the sequence: 6,2,5,9,8,3,6,26, 2, 5, 9, 8, 3, 6, 2?

2,5,6,8,3,6,2,92, 5, 6, 8, 3, 6, 2, 9

5
New cards

In a Heapsort procedure using a MAX-heap, what is the state of the array 17,14,11,5,6,2,8,917, 14, 11, 5, 6, 2, 8, 9 after 3 steps (the three largest elements placed at the end)?

9,6,8,5,2,11,14,179, 6, 8, 5, 2, 11, 14, 17

6
New cards

After applying the BUILD-MAX-HEAP algorithm to the array 7,15,4,10,3,9,13,2,1,87, 15, 4, 10, 3, 9, 13, 2, 1, 8, what is the resulting sequence?

15,10,13,7,8,9,4,2,1,315, 10, 13, 7, 8, 9, 4, 2, 1, 3

7
New cards

Define the order of visits in a PREORDER Binary Search Tree (BST) traversal.

root, left subtree, right subtree

8
New cards

What is the POSTORDER traversal of a BST with root 1010, where 10L:510 \rightarrow L:5 (5L:35 \rightarrow L:3 (3L:13 \rightarrow L:1), 5R:75 \rightarrow R:7) and 10R:1510 \rightarrow R:15 (15L:1415 \rightarrow L:14, 15R:2515 \rightarrow R:25)?

1,3,7,5,14,25,15,101, 3, 7, 5, 14, 25, 15, 10

9
New cards

If keys 15,8,17,18,19,10,9,4,20,1415, 8, 17, 18, 19, 10, 9, 4, 20, 14 are inserted into an empty BST, how many nodes are in the subtree rooted at the RIGHT child of the LEFT child of the root?

3 nodes (The subtree rooted at node 10, containing {10, 9, 14})

10
New cards

What is the Reverse Polish Notation (postfix) for the expression: ((1+3)/2+(122)×3)/2((1+3)/2+(12-2) \times 3)/2?

1 3 + 2 / 12 2 - 3 \times + 2 /

11
New cards

Given the graph vertices V={1,2,3,4,5,6}V = \{1,2,3,4,5,6\} and edges E={(1,2),(2,1),(1,4),(1,3),(3,5),(5,3),(4,5),(5,6)}E = \{(1,2),(2,1),(1,4),(1,3),(3,5),(5,3),(4,5),(5,6)\}, what is row 1 of the adjacency matrix?

0 1 1 1 0 0

12
New cards

What is the edit distance (Levenshtein) between the strings ARM and RAMA?

3

13
New cards

What is the phenomenon in linear probing hashing where long, merging runs of occupied cells are created?

Primary clustering

14
New cards

What is the worst-case time complexity for lookup and deletion in Cuckoo hashing?

O(1)O(1)

15
New cards

How many total bits are required to encode a symbol in a Hamming code with distance 3 and an alphabet size of 24?

9 bits (5 information bits + 4 check bits)

16
New cards

What are the primary properties of Huffman coding regarding its codewords and optimality?

It is an optimal prefix-free code with variable-length codewords that minimizes the average total encoded length.

17
New cards

What are the disadvantages of using an adjacency matrix to represent a graph?

It uses O(n2)O(n^2) memory regardless of the number of edges (wasteful for sparse graphs) and iterating over a vertex’s neighbors costs O(n)O(n).

18
New cards

Why is the statement 'Insertion sort, bubble sort, and radix sort all have O(n2)O(n^2) worst-case complexity' false?

Radix sort does not have O(n2)O(n^2) complexity; it runs in O(d(n+k))O(d \cdot (n+k)) time.

19
New cards

Why is a binary heap NOT considered an efficient dictionary data structure?

Because searching for an arbitrary key in a binary heap takes O(n)O(n) time.

20
New cards

What is the average-case complexity of interpolation search on uniformly distributed data?

O(loglog(n))O(\log \log(n))

21
New cards

In which data structure can the maximum element be found in O(log(n))O(\log(n)) expected time?

A treap (the maximum is the rightmost node)

22
New cards

Which sorting algorithm has the smallest worst-case complexity: heap sort, insertion sort, or quicksort?

Heap sort (O(nlog(n))O(n \log(n)))