Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * <summary> Determines the index of the smallet element </summary>
- * <params>
- * "arr" = Array containing the integer elements
- * "size" = Size of "arr"
- * "currentIndex" = Index position of the current element
- * </params>
- * <return> Index of the first occuring minimum value </return>
- * <precond>
- * "size" > 0
- * Function should have an intial call with "0" as the currentIndex
- * </precond>
- */
- int get_min_index(int arr[], int size, int currentIndex)
- {
- int minIndex;
- /* Base Case - Last Element */
- if(currentIndex == size - 1)
- return currentIndex;
- minIndex = get_min_index(arr, size, currentIndex + 1);
- return (arr[currentIndex] <= arr[minIndex]) ? currentIndex : minIndex;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement