- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Program to find the largest element in an array
In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given an array, we need to calculate the largest element of the array.
Here we use the bruteforce approach in which we compute the largest element by traversing the whole loop and get the element.
We can observe the implementation below.
# largest function def largest(arr,n): #maximum element max = arr # traverse the whole loop for i in range(1, n): if arr[i] > max: max = arr[i] return max # Driver Code arr = [23,1,32,67,2,34,12] n = len(arr) Ans = largest(arr,n) print ("Largest element given in array is",Ans)
Largest in given array is 67
All the variables are declared in global form as shown above
In this article, we have learned how to get the largest element from the array.
- Python Program to find largest element in an array
- C# Program to find the largest element from an array
- C++ Program to Find Largest Element of an Array
- Program to find largest element in an array in C++
- Program to find out the index in an array where the largest element is situated in Python
- C# Program to find the largest element from an array using Lambda Expressions
- Kth Largest Element in an Array in Python
- Java program to find the largest number in an array
- Kth Largest Element in an Array
- Java program to find the 3rd largest number in an array
- Java program to find the 2nd largest number in an array
- Python Program to Find the Largest Element in a Doubly Linked List
- Java program to find Largest, Smallest, Second Largest, Second Smallest in an array
- PHP program to find the minimum element in an array
- PHP program to find the maximum element in an array