Learn basic concept of c , c++ and python programming in regularcodes.com

Spread the post

Find the Smallest element of unsorted array

Given an unsorted array Our goal is to find minimum element of this given array. Suppose array are contain following elements.

Stack AreamainFind smallest elementdata [0] 322 Smallest [3] at index 8 [1] 444 [2] 12 [3] 66 [4] 233 [5] 466 [6] 233 [7] 11 [8] 3 [9] 4 [10] 112 [11] 443 [12] 221size (int) =13

Algorithm:

Help of this function we are learning how to find smallest element in given array


Time complexity of this program O(n)

Accepted Output


C program to find smallest element of given array. Iterative approach.


Output

Code execution:

Find smallest element Find smallest element of given array Stack Areamaindata [0] 322 [1] 444 [2] 12 [3] 66 [4] 233 [5] 466 [6] 233 [7] 11 [8] 3 [9] 4 [10] 112 [11] 443 [12] 221size (int) =13smallest_dataindex (int) =11result(pointer)size (int) =13temp(pointer)

Here not given all process to find how to find smallest element in unsorted array. Visualize how to find smallest element in step by step.

Try it Yourself

Spread the post

Recommended Posts: