0% found this document useful (0 votes)
17 views

Step 1: Let Largest L1

The document describes an algorithm to find the largest number in an unsorted list of numbers. The algorithm involves: 1) Setting the first number in the list as the initial largest number. 2) Iterating through each item in the list and comparing it to the current largest. 3) If an item is larger than the current largest, updating the largest to that item. 4) After iterating through the full list, the final largest number is returned.

Uploaded by

ADITYA ANSH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Step 1: Let Largest L1

The document describes an algorithm to find the largest number in an unsorted list of numbers. The algorithm involves: 1) Setting the first number in the list as the initial largest number. 2) Iterating through each item in the list and comparing it to the current largest. 3) If an item is larger than the current largest, updating the largest to that item. 4) After iterating through the full list, the final largest number is returned.

Uploaded by

ADITYA ANSH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

A very simple example of an algorithm would be to find the largest number in an unsorted list

of numbers. If you were given a list of five different numbers, you would have this figured out
in no time, no computer needed. Now, how about five million different numbers? Clearly, you
are going to need a computer to do this, and a computer needs an algorithm.

Below is what the algorithm could look like. Let's say the input consists of a list of numbers,
and this list is called L. The number L1 would be the first number in the list, L2 the second
number, etc. And we know the list is not sorted - otherwise, the answer would be really easy.
So, the input to the algorithm is a list of numbers, and the output should be the largest number
in the list.

The algorithm would look something like this:


Step 1: Let Largest = L1
This means you start by assuming that the first number is the largest number.
Step 2: For each item in the list:
This means you will go through the list of numbers one by one.
Step 3: If the item > Largest:
If you find a new largest number, move to step four. If not, go back to step two, which means
you move on to the next number in the list.
Step 4: Then Largest = the item
This replaces the old largest number with the new largest number you just found. Once this is
completed, return to step two until there are no more numbers left in the list.
Step 5: Return Largest
This produces the desired result.

Notice that the algorithm is described as a series of logical steps in a language that is easily
understood. For a computer to actually use these instructions, they need to be written in a
language that a computer can understand, known as a programming language.

You might also like