Docsity

CS1332 Campus Spring 2022 Exam 3 Version A, Exams of Data Structures and Algorithms

Toggle sidebar
bg1
CS1332 Campus Spring 2022 Exam 3 Version A
Amara Janeice Williams
TOTAL POINTS
73 / 100
QUESTION 1
1 Big-O A 2 / 2
✓ + 2 pts Correct $$O(n^2)$$
ÊÊ + 0 pts Incorrect
QUESTION 2
2 Big-O B 2 / 2
✓ + 2 pts Correct $$O(n^2)$$
ÊÊ + 1 pts Partial credit
ÊÊ + 0 pts Incorrect
QUESTION 3
3 Big-O C 0 / 2
ÊÊ + 2 pts Correct $$O(n^2)$$
✓ + 0 pts Incorrect
QUESTION 4
4 Big-O D 2 / 2
✓ + 2 pts Correct $$O(kn)$$
ÊÊ + 0 pts Incorrect
QUESTION 5
5 Big-O E 0 / 2
ÊÊ + 2 pts Correct $$O(m+n)$$
✓ + 0 pts Incorrect
QUESTION 6
6 Big-O F 1 / 2
ÊÊ + 2 pts Correct $$O(m+n)$$
✓ + 1 pts Partial credit
✓ + 0 pts Incorrect
QUESTION 7
7 Big-O G 2 / 2
✓ + 2 pts Correct $$O(mn)$$
ÊÊ + 1 pts Partial Credit
ÊÊ + 0 pts Incorrect
QUESTION 8
8 Sorting ID A 3 / 3
✓ + 3 pts LSD Radix Sort
ÊÊ + 0 pts Incorrect/No answer
QUESTION 9
9 Sorting ID B 3 / 3
✓ + 3 pts QuickSort
ÊÊ + 0 pts Incorrect/No answer
QUESTION 10
10 Sorting ID C 3 / 3
✓ + 3 pts Cocktail Shaker Sort
ÊÊ + 0 pts Incorrect/No answer
QUESTION 11
11 KMP Failure Table 6 / 10
ÊÊ + 10 pts Correct Failure Table = [0, 1, 0, 1, 2, 2, 3,
4, 5, 3]
Partial Credit (only if not all entries are
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download CS1332 Campus Spring 2022 Exam 3 Version A and more Exams Data Structures and Algorithms in PDF only on Docsity!

CS1332 Campus Spring 2022 Exam 3 Version A

Amara Janeice Williams

TOTAL POINTS

QUESTION 1

1 Big-O A 2 / 2

✓ + 2 pts Correct $$O(n^2)$$

  • 0 pts Incorrect

QUESTION 2

2 Big-O B 2 / 2

✓ + 2 pts Correct $$O(n^2)$$

  • 1 pts Partial credit
  • 0 pts Incorrect

QUESTION 3

3 Big-O C 0 / 2

  • 2 pts Correct $$O(n^2)$$ ✓ + 0 pts Incorrect

QUESTION 4

4 Big-O D 2 / 2

✓ + 2 pts Correct $$O(kn)$$

  • 0 pts Incorrect

QUESTION 5

5 Big-O E 0 / 2

  • 2 pts Correct $$O(m+n)$$ ✓ + 0 pts Incorrect

QUESTION 6

6 Big-O F 1 / 2

  • 2 pts Correct $$O(m+n)$$

✓ + 1 pts Partial credit ✓ + 0 pts Incorrect

QUESTION 7

7 Big-O G 2 / 2

✓ + 2 pts Correct $$O(mn)$$

  • 1 pts Partial Credit
  • 0 pts Incorrect

QUESTION 8

8 Sorting ID A 3 / 3

✓ + 3 pts LSD Radix Sort

  • 0 pts Incorrect/No answer

QUESTION 9

9 Sorting ID B 3 / 3

✓ + 3 pts QuickSort

  • 0 pts Incorrect/No answer

QUESTION 10

10 Sorting ID C 3 / 3

✓ + 3 pts Cocktail Shaker Sort

  • 0 pts Incorrect/No answer

QUESTION 11

11 KMP Failure Table 6 / 10

  • 10 pts Correct Failure Table = [0, 1, 0, 1, 2, 2, 3, 4, 5, 3]

Partial Credit (only if not all entries are

correct)

✓ + 1 pts f[0] = 0 ✓ + 1 pts f[1] = 1 ✓ + 1 pts f[2] = 0 ✓ + 1 pts f[3] = 1 ✓ + 1 pts f[4] = 2

  • 1 pts f[5] = 2
  • 1 pts f[6] = 3
  • 1 pts f[7] = 4
  • 1 pts f[8] = 5 ✓ + 1 pts f[9] = 3

QUESTION 12

12 Rabin-Karp Rolling Hash 3 / 10

  • 10 pts Correct: 895

Partial. mutually exclusive with 1

  • 1 pts calculates $$BASE^5 = 2^5 = 32$$ ✓ + 1 pts calculates $$M * BASE^5=2*2^5=64$$ ✓ + 1 pts calculates $$500 - M * BASE^5 = 500 - 2*2^5 = 436$$
  • 2 pts calculates $$(500 - M * BASE^5) * BASE $$ $$ = (500 - 22^5)2 = 872$$ ✓ + 1 pts adds value of 'o' (23): $$... + 23 = 895$$
  • 0 pts Incorrect/Blank

QUESTION 13

13 Quicksort Diagramming 9.5 / 10

✓ + 1 pts exactly 4 swaps occured (8 elements circled) ✓ + 1.5 pts 78 and 71 are swapped (Pivot Swap)

✓ + 1.5 pts 65b and 82a are swapped ✓ + 1.5 pts 72 and 84 are swapped ✓ + 1.5 pts 72 and 78 are swapped

Left Subarray PICK ONE

✓ + 1 pts left sub array is in order: 72, 65b, 65a, 71 (it is okay if 78 is last)

  • 0.5 pts left sub array is in order based on incorrect swaps

Right Sub array PICK ONE

✓ + 1 pts right sub array is in order: 84, 82b, 82a, 88 (it is okay if 78 is first)

  • 0.5 pts right sub array is in order based on incorrect swaps ✓ + 0.5 pts left sub array does not contain 78
  • 0.5 pts right sub array does not contain 78

Incorrect Pivot, Correct Quicksort

  • 1 pts some element was swapped to index 0
  • 2 pts based on pivot index from first swap, remaining swaps are correct
  • 1 pts chosen pivot is placed into correct final location
  • 1 pts left sub array is in order based on incorrect pivot
  • 1 pts right sub array is in order based on incorrect pivot
  • 0.5 pts neither sub array contains the pivot
  • 0 pts incorrect
  • 0.5 pts at least 3 elements were not circled (there should be 8 circled)

QUESTION 14 14 Boyer-Moore Galil Diagramming 9.5 /

Extracting ith digit (KG) - no credit if both

used

  • 1.5 pts Correct - K
  • 0 pts Incorrect

Filling / Emptying buckets (DEI) - no credit if

all 3 used

  • 2.5 pts Correct - DE
  • 0.5 pts Breaks FIFO - IE
  • 0 pts Incorrect
  • 0 pts Incorrect / No answer

QUESTION 16

16 HashMap Coding 10.5 / 12 ✓ + 1 pts Checks if key == null ✓ + 0.5 pts If key == null, throws IllegalArgumentException

Hash and Compression

✓ + 1.5 pts Takes the hash of the key (i.e. key.hashCode()) ✓ + 1 pts Attempts to handle hashes >= capacity (e.g. mod) ✓ + 0.5 pts Mods the hash by table.length

  • 1 pts Attempts to handle negative hashes (e.g. Math.abs)
  • 0.5 pts Takes absolute value after modding hash

Search through chain

✓ + 1 pts Sets a current reference to the head of a chain ✓ + 1 pts Has a loop that continue while current != null ✓ + 1 pts Checks if current.key.equals(key)

✓ + 1 pts If key match, returns current.value ✓ + 1 pts Sets current = current.next ✓ + 1 pts If no keys match, throws NoSuchElementException

  • 1 pts Syntax Error
  • 1 pts Minor Error
  • 1 pts Inefficient
  • 1 pts Modifies HashMap
  • 0 pts Incorrect / No answer

QUESTION 17 17 AVL Coding 5.5 / 15 ✓ + 1 pts Creates a helper method ✓ + 1 pts Calls a helper method ✓ + 1 pts Helper method has a base case ✓ + 1 pts Method avoids NullPointerException ✓ + 2.5 pts Checks the Balance Factor of the current node (or compares the heights of its children or depth of curr to height of root)

  • 1.25 pts Traverses left when BF > 0 (or leftHeight > rightHeight)
  • 1.25 pts Traverses right when BF < 0 (or leftHeight < rightHeight)
  • 1.25 pts Traverses left and right when bf == 0
  • 1 pts Adds node data to a list
  • 1 pts Returns a list
  • 1.25 pts List is correct (only the deepest nodes, in sorted order)
  • 1.5 pts Efficient: Traverses down only the deepest branches
  • 1 pts Efficiency (Multiple lists, list operations, etc.)
  • 1 pts Minor error ✓ - 1 pts Syntax
  • 1 pts Modifies tree
  • 0 pts Incorrect / No Answer (^1) should be &&

QUESTION 18

18 Bonus 1 / 0

✓ + 1 pts literally anything is drawn

  • 0 pts blank

Page 5