/ruby

playing with array in ruby

Primary LanguageRuby

ruby

array.rb * playing with array in ruby

  1. uniq function
  2. hex.to_s(2) hex to binary function & gsub function with hash as second argument
  3. toeplitz matrix array
  4. count array values split by comas
  5. loop vs inject

jstackprocstate.rb * using piped shell commands with open3

sort.rb * sort algorithms

  1. Bubble sort : O(n^2) Adaptive: O(n) when nearly sorted
  2. Selection sort: Θ(n^2) Not adaptive
  3. Insertion sort: O(n^2) Adaptive: O(n) when nearly sorted
  4. Heap sort : O(n·log(n)) Seudo Adaptive
  5. Merge sort : O(n·log(n))
  6. Bucket sort : O(n)

search.rb * search algorithms

  1. linearsearh
  2. binarysearch

recursion.rb * recursive approach examples

  1. fibonacci
  2. factorial
  3. towerofhanoi

linkedlist.rb * linked list data structure