Open In App

C++ Program to Find the Minimum and Maximum Element of an Array

Last Updated : 23 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Given an array, write functions to find the minimum and maximum elements in it. 


Example:

Output: 

Minimum element of array: 1
Maximum element of array: 1234

Time Complexity: O(n)

Auxiliary Space: O(1), as no extra space is used
Recursive Solution 

Example:

Output: 

Min of array: 1
Max of array: 1234

Time Complexity: O(n)

Auxiliary Space: O(n), as implicit stack is used due to recursion


Using Library functions: 
We can use min_element() and max_element() to find minimum and maximum of array. 


Example:

Output:

Minimum element of array: 1
Maximum element of array: 1234

Time Complexity: O(n)

Auxiliary Space: O(1), as no extra space is used

 


Article Tags :
Practice Tags :

Similar Reads