MCPcopy Create free account
hub / github.com/TheAlgorithms/Rust / insertion_sort

Function insertion_sort

src/sorting/insertion_sort.rs:5–17  ·  view source on GitHub ↗

Sorts a mutable slice using in-place insertion sort algorithm. Time complexity is `O(n^2)`, where `n` is the number of elements. Space complexity is `O(1)` as it sorts elements in-place.

(arr: &mut [T])

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 8

bucket_sortFunction · 0.70
emptyFunction · 0.70
one_elementFunction · 0.70
already_sortedFunction · 0.70
basicFunction · 0.70
odd_number_of_elementsFunction · 0.70
repeated_elementsFunction · 0.70
tim_sortFunction · 0.70

Calls 1

lenMethod · 0.45

Tested by 6

emptyFunction · 0.56
one_elementFunction · 0.56
already_sortedFunction · 0.56
basicFunction · 0.56
odd_number_of_elementsFunction · 0.56
repeated_elementsFunction · 0.56