Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions sorting/selection_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#include <time.h>

/**
* Swapped two numbers using pointer
* Swap two integers using pointer
*
* @param first first pointer of first number
* @param second second pointer of second number
*/
Expand All @@ -21,9 +22,12 @@ void swap(int *first, int *second)
}

/**
* Selection sort algorithm implements
* Implements the Selection Sort algorithm.
*
* @param arr array to be sorted
* @param size size of array
* @param n NUmber of elements in the array
* Time Complexity:0(n^2)
* Space Complexity: O(1)
*/
void selectionSort(int *arr, int size)
{
Expand All @@ -39,7 +43,7 @@ void selectionSort(int *arr, int size)
}
if (min_index != i)
{
swap(arr + i, arr + min_index);
swap(&arr[i], &arr[min_index]);
}
}
}
Expand Down