AND PROGRAMMING - FOUNDATIONS:
(LATEST 2026/2027 UPDATE), WITH
CORRECT/ACCURATE ANSWERS
WGU D278 FINAL EXAM PREP SCRIPTING
AND PROGRAMMING - FOUNDATIONS
WGU D278 – Final Exam Prep (2026/2027 Update)
Scripting and Programming – Foundations
Question 1
Which change would correct the following algorithm so that it correctly identifies the
maximum number from a list containing the values 2, 7, 8, 3, 9, and 1?
max = 0
for each value
if value > max
max = value
else
max = 0
A. Initialize max to the first value in the list
B. Remove the else clause
C. Replace > with <
D. Move max = 0 outside the loop
Correct Answer: B
Rationale:
The else clause incorrectly resets the maximum value to zero whenever a value is not
greater than the current maximum. This causes previously stored maximum values to
be lost. By removing the else clause, the algorithm only updates max when a larger
value is found, preserving the correct maximum throughout the loop. This ensures the
algorithm functions as intended.
,Question 2
What does algorithm time efficiency measure?
A. The amount of memory an algorithm uses
B. The readability of an algorithm
C. The number of calculations required to solve a problem
D. The number of variables in a program
Correct Answer: C
Rationale:
Algorithm time efficiency refers to how many operations or calculations an algorithm
performs as input size increases. It helps determine how well an algorithm scales and
performs under larger workloads. Time efficiency is often expressed using Big-O
notation. Understanding efficiency allows programmers to choose faster solutions.
Question 3
Which search algorithm is generally the most efficient when working with a sorted list?
A. Linear search
B. Hash search
C. Binary search
D. Sequential search
Correct Answer: C
Rationale:
Binary search repeatedly divides a sorted list in half, significantly reducing the number
of comparisons required. This gives it a time complexity of O(log n), which is much
faster than linear search for large datasets. However, binary search requires the data
to be sorted beforehand. When that condition is met, it is the most efficient option.
,Question 4
Place the steps of a binary search algorithm in the correct order.
A. Compare the midpoint value to the target
B. Find the midpoint of the sorted list
C. Repeat until the value is found or the list is exhausted
D. Choose the left or right half based on comparison
Correct Order:
1. B
2. A
3. D
4. C
Rationale:
Binary search begins by identifying the midpoint of a sorted list. The midpoint is
compared to the target value to determine which half may contain the target. The
algorithm then narrows the search range accordingly. This process repeats until the
value is found or no elements remain.
Question 5
Arrange the steps of the following algorithm in the correct order to plant a seed.
A. Put pot in sunlight
B. Cover seed with soil
C. Fill pot with soil
D. Poke hole in soil
E. Water pot in a shady area
F. Place seed in hole
Correct Order:
, 1. C
2. D
3. F
4. B
5. E
6. A
Rationale:
Algorithms require logical sequencing to achieve the desired outcome. Soil must be
added before creating a hole, and the seed must be placed before covering it.
Watering occurs after planting to support germination. Sunlight is introduced last to
promote healthy growth.
Question 6
What is the primary purpose of UML (Unified Modeling Language)?
A. To write executable code
B. To test software performance
C. To visualize the structure and behavior of programs
D. To replace programming languages
Correct Answer: C
Rationale:
UML provides standardized diagrams that visually represent system components and
interactions. These diagrams help developers and stakeholders understand system
architecture and behavior. UML improves communication during development and
reduces ambiguity. It does not replace code but complements it.
Question 7
Which UML diagrams are commonly used during the testing phase of the SDLC?