Skip to content

safalinf/Sorting-Algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sorting-Algorithms

Bubble Sort

This Sorting algorithm has O(n^2) time complexity.

Algorithm for Bubble sort

  -> first iterate though a given array(i as a looping variable) 
    ->secondly run a second nested loop (j as a looping variable)
      -> check(arr[j]>=arr[j+1]) then swap(arr[j],arr[j+1])

Insertion Sort

This Sorting algorithm has O(n^2) time complexity.

Algorithm for Insertion sort

   In this sorting we basically make a gap such that the smallest element to the adjacent will occupy that place:
   1.
         for example:  6->5->7->3->2
         for i=1: first=5
         while(A[j]>=5) we make a gap in the 1st place i.e. 6 so 6->5 will become 5->6
   Similarly this process go on:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages