it starts on the rightmost element efficiency of the bubble sort as you can see by watching the workshop applet with barsthe inner and inner+ arrows make comparisons on the first pass on the secondand so ondown to comparison on the last pass for items this is in generalwhere is the number of items in the arraythere are - comparisons on the first passn- on the secondand so on the formula for the sum of such series is ( - ( - ( - *( - )/ *( - )/ is when is thus the algorithm makes about / comparisons (ignoring the - which doesn' make much differenceespecially if is largethere are fewer swaps than there are comparisonsbecause two bars are swapped only if they need to be if the data is randoma swap is necessary about half the timeso there will be about / swaps (although in the worst casewith the initial data inversely sorteda swap is necessary with every comparison both swaps and comparisons are proportional to because constants don' count in big notationwe can ignore the and the and say that the bubble sort runs in ( time this is slowas you can verify by running the workshop applet with bars whenever you see nested loops such as those in the bubble sort and the other sorting algorithms in this you can suspect that an algorithm runs in ( time the outer loop executes timesand the inner loop executes (or perhaps divided by some constanttimes for each cycle of the outer loop this means you're doing something approximately * or times selection sort the selection sort improves on the bubble sort by reducing the number of swaps necessary from ( to (nunfortunatelythe number of comparisons remains ( howeverthe selection sort can still offer significant improvement for large records that must be physically moved around in memorycausing the swap time to be much more important than the comparison time (typically this isn' the case in javawhere references are moved aroundnot entire objects selection sort on the baseball players let' consider the baseball players again in the selection sortyou can no longer compare only players standing next to each other thus you'll need to remember certain player' heightyou can use notebook to write it down magenta-colored towel will also come in handy brief description what' involved is making pass through all the players and picking (or selectinghence the name of the sortthe shortest one this shortest player is then swapped with the