• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
August 13, 2024 |10.2K Views

Cycle Sort

  Share   Like
Description
Discussion

Cycle sort is an in-place sorting Algorithm, unstable sorting algorithm, a comparison sort that is theoretically optimal in terms of the total number of writes to the original array. 
 

It is optimal in terms of number of memory writes. It minimizes the number of memory writes to sort (Each value is either written zero times, if it’s already in its correct position, or written one time to its correct position.)
It is based on the idea that array to be sorted can be divided into cycles. Cycles can be visualized as a graph. We have n nodes and an edge directed from node i to node j if the element at i-th index must be present at j-th index in the sorted array. 
Cycle in arr[] = {2, 4, 5, 1, 3}

 

Cycle Sort : https://www.geeksforgeeks.org/cycle-sort/