Sorting Algorithms

The sorting problem is as following:
Take a bunch of numbers, put them in order.

Input: We have a sequence <a1, a2, a3, ......, an>of number

.

Output: A permutation (rearrangement) <a1', a2', a3', ....., an'> of those numbers.

such that: a1' <= a2' <= ... <= an'

Psudo code of Insertion-Sort :

Insertion-Sort(A,n) //sort A[1..n]
    for j <-- 2 to n
        do key <-- A[j]
            i <-- j - 1
            while i  > 0 and A[i] > key
                do A[i + 1] <-- A[i] 
                    i  <-- i - 1
                A[i+1] <-- key

 
1
Kudos
 
1
Kudos

Now read this

Capybara Cheat Sheet

Capybara helps to test web applications by simulating a real user. Navigating # visit products_path visit '/products/new' visit post_comments_path(post) Clicking links and buttons # click_button 'New Product' click_link 'Delete'... Continue →