Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are given a stack of 100 cards On each card is written a positive number bet

ID: 3663813 • Letter: Y

Question

You are given a stack of 100 cards On each card is written a positive number between 1 and 100. Define an algorithm that you would use to find the largest number in the stack. Make sure that your algorithm is clear and unambiguous. Identify any selection or repetition in it. Represent the algorithm using pseudocode. The cards in the stack would look somewhat like the following: The actual numbers written on the cards are not important for your algorithm. What is important is that they are equal or greater than 1, no number is repeated, and the cards are not sorted in any way.

Explanation / Answer

We will store all the card numbers in an array first and then find the largest number from that array using a for loop and comparing each and every element .

We will assign maximum to the first element of the array and keep comparing it with the rest of the elements of the array one by one. We will swap the value if we find a number greater than maximum and make it as maximum.Then we will continue comparing till th end of array of 100 elements to find the largest/maximum in the array which will be be the maximum number present in the stack of cards.

This is how we will find the largest element from a deck of cards.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote