You are on page 1of 2

AL101 – ALGORITHMS AND COMPLEXITY

ACTIVITY # 1 Week # 2

NAME: Vida, John Paul S


STUDENT NO: 20-2167
YEAR/SECTION: 3rd Year / SBIT - 3L
DATE: 1/27/23

INSTRUCTIONS:
Create a program that will find the lowest and highest element in an array. You also need to draw a
system Flowchart and the Pseudocode of this program.

FLOWCHART:

PSEUDOCODE:
1: Start
2: Declare variable large, i and array a[n]
3: Read n from User and read all the elements of a[n]
4: Initialize Variable large=a[0] , and i=1
5: Repeat Until i<=n-1
5.1 if(a[i]>large), set large=a[i]
5.2 increment i=i+1
6: Print "The smallest element is": small
“The largest element is”: large
7: Stop
1. We first take input the number of elements in the array from the user and store it in
variable n.
2. Then we declare an array of size n and read it from the user.
3. Then declare two variables i and large.
4. Initialize i=1 and largest= a[0], the first element of the array a.
5. Then we compare a[i] with large, if a[i] is greater we set large=a[i] We repeat the above
step until (n-1) is greater than or equal to i.
6. At last, when we get out of the loop the value stored in the variable large is the largest
element in an array.

SYSTEM’S SCREENSHOT (OUTPUT):

Note:
To prove an algorithm is correct, empirical analysis is frequently used by developers to uncover flaws in
algorithms, but only formal reasoning can establish complete correctness.

To understand why we should use algorithms in programming, we must first realize that computer
programs use various algorithms that operate on computer hardware that includes a CPU and memory,
both of which have constraints. A CPU is not indefinitely fast, and memory is not unlimited. They are
finite resources. They must be handled with caution, and a smart algorithm that is efficient in terms of
time and space complexities can assist you in doing so.

You might also like