https://github.com/hima890/sorting_algorithms
Explore various sorting algorithms implemented in C within this repository. Each algorithm, such as Bubble Sort, Insertion Sort, Selection Sort, and Quick Sort, is meticulously crafted in separate C files. Witness these algorithms in action as they sort arrays or linked lists, with printed outputs after each step.
https://github.com/hima890/sorting_algorithms
algorithms alx alx-africa alx-low-level-programming data-structures search-algorithm
Last synced: 2 months ago
JSON representation
Explore various sorting algorithms implemented in C within this repository. Each algorithm, such as Bubble Sort, Insertion Sort, Selection Sort, and Quick Sort, is meticulously crafted in separate C files. Witness these algorithms in action as they sort arrays or linked lists, with printed outputs after each step.
- Host: GitHub
- URL: https://github.com/hima890/sorting_algorithms
- Owner: hima890
- License: mit
- Created: 2024-05-02T06:49:18.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-02T14:27:34.000Z (about 1 year ago)
- Last Synced: 2024-12-25T15:41:52.481Z (4 months ago)
- Topics: algorithms, alx, alx-africa, alx-low-level-programming, data-structures, search-algorithm
- Language: C
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Sorting Algorithms
This repository contains implementations of various sorting algorithms in C. Each sorting algorithm is implemented in a separate C file and is tested with example arrays or linked lists.
## Table of Contents
- [Bubble Sort](#bubble-sort)
- [Insertion Sort](#insertion-sort)
- [Selection Sort](#selection-sort)
- [Quick Sort](#quick-sort)## General Requirements
- Code is written in C language.
- All code is compiled on Ubuntu 20.04 LTS using gcc.
- The code follows the Betty style.
- Global variables are not allowed.
- Each C file contains no more than 5 functions.
- The standard library is not used unless specified otherwise.
- Header files are included with include guards.
- A README.md file is included at the root of the project folder.
- All header files contain prototypes of functions.
- List and array sizes less than 2 are not sorted.
- There is one project repository per group.## Sorting Algorithms
### Bubble Sort
- Prototype: `void bubble_sort(int *array, size_t size);`
- Sorts an array of integers in ascending order using the Bubble sort algorithm.
- Prints the array after each swap.### Insertion Sort
- Prototype: `void insertion_sort_list(listint_t **list);`
- Sorts a doubly linked list of integers in ascending order using the Insertion sort algorithm.
- Prints the list after each swap.### Selection Sort
- Prototype: `void selection_sort(int *array, size_t size);`
- Sorts an array of integers in ascending order using the Selection sort algorithm.
- Prints the array after each swap.### Quick Sort
- Prototype: `void quick_sort(int *array, size_t size);`
- Sorts an array of integers in ascending order using the Quick sort algorithm with the Lomuto partition scheme.
- Prints the array after each swap.## Big O Notations
For each sorting algorithm, the time complexity in the best case, average case, and worst case is provided in separate files named `0-O`, `1-O`, `2-O`, and `3-O`, respectively.
## Usage
To test each sorting algorithm, compile the corresponding C files along with the main file and execute the compiled program.
For example:
```bash
gcc -Wall -Wextra -Werror -pedantic -std=gnu89 0-bubble_sort.c 0-main.c print_array.c -o bubble_sort
./bubble_sort### Authors
Ibrahim Hanafi