In each cycle the smallest element will be moved to its correct place to the left
How It Works: Link to Video
- Worst Case Complexity: O(n2) If we want to sort in ascending order and the array is in descending order then, the worst case occurs.
- Best Case Complexity: O(n2) It occurs when the array is already sorted
- Average Case Complexity: O(n2) It occurs when the elements of the array are in jumbled order (neither ascending nor descending).
- The space complexity is O(1) because this algorithm is in place, so it does not use any extra memory to sort.
- Comparison Based
- Not Stable
- Inplace
- Makes minimum memory writes as compared to all other sorting algorithms
- This sorting algorithm is best suited for situations where memory write or swap operations are costly.
- Useful for complex problems.
- No additional storage is required.
- In-Place sorting algorithm.
- A minimum number of writes to the memory
- Cycle sort is useful when the array is stored in EEPROM or FLASH.
- It is not mostly used.
- It has more time complexity O(n2)
- Unstable sorting algorithm.