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
Exam (elaborations)

WGU C960 – Discrete Mathematics II Objective Assessment Review Full Questions, Correct Answers, and Worked Solutions | 2026 Update | 100% Correct

Rating
-
Sold
-
Pages
46
Grade
A+
Uploaded on
16-07-2026
Written in
2025/2026

What is the final value of abs after the following pseudocode is run? text x := 2 If (x 0) abs := x Else abs := -x End-if A) -2 B) 0 C) 2 D) 4 Answer: C Rationale: The condition (x 0) evaluates to true because x = 2. The line abs := x is executed, assigning the value 2 to abs. The Else branch is skipped entirely . Question 2 What is the final value of abs after the following pseudocode is run? text x := -2 If (x 0) abs := x Else abs := -x End-if A) -2 B) 0 C) 2 D) 4 Answer: C Rationale: The condition (x 0) evaluates to false because x = -2. The Else branch executes, setting abs := -x = -(-2) = 2 . Question 3 What is the final value of product after the following pseudocode runs? text product := 1 count := 5 While (count 0) product := product * count count := count - 2 End-while A) 3 B) 5 C) 15 D) 30 Answer: C Rationale: • Iteration 1: count = 5, product = 1 × 5 = 5, count becomes 3 • Iteration 2: count = 3, product = 5 × 3 = 15, count becomes 1 • The loop would execute a third iteration (count = 1), but the condition is checked at the start. Wait, let me recalculate: Actually, the loop executes while count 0: • Iteration 1: count=5 → product=5, count=3 • Iteration 2: count=3 → product=15, count=1 • Iteration 3: count=1 → product=15, count=-1 • Loop ends (count = -1) Final product = 15 Question 4 How many iterations will the loop in Question 3 execute? A) 1 B) 2 C) 3 D) 4 Answer: C Rationale: count values: 5, 3, 1. Each time count 0, the loop executes. When count becomes -1, the condition count 0 is false. The loop executes 3 iterations . Question 5 Consider the following pseudocode that merges two lists: text Merge0(List1, List2) Set OUTlist to empty While List1 is not empty OR List2 is not empty If one list is empty and the other is not, Remove the first number from the non-empty list and add it to OUTlist If both lists are non-empty, Remove the first number from List1 and add it to OUTlist Remove the first number from List2 and add it to OUTlist Return OUTlist If ListA = [1, 3, 5] and ListB = [2, 4, 6], what is the result of Merge0(ListA, Merge0(ListB, ListA))? A) [1, 2, 3, 4, 5, 6] B) [1, 2, 3, 1, 5, 4, 3, 6, 5] C) [2, 1, 4, 3, 6, 5] D) [2, 4, 6, 1, 3, 5] Answer: B Rationale: First compute the inner call: Merge0([2,4,6], [1,3,5]) produces [2,1,4,3,6,5]. Then the outer call: Merge0([1,3,5], [2,1,4,3,6,5]) produces [1,2,3,1,5,4,3,6,5] . Question 6 Given the following pseudocode, what is S at the end? text S = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} x = 2 While(x 11): For i in S: If 0 ≡ i mod x and i ≠ x: delete i from S end-If end-For x = x + 1 end-While A) {2, 3, 5, 7, 9, 11, 13, 17, 19} B) {2, 3, 5, 7, 11, 13, 17, 19} C) {1, 2, 3, 5, 7, 11, 13, 17, 19} D) All numbers remain Answer: B Rationale: This is the Sieve of Eratosthenes algorithm. Starting with x=2, it removes all multiples of each number. After removing all composites, only primes remain: {2, 3, 5, 7, 11, 13, 17, 19} .

Show more Read less
Institution
Wgu
Course
C 960

Content preview

WGU C960 – Discrete Mathematics II
Objective Assessment Review Full
Questions, Correct Answers, and Worked
Solutions | 2026 Update | 100% Correct.



SECTION 1: ALGORITHMS & ALGORITHM ANALYSIS
(Questions 1-30)

Question 1

What is the final value of abs after the following pseudocode is run?

text
x := 2
If (x > 0)
abs := x
Else
abs := -x
End-if


A) -2
B) 0
C) 2
D) 4

Answer: C

Rationale: The condition (x > 0) evaluates to true because x = 2. The line abs := x is
executed, assigning the value 2 to abs. The Else branch is skipped entirely .

,Question 2

What is the final value of abs after the following pseudocode is run?

text
x := -2
If (x > 0)
abs := x
Else
abs := -x
End-if


A) -2
B) 0
C) 2
D) 4

Answer: C

Rationale: The condition (x > 0) evaluates to false because x = -2. The Else branch
executes, setting abs := -x = -(-2) = 2 .




Question 3

What is the final value of product after the following pseudocode runs?

text
product := 1
count := 5
While (count > 0)
product := product * count
count := count - 2
End-while


A) 3
B) 5
C) 15
D) 30

,Answer: C

Rationale:

• Iteration 1: count = 5, product = 1 × 5 = 5, count becomes 3
• Iteration 2: count = 3, product = 5 × 3 = 15, count becomes 1
• The loop would execute a third iteration (count = 1), but the condition is checked at
the start. Wait, let me recalculate:

Actually, the loop executes while count > 0:

• Iteration 1: count=5 → product=5, count=3
• Iteration 2: count=3 → product=15, count=1
• Iteration 3: count=1 → product=15, count=-1
• Loop ends (count = -1)
Final product = 15




Question 4

How many iterations will the loop in Question 3 execute?
A) 1
B) 2
C) 3
D) 4

Answer: C

Rationale: count values: 5, 3, 1. Each time count > 0, the loop executes. When count
becomes -1, the condition count > 0 is false. The loop executes 3 iterations .




Question 5

Consider the following pseudocode that merges two lists:

, text
Merge0(List1, List2)
Set OUTlist to empty
While List1 is not empty OR List2 is not empty
If one list is empty and the other is not,
Remove the first number from the non-empty list and add it to OUTlist
If both lists are non-empty,
Remove the first number from List1 and add it to OUTlist
Remove the first number from List2 and add it to OUTlist
Return OUTlist


If ListA = [1, 3, 5] and ListB = [2, 4, 6], what is the result of Merge0(ListA,
Merge0(ListB, ListA))?
A) [1, 2, 3, 4, 5, 6]
B) [1, 2, 3, 1, 5, 4, 3, 6, 5]
C) [2, 1, 4, 3, 6, 5]
D) [2, 4, 6, 1, 3, 5]

Answer: B

Rationale: First compute the inner call: Merge0([2,4,6], [1,3,5]) produces [2,1,4,3,6,5]. Then
the outer call: Merge0([1,3,5], [2,1,4,3,6,5]) produces [1,2,3,1,5,4,3,6,5] .




Question 6

Given the following pseudocode, what is S at the end?

text
S = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
x = 2
While(x < 11):
For i in S:
If 0 ≡ i mod x and i ≠ x:
delete i from S
end-If
end-For
x = x + 1
end-While

Written for

Institution
Course

Document information

Uploaded on
July 16, 2026
Number of pages
46
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$14.99
Get access to the full document:

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

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Brainarium Delaware State University
View profile
Follow You need to be logged in order to follow users or courses
Sold
1969
Member since
3 year
Number of followers
1045
Documents
23691
Last sold
5 hours ago

3.8

333 reviews

5
155
4
63
3
57
2
16
1
42

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