(60 Views)

Array, is a data structure consisting of a collection of homogenous datatype 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.

In the above algorithm,

- We first take input the number of elements in the array from user and store it in variable n.
- Then we declare a array a of size n and read it from the user.
- We then declare two variables i and large.
- Intialize i=1 and largest= a[0], the first element of the array a.
- 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.
- At last, when we get out of the loop the value stored in the variable large is the largest element in an array.

0 UpvotesUpvote |
0 DownvotesDownvote |

- Find HCF and LCM using Python [642 Views]
- Javascript Program to Check whether Number is Prime or Not [453 Views]
- Bellman-Ford Algorithm with Example [2517 Views]
- Download DIGITAL SIGNAL PROCESSING by Ashok Ambardar PDF [440 Views]
- 0/1 Knapsack problem with solution [1867 Views]

- Knuth-Morris-Pratt (KMP) Substring Search Algorithm with Java Example [9721 Views]
- Pseudocode and Algorithm to find whether number is Armstrong Number or Not [8749 Views]
- How To Win Ludo King Game Every Time [8524 Views]
- error: Multiple commands produce error in Xcode 10 [5381 Views]
- FlowChart and Pseudocode to find Whether a Number is Even or Odd [4621 Views]