This repo contains implementation of several sorting algorithms for both arrays or linked lists.
First, I recommend to test your skills in time complexity (Big O notation) by passing his exam (will update soon)
The following algorithms are commonly used for sorting data in various applications.
-
Insertion Sort (Arrays - Doubly linked list)
-
Shell sort
-
Cocktail shaker sort
-
Counting sort
-
Merge sort
-
Heap sort
-
Radix sort
-
Bitonic sort
-
Quick Sort - Hoare Partition scheme
Helper Functions and files
- Header file
sort.h
- swap
- swap_nodes
- create_list_from_array
This section will be updated over the time.
Building the Project
-
Clone this repository to your local machine.
-
Change to
sorting_algorithms
directory: -
Compile the project:
gcc *.c -o a ./a
Sorting Arrays
To sort an array using one of the implemented algorithms, you can call the respective sorting function and provide your array and its size as parameters. For example, to sort an array using Bubble Sort:
int array[] = {5, 2, 9, 3, 6};
size_t size = sizeof(array) / sizeof(array[0]);
bubble_sort(array, size);
Sorting Linked Lists
To sort a linked list, you can create a list from an array and then call the sorting function for linked lists. For example:
int array[] = {5, 2, 9, 3, 6};
size_t size = sizeof(array) / sizeof(array[0]);
listint_t *list = create_listint(array, size);
insertion_sort_list(&list);
Contributions to this project are welcome. If you'd like to contribute, please fork the repository, make your changes, and submit a pull request. Be sure to follow best practices and maintain code quality.
Feel free to customize this README
file further to include more project-specific details or instructions as needed.