Skip to content

samitmohan/sorting_library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Objective : Sorting Library in C.

Goals -> To make a sorting library (sort.h) which you can include in your C program just like other library functions (stdio.h, string.h etc) and use all kinds of sorting without the need to implement them individually.

Why? Because all other programming languages already have this function built in, it's time C does too.

Python -> sort() function, C++ STL -> sort(arr.begin(), arr.end()), Java Framework Libray -> sort() function.

Where as C (being a very fundamental and old langauge) does not have an inbuilt sorting library.


What is an algorithm

-> Set of instructions in a procedural/sequential way to build/solve a problem

What is a sorting algorithm?

Sorting algorithm is used to re-arrange a given array/vector/list of elements according to a comparision operator(ascending or descending)

Types of sort in sort.h

-> Bubble Sort -> Insertion Sort -> Selection Sort -> Merge Sort -> Quick Sort -> Cyclic Sort -> Heap Sort

Complexity

-> Time Complexity -> Space Complexity

Stability

-> Is the algorithm stable or not?

File Handling

-> Read file num.txt containing of numbers of size n (given by user) -> Pass file to sort function -> Return file with sorted numbers

Github

-> Upload all files to github, (deployment) -> Learning git requests and how to collaborate with people.

Implementation

To run -> Make sure all files are in the same folder, run via preferred editor/IDE

Case 1 : Take input array from the user.

Output

Case 1

Case 2 : Array already given by the user.

Output

Case 2

Case 3 : File Handling -> num.txt file given with n numbers, sort the file.

Text File

Case 3, text file

Output

Case 3

Websites used for reference

https://www.interviewbit.com/tutorial/sorting-algorithms/ https://www.bigocheatsheet.com https://www.quora.com/How-do-you-make-your-own-libraries-in-C-programming https://www.geeksforgeeks.org/how-to-measure-time-taken-by-a-program-in-c/ https://computer.howstuffworks.com/c15.htm

About

fun project in C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages