Skip to content

Sorting algorithm using two stacks and a limited amount of moves upon shifting numbers around.

Notifications You must be signed in to change notification settings

tihendri/push_swap

Repository files navigation

The Push_swap project is a very simple and highly effective algorithm project: data will need to be sorted. You have at your disposal a set of int values, 2 stacks and a set of instructions to manipulate both stacks.

My goal ? Write 2 programs in C:

• The first, named checker which takes integer arguments and reads instructions on the standard output. Once read, checker executes them and displays OK if integers are sorted. Otherwise, it will display KO.

• The second one called push_swap which calculates and displays on the standard output the smallest progam using Push_swap instruction language that sorts integer arguments received.

To write a sorting algorithm is always a very important step in a coder’s life, because it is often the first encounter with the concept of complexity.

Sorting algorithms, and their complexities are part of the classic questions discussed during job interviews. It’s probably a good time to look at these concepts because you’ll have to face them at one point.

The learning objectives of this project are rigor, use of C and use of basic algorithms. Especially looking at the complexity of these basic algorithms.

Sorting values is simple. To sort them the fastest way possible is less simple, especially because from one integers configuration to another, the most efficient sorting algorithm can differ.

Instructions for creating project:

-Global variables are forbidden. -Your project must be written in C in accordance with the Norm. -You have to handle errors in a sensitive manner. In no way can your program quit in an unexpected manner (Segmentation fault, bus error, double free, etc). -Neither program can have any memory leaks. -Within your mandatory part you are allowed to use the following functions: ◦ write ◦ read ◦ malloc ◦ free ◦ exit

About

Sorting algorithm using two stacks and a limited amount of moves upon shifting numbers around.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published