Bubble Sort In Data Structure
• It is comparison based algorithm in which each pair of adjacent element is compare and elements are swapped if they are in not in order. • Therefore, after the first pass, the largest element in the array will have bubbled up to one end of the array.
• Element 11 the largest has bubbled up to the end of array.
• Now same process will be applied until we get sorted list.
• How to decide that array has been sorted?
• for this we check whether or not any exchanges has been made in the current pass.
• If yes then array is not sorted and if no then array has been sorted.
• For this we will use flag set to true if exchange is made during pass.
18- Array- Bubble Sort Part-1- DataStructures
CLICK HERE TO Download This PDF NOTES