Finding Maximum Element in an Array using Recursion

Recursion is something that may be a little confusing to understand but when you master it would be very much easier and will actually consume less space compared to a normal iterative function. So now we will write a program to find the maximum element in an array using recursion.

Algorithm :

  • Get the numbers from the user and pass the array and size of array to the function
  • Declare max as global and initialise it to a[0].
  • Inside the function check for the condition of maximum element and if the index value reaches -1 return the maximum element.


Popular posts from this blog

Finding the Number of Trailing Zero's in Factorial of a Number

Finding the sum of N Biggest elements in Binary Search Tree

Finding a Single Number amongst Repeated Numbers [Repeated Twice]