Pseudocode and Flowchart for finding the largest element in an Array

[4010 views]


Array is a data structure consisting of a collection of homogenous data type or element (values or variables), each identified by at least one array index or key. An array is stored in such a manner that the position of each element can be found out from its index tuple by using a mathematical formula. The simplest data structure is a linear array, also known as one-dimensional array.

Arrays are among the most important data structures and are used in almost every program. They can be also used to implement many other data structures, such as linked-lists and stacks. The most important fact is that arrays are linear datatypes in which data is stored in sequence. In many internal and external storage devices, the memory is a one-dimensional array of words, whose indices are their addresses. We can access the elements if we know their indexes directly so, we can say that random access is possible in array.

Flowchart for finding the largest element in an Array :

Flowchart for finding the largest element in an Array
Remove WaterMark from Above Flowchart

Algorithm to find the largest element in an Array :

Step 1: Start Step 2: Declare array a[n] and variable i, large Step 3: Read n from User and read all the elements of a[n] Step 4: Initialize Variable i=1 and large=a[0] Step 5: Repeat Until i<=n-1 5.1 if(a[i]>large), set large=a[i] 5.2 increment i=i+1 Step 6: Print "The largest element is": large Step 7: Stop

In the above algorithm,

  1. We first take input the number of elements in the array from user and store it in variable n.
  2. Then we declare a array a of size n and read it from the user.
  3. We 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.
        

Algorithm Logic Test

Our Quiz prepared by Experts Helps you identify your knowledge in Algorithms. Everyone should atleast attempt this Quiz Once. 



Comments



Recommended Book Deals Ends in

Download 101 Ready to Use Excel Formulas ebook
Download Python All in One for Dummies ebook



Search
Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online

Search Tags

    Simple Algorithm for Largest Element in an Array

    Simple Flowchart for Largest Element in an Array

    Search Array for biggest number algorithm