Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 30 pages
Exam (elaborations)

WGU C949 Data Structures and Algorithms|OA|OBJECTIVE ASSESSMENT|EXPLORE NEW 102 ACTUAL QUESTIONS AND ANSWERS|100% ACCURATE

Document preview thumbnail
Preview 3 out of 30 pages

WGU C949 Data Structures and Algorithms|OA|OBJECTIVE ASSESSMENT|EXPLORE NEW 102 ACTUAL QUESTIONS AND ANSWERS|100% ACCURATE

Content preview

WGU C949 Data Structures and
Algorithms|OA|OBJECTIVE
ASSESSMENT|EXPLORE NEW 102 ACTUAL
QUESTIONS AND ANSWERS|100% ACCURATE


1. Given a hash table of size m=13 that uses open addressing with double hashing, where primary
hash function h1(k)=k mod 13 and secondary hash function h2(k)=1+(k mod 11). Insert the keys
18, 41, 22, 44, 59, 32, 31, 73 in this order. After all insertions, what is the average number of probes
required to search for a key that is present in the table? (Assume uniform distribution and that all
keys are equally likely to be searched.)

A. 1.0
B. 1.25
C. 1.5
D. 1.75

Answer: B
Rationale: The insertions cause collisions. The sequence of probes for each key: 18->5 (1 probe), 41->2
(1), 22->9 (1), 44->5,18,? double: h2=1+44mod11=1, so probe 5,18? Actually 44: h1=5 (collision),
h2=1+0=1, so probe 6 (free) -> 2 probes. 59: h1=7 (1 probe). 32: h1=6 (collision with 44),
h2=1+10=11, so probe 6+11=17 mod13=4 (free) -> 2 probes. 31: h1=5 (collision with 18),
h2=1+9=10, probe 5, then 5+10=15 mod13=2 (collision with 41), then 2+10=12 (free) -> 3 probes.
73: h1=8 (1 probe). Total probes = 1+1+1+2+1+2+3+1=12, average = 12/8 = 1.5. But wait, average
probes for successful search = (sum of probes for each key)/8 = 12/8 = 1.5. However, the question asks
average number of probes to search for a key that is present, which is the same as successful search. So
answer should be 1.5, but options include 1.5 as C. Double-check: 44: h1=5, h2=1+44mod11=1+0=1,
so probe 5 (collision), then (5+1)=6 (free) => 2 probes. 32: h1=6, h2=1+32mod11=1+10=11, probe 6
(collision), then 6+11=17 mod13=4 (free) => 2 probes. 31: h1=5, h2=1+31mod11=1+9=10, probe 5
(collision), then 5+10=15 mod13=2 (collision), then 2+10=12 (free) => 3 probes.
Sum=1+1+1+2+1+2+3+1=12, average=1.5. So correct is C. But I wrote B earlier, so correct answer
is C: 1.5.


2. Consider a binary search tree (BST) that stores distinct integers. Suppose we insert the following
sequence of keys into an initially empty BST in the order given: 50, 30, 70, 20, 40, 60, 80, 35, 45, 55,
65. After all insertions, we delete the key 50 using the standard BST deletion algorithm (replace
with inorder successor). Which of the following statements about the resulting tree is true?

A. The root of the tree is 60, and the left subtree of the root contains both 30 and 70.
B. The root of the tree is 60, and the height of the tree is 4.
C. The root of the tree is 55, and the height of the tree is 3.
D. The root of the tree is 55, and the height of the tree is 4.




Page 1

,Answer: B
Rationale: After insertions, the BST is balanced. Deleting 50: the inorder successor is 55 (the smallest
key in the right subtree). The successor is a leaf (55 has no left child). So we replace 50 with 55, and
then delete the leaf 55 (which originally was at the left child of 60? Actually 55 is left child of 60, but
after deletion, 60's left becomes null). The new root is 55. But wait, the successor is 55, so root becomes
55. Height: from root 55, left subtree height = 3 (30-40-45 or 30-20-? Actually left subtree: 30 has
children 20 and 40, 40 has children 35 and 45, so height 3). Right subtree: 70 has 60 and 80, 60 has 65
(and 55 is gone), so height 2. So overall height = max(3,2)+1 = 4. So root is 55, height 4. Option D says
root=55, height=4, so D is correct. Option B says root=60, height=4, which is wrong. Option C says
root=55, height=3, wrong. Option A says root=60, wrong. So correct is D.


3. Which of the following best describes the primary advantage of using a splay tree over an AVL
tree for implementing a dictionary that supports insert, delete, and search operations, given that
the access pattern exhibits temporal locality?

A. Splay trees guarantee O(log n) amortized time for all operations, whereas AVL trees only guarantee
worst-case O(log n) but can degrade to O(n) on certain sequences.
B. Splay trees are simpler to implement because they do not require storing balance factors or performing
rotations.
C. Splay trees automatically adapt to the access pattern, bringing frequently accessed elements closer to the root,
which can lead to faster access times for repeated queries.
D. Splay trees use less memory than AVL trees because they do not store any auxiliary data in each node.

Answer: C
Rationale: Both splay trees and AVL trees guarantee O(log n) time per operation (amortized for splay,
worst-case for AVL). Option A is false because AVL trees also have worst-case O(log n). Option B is
false because splay trees still require rotations (splaying). Option D is false because splay trees do not
store balance factors, but they do store parent pointers typically, so memory difference is negligible. The
key advantage is that splay trees are self-adjusting and exploit locality of reference, making repeated
accesses to the same key faster.


4. Consider the following weighted undirected graph with vertices A, B, C, D, E, and edges: AB
(weight 4), AC (2), BC (1), BD (5), CD (3), CE (6), DE (7). Suppose we run Kruskal's algorithm to
find the minimum spanning tree. Which edge is added last to the MST?

A. AB
B. CE
C. DE
D. BD

Answer: C
Rationale: Kruskal's algorithm sorts edges by weight: BC(1), AC(2), CD(3), AB(4), BD(5), CE(6), DE(7).
Starting with BC, then AC, then CD. At this point, vertices A,B,C,D are connected. Next edge AB (4)
would create a cycle (A-B-C-A), so skip. Next BD (5) would connect B and D, but they are already
connected, skip. Next CE (6) connects C and E, so add CE. Now all vertices are connected (A,B,C,D via
earlier edges, and E via CE). The last edge added is DE? Actually after adding CE, the MST has edges
BC, AC, CD, CE (total weight 1+2+3+6=12). The next edge DE (7) would connect D and E, but D and
E are already connected through D-C-E, so it would create a cycle, so it is skipped. So the last edge
added is CE. But wait, CE is added fourth, and then no more edges are added. So the last added edge is

Page 2

, CE. But option B is CE. However, check if DE is added? No, because after CE, all vertices are
connected. So correct is B: CE. But I need to verify: The MST should have 4 edges for 5 vertices. Edges
added: BC, AC, CD, CE. That's 4 edges. So last added is CE. So answer is B.


5. In the context of dynamic programming, consider the problem of computing the minimum
number of scalar multiplications needed to multiply a chain of matrices A1, A2, ..., An, where
matrix Ai has dimensions p_{i-1} x p_i. If the dimensions are given by the array p = [10, 20, 30, 40,
30], what is the minimum number of scalar multiplications?

A. 18000
B. 24000
C. 30000
D. 36000

Answer: B
Rationale: Using the matrix chain multiplication DP algorithm. For n=4 matrices (A1:10x20, A2:20x30,
A3:30x40, A4:40x30). Compute optimal costs: m[1][2]=10*20*30=6000; m[2][3]=20*30*40=24000;
m[3][4]=30*40*30=36000. For length 3:
m[1][3]=min(m[1][2]+m[3][3]+10*20*40=6000+0+8000=14000,
m[1][1]+m[2][3]+10*30*40=0+24000+12000=36000) => 14000.
m[2][4]=min(m[2][3]+m[4][4]+20*30*30=24000+0+18000=42000,
m[2][2]+m[3][4]+20*40*30=0+36000+24000=60000) => 42000. For length 4:
m[1][4]=min(m[1][1]+m[2][4]+10*20*30=0+42000+6000=48000,
m[1][2]+m[3][4]+10*30*30=6000+36000+9000=51000,
m[1][3]+m[4][4]+10*40*30=14000+0+12000=26000) => 26000. Wait, 26000 is not among options.
Let's recalc: Actually p = [10,20,30,40,30]. So matrices: A1:10x20, A2:20x30, A3:30x40, A4:40x30. For
m[1][4]: k=1: m[1][1]+m[2][4]+10*20*30 = 0 + 42000 + 6000 = 48000. k=2:
m[1][2]+m[3][4]+10*30*30 = 6000 + 36000 + 9000 = 51000. k=3: m[1][3]+m[4][4]+10*40*30 =
14000 + 0 + 12000 = 26000. So minimum is 26000. But 26000 is not an option. Options are
18000,24000,30000,36000. Did I miscompute? Check dimensions: p[0]=10, p[1]=20, p[2]=30,
p[3]=40, p[4]=30. So A1:10x20, A2:20x30, A3:30x40, A4:40x30. For m[2][4] I got 42000. But maybe
the optimal order is (A1 (A2 A3 A4))? Let's compute recursively: (A1 ((A2 A3) A4)): cost = cost(A2 A3)
+ cost((A2A3)A4) + cost(A1(rest)). cost(A2A3)=20*30*40=24000. Then (A2A3) is 20x40. Multiply with
A4: 20*40*30=24000. So cost of ((A2A3)A4)=24000+24000=48000. Then A1*(that): 10*20*30?
Actually A1 is 10x20, result of rest is 20x30? Wait, the product (A2A3A4) yields 20x30. So cost = 48000
+ 10*20*30 = 48000+6000=54000. That's higher. Another order: (A1 A2) (A3 A4):
cost(A1A2)=10*20*30=6000, cost(A3A4)=30*40*30=36000, then multiply: (10x30) and (30x30) cost
10*30*30=9000, total = 6000+36000+9000=51000. Another: A1 (A2 (A3 A4)): cost(A3A4)=36000,
then (A2*(A3A4)): A2 20x30, (A3A4) 30x30? Actually A3A4 is 30x30? Wait A3:30x40, A4:40x30,
product is 30x30. So cost = 36000 + 20*30*30 = 36000+18000=54000, then A1*(that):
10*20*30=6000, total 60000. So the best is 26000 from order (A1 A2 A3) A4? Let's compute (A1 A2 A3)
first: m[1][3]=14000 (from earlier). That product is 10x40. Then multiply with A4: 10*40*30=12000,
total 14000+12000=26000. So that's correct. But 26000 is not an option. Perhaps the dimensions are
different? Maybe p = [10,20,30,40,30] but I misread? Alternatively, maybe the question expects the
answer for a different chain length? Let's double-check the options: 18000, 24000, 30000, 36000. 24000
appears as m[2][3] = 20*30*40 = 24000. So maybe the question is asking for something else? Or
perhaps I made an arithmetic error: 10*40*30 = 12000, plus 14000 = 26000. Yes. Could it be that the


Page 3

Document information

Uploaded on
July 6, 2026
Number of pages
30
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$20.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
1
Followers
2
Items
412
Last sold
2 weeks ago


Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions