niluferpolat / Algorithm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Algorithm

Insertion Sort

[22,27,16,2,18,6] -> Insertion Sort

  1. [2,27,16,22,18,6]
  2. [2,6,16,22,18,27]
  3. [2,6,16,18,22,27]

Big O Notation--->O(n2) Time Complexity of this array is average case(For 18)

[7,3,5,8,2,9,4,15,6]

  1. [2,3,5,8,7,9,4,15,6]
  2. [2,3,4,8,7,9,5,15,6]
  3. [2,3,4,5,7,9,8,15,6]
  4. [2,3,4,5,6,9,8,15,7]
  5. [2,3,4,5,6,7,8,15,9]
  6. [2,3,4,5,6,7,8,9,15]

Merge Sort

[16,21,11,8,12,22] -> Merge Sort

  1. [16,21,11] [8,12,22]
  2. [16] [21,11] [8,12] [22]
  3. [16] [21] [11] [8] [12] [22]
  4. [16] [21,11] [8,12] [22]
  5. [11,16,21] [8,12,22]
  6. [8,11,16,21,22]

Big O Notation--->O(nlogn)

Binary Search Tree

[7, 5, 1, 8, 3, 6, 0, 9, 4, 2]

       [5]
  [2]         [8]

[0][1] [3][4] [7] [6][9]

About