• Gnome Sort, also known as Stupid Sort, is a sorting algorithm that is conceptually simple but inefficient for large datasets.

    Time Complexity

    • Best Case: O(n) - If the list is already sorted, because it only needs to traverse the list once.

    • Average Case: O(n^2)

    • Worst Case: O(n^2) - It happens when list is reversed.

    Space complexity: O(1) - it is in place sorting algorithm, which means it requires only constact amount of extra space.

    It is mainly used for conceptual or educational purposes, due to inneficient performance with large datasets.

    Type Parameters

    • TElement extends string | number

    Parameters

    • arr: TElement[]

      passed array of string or numbers

    Returns TElement[]

    return sorted array

Generated using TypeDoc