Skip to content

Instantly share code, notes, and snippets.

View jorgemdnt's full-sized avatar

Jorge Modesto jorgemdnt

View GitHub Profile
@bih
bih / MergeSort.markdown
Last active December 31, 2022 14:20
MergeSort Example in Ruby

MergeSort Algorithm in Ruby

When learning about sorting algorithms, I wanted to implement them to help me understand them better. This algorithm was originally invented by John von Neumann in 1948.

The Ruby script attached explains in real code what is going on. Play about with it.

How does the algorithm work?

Step by step:

  • Pass through an array of unsorted numbers (i.e. [4, 3, 2, 10])