Answer in Brief
Write an algorithm to find smallest element in an Array.
Advertisement Remove all ads
Solution
1) Initialize both first and second smallest as INT_MAX first = second = INT_MAX 2) Loop through all the elements. a) If the current element is smaller than first, then update first and second. b) Else if the current element is smaller than second then update second
Concept: Basic Data Structures (Stack, Queue, Dequeue)
Is there an error in this question or solution?
Advertisement Remove all ads
APPEARS IN
Advertisement Remove all ads
Advertisement Remove all ads