Push_swap is a sorting algorithm project that aims to sort a stack of integers using a limited set of operations while minimizing the number of moves. The goal is to implement two programs: one that checks if a given list of instructions sorts the stack, and another that generates the list of instructions to sort the stack.
The push_swap program uses a sorting algorithm that involves manipulating two stacks, commonly referred to as Stack A and Stack B. The algorithm follows a combination of operations like pushing, rotating, reverse rotating, and swapping elements between the two stacks to sort the numbers. To do this project, I've implemented the Turk Algorithm, an optimization algorithm created by Ali Yigit Ogun: a student from 42 Heilbronn school.
Follow the steps below to test the project:
- Clone the repository:
git clone https://github.com/your-username/push_swap.git
- Compile the project:
make
- Run the program with the following syntax:
./push_swap num1 num2 num3 num4 num5
- num: unique numbers in a non-ascending order.
./push_swap 8 5 2 4 9 1 3
To better understand the algorithm and operations done in the push_swap project you can download a GUI to experience a visual demonstration.