Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sorting & Searching alGOrithms

Kaylyn
April 27, 2018

Sorting & Searching alGOrithms

A presentation explaining Quicksort and Binary Search in Go with Testing and Benchmarks.

Kaylyn

April 27, 2018
Tweet

Other Decks in Technology

Transcript

  1. 1. New to Go 2. New to algorithms 3. I

    already know these, why am I here Who is this talk for?
  2. Quicksort “Given an array, one element is chosen and the

    others are partitioned into two subsets-those less than the partition element and those greater than or equal to it. The same process is then applied recursively to the two subsets. When a subset has fewer than two elements, it doesn't need any sorting; this stops the recursion.” Kernighan and Ritchie
  3. E A D C B F G E R T

    U D E O B L I C E U G E N E R E D A R O L A V I D
  4. B A

  5. Binary Search Search a sorted array by repeatedly dividing the

    search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty. GeeksForGeeks
  6. D C G F A E B lo hi mid

    E > D left array right array
  7. G F E hi E < F lo mid right

    array left array