Skip to content

Latest commit

 

History

History
13 lines (9 loc) · 440 Bytes

13-BubbleSort.md

File metadata and controls

13 lines (9 loc) · 440 Bytes

BubbleSort

The problem

Write a function f(N) that accepts an array of numbers N and returns it sorted

Concepts

  • compare each member to the element to the right
  • if right number is larger, switch the two elements
  • each pass there is no need to check (length - i)th element, as that is the largest num in the last pass (largest elements 'bubble' up to the end)
  • length - 1 passes are needed to fully sort the array

Notes