Bubble sort- Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. The pass of the list is repeated until the list is sorted. Why bubble sort is called “bubble” sort? The “bubble” sort is called so because the list elements with greater value than their surrounding elements “bubble” towards the end of the list . For example, after first pass, the largest element is bubbled towards the right most position. Worst complexity : n^2 Average complexity : n^2 Best complexity : n Space complexity : 1 at the end of i th pass, we have the i th largest element placed at its correct place. look the example below. Example: First Pass: ( 5 1 4 2 8 ) –> ( 1 5 4 2 8 ) ( 1 5 4 2 8 ) –> ( 1 4 5 2 8 ) ( 1 4 5 2 ...
Technical Keeda is best plateform for learning coding, Programming,competitive programming ,c++ language. Here we Provide best explaination of Programming question also Here You can boost your technical knowledge.You Will get aware of latest technology available in market.