• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 27 pages
Exam (elaborations)

WGU C960 DISCRETE MATH II PA EXAM QUESTIONS WITH 100% COMPLETE SOLUTIONS

Document preview thumbnail
Preview 3 out of 27 pages

WGU C960 DISCRETE MATH II PA EXAM QUESTIONS WITH 100% COMPLETE SOLUTIONS....

Content preview

WGU C960 DISCRETE MATH II PA EXAM
QUESTIONS WITH 100% COMPLETE
SOLUTIONS

Algorithms and Algorithm Structures: Pre-assessment
First query:
Examine the pseudocode that combines two lists of numbers into one, as
follows:

(List1, List2) Merge0
Make the OUTlist empty.
Either List 1 or List 2 is not empty.
If one list is empty and the other is not,
Add the first number to the OUTlist after removing it from the non-empty list.
If neither list is empty,
Add the first number to the OUTlist after removing it from List 1.
Add the first number to the OUTlist after removing it from List 2.
Return Outlist

What happens when Merge0 (ListA, Merge0 (ListB, ListA)) is performed if
ListA is [1, 3, 5] and ListB is [2, 4, 6]? [1, 2, 3, 1, 5, 4, 3, 6, 5] is the answer.
First Step:
We must comprehend the operation of the Merge0 function in order to solve
this. By selecting the first item from each list and adding it to the output list in
ascending order, it combines two lists. The first member from the non-empty
list is taken out and added to the output list if one list is empty while the other is
not.
With the example provided, we have:
ListA = [1, 3, 5]
ListB is equal to [2, 4, 6].
The innermost function Merge0(ListB, ListA) will now be examined:
1. OUTlist = null
2. OUTlist = [2]
3. OUTlist = [2, 1]

,4. OUTlist = [2, 1, 4]
5. List of Outcomes = [2, 1, 4, 3]
6. List of Outcomes = [2, 1, 4, 3, 6]
7. [2, 1, 4, 3, 6, 5] is the OUTlist.
8. Since ListA is now empty, OUTlist = [2, 1, 4, 3, 6, 5] is returned.
Step 2:
The second argument for the outer Merge0 function will now be the outcome of
Merge0(ListB, ListA). Thus, we have:
ListA = [1, 3, 5] = List1
List2 = [2, 1, 4, 3, 6, 5] = Merge0(ListB, ListA)
With these lists and the Merge0 function, we get:
1. OUTlist = null
2. OUTlist = [1]
3. OUTlist = [1, 2]
4. OUTlist = [1, 2, 3]
5. List of Outcomes = [1, 2, 3, 1]
6. List of Outcomes = [1, 2, 3, 1, 5]
7. [1, 2, 3, 1, 5, 4] is the OUTlist.
8. [1, 2, 3, 1, 5, 4, 3] is the OUTlist.
9. [1, 2, 3, 1, 5, 4, 3, 6] is the OUTlist.
10. [1, 2, 3, 1, 5, 4, 3, 6, 5] is the OUTlist.
11. OUTlist = [1, 2, 3, 1, 5, 4, 3, 6, 5] is returned.
Thus, [1, 2, 3, 1, 5, 4, 3, 6, 5] is the outcome of Merge0(ListA, Merge0(ListB,
ListA)).

Algorithms and Algorithm Structures: Pre-assessment
Second query:

Considering this pseudocode:
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}] is S.
x = 2.
While (x<11):
Regarding i in S:
If i ≠ x and 0 ≡ i mod x:
remove "I" from S.
final-If
final-For
x = x + 1.

, final moment

At the end of this code, what is S? "2, 3, 5, 7, 11, 13, 17, 19" is the answer.

Finding the prime integers from the provided collection is all that this function
does.
Commence with x = 2.
1) When x = 2, we must remove from S those entries that meet 0 == i mod 2
and i ≠ 2, that is, multiples of 2 other than 2. Thus, {4, 6, 8, 10, 12, 14, 16, 18,
20} is eliminated.
x = x+1
2) When x = 3, we must remove from S those entries that meet 0 == i mod 3
and i ≠ 3, that is, multiples of 3 other than 3. Therefore, we eliminate {6, 9, 12,
15, 18}
x = x+1
3) When x = 4, we must remove from S those entries that meet 0 == i mod 4
and i ≠ 4, that is, multiples of 4 other than 4. Therefore, we eliminate {8, 12, 16,
20}
x = x+1
4) When x = 5, we must remove from S those entries that meet 0 == i mod 5
and i ≠ 5, that is, multiples of 5 other than 5. Thus, we eliminate {10, 15, 20}
x = x+1
5) We must remove from S all components that meet 0 == i mod 6 and i ≠ 6
(i.e., multiples of 6 except 6) when x = 6. Thus, we eliminate {12, 18}
x = x+1
6) When x = 7, we must remove from S those entries that meet 0 == i mod 7
and i ≠ 7, that is, multiples of 7 other than 7. Thus, we eliminate {14}
x = x+1
7) When x = 8, we must remove from S those entries that meet 0 == i mod 8
and i ≠ 8, that is, multiples of 8 other than 8. Thus, we eliminate {16}
x = x+1
8) When x = 9, we must remove from S those entries that fulfill 0 == i mod 9
and i ≠ 9, that is, multiples of 9 other than 9. Thus, we eliminate {18}
x = x+1
9) We must remove from S those elements that fulfill 0 == i mod 10 and i ≠ 10,
that is, multiples of 10, except 10 when x = 10. Thus, we eliminate {20}
x = x+1
We break the while loop and end the program now that x = 11.

Document information

Uploaded on
February 8, 2025
Number of pages
27
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$15.19

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

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.
luzlinkuz
3.8
(330)
Sold
1611
Followers
852
Items
32513
Last sold
13 hours 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