본문 바로가기

버블 정렬

English

Put the smallest height first

  • Four heights sit in an array. The smallest should come first.
  • Compare each pair of neighbours. When the left one is larger, swap them.
  • That single comparison does not finish the list. The next pair is compared after it.

One pass over 160, 152, 171, 148: swap, keep, swap; 171 reaches the end but 148 is not first yet

교재 자료

로그인 또는 계정 만들기

IGCSE, A-Level & AP