Data structures and Algorithms using Elixir Language
defmodule Algox.BinarySearch do
@ moduledoc """
Binary search: marking the middle element
in a list as pivot (starting point) before
making any search. Do note the
implementation needs to sort the list.
Returns the index position or nil.
"""
defmodule Algox.LinearSearch do
@ moduledoc """
Linear search: needs to traverse the
entire list in order to find the target.
Returns the index position or nil.
"""
defmodule Algox.QuickSort do
@ moduledoc """
Quick sort: in this version, it picks
the first element as pivot, then inserts
the pivoted element in between the
lesser numbers and greater numbers.
Accepts integer and returns empty list
or list of integers.
"""
defmodule WalkOnMatrix do
@ moduledoc """
Walk on matrix: Think of these as "spiral"
walking until you hit the center of it.
You start at the very leftmost part, then
traverse in spiral fashion (or like snake,
let your imagination flow) until you hit
the center. We'll use nested list integers
as an example input.
Accepts 2-dimensional list of integers
and returns 1-dimensional list of all
integers according on the order of
walking.
"""
using mix task:
# file names found in lib/algox dir
mix benchmark binary_search
mix benchmark quick_sort