This project aims to develop the most efficient algorithm to sort a sequence of numbers in the fewest possible steps. Using stack data structures, the sorting operation is optimized by transferring data between two stacks. Various sorting algorithms (Bubble Sort, Quick Sort, etc.) are evaluated, and the most suitable one is selected. The project provides insight into algorithm design and effective use of data structures while offering performance advantages. 🔍📊
The main goal of the Push_swap project is to develop the most effective algorithm to sort a given sequence of numbers with the minimum number of operations. This is achieved by using stack data structures and various sorting algorithms.
Stack structures play a crucial role in organizing and managing data during the sorting process. These structures operate on a "last in, first out" (LIFO) principle and are used to enhance the efficiency of sorting algorithms. By utilizing two separate stacks, data is transferred between them, making the sorting process more efficient and structured.
The project involves a detailed analysis of sorting algorithm performance. It includes simple algorithms (Bubble Sort, Insertion Sort) as well as more complex ones (Quick Sort, Merge Sort). Each method is evaluated for its advantages and disadvantages, helping determine which algorithm yields the best performance.
Push_swap offers deep insights into algorithm design, data structures, and performance optimization. Effective use of stacks and understanding algorithmic efficiency contribute significantly to software development skills and provide real-world benefits in terms of performance and scalability.
- Efficient Sorting: Develop an algorithm that can sort a given sequence of numbers in the fewest steps.
- Use of Stacks: Implement sorting using two separate stacks.
- Algorithm Optimization: Identify and apply the most optimal sorting algorithm.
Here are some of the main commands used in the Push_swap project:
sa
: Swap the first two elements of stacka
. 🔄sb
: Swap the first two elements of stackb
. 🔄pa
: Push the top element from stackb
to stacka
.↔️ pb
: Push the top element from stacka
to stackb
.↔️ ra
: Rotate all elements of stacka
upwards by one position. 🔁rb
: Rotate all elements of stackb
upwards by one position. 🔁rra
: Reverse rotate all elements of stacka
by one position. 🔙rrb
: Reverse rotate all elements of stackb
by one position. 🔙rr
: Rotate both stacksa
andb
upwards by one position. 🔁🔁rrr
: Reverse rotate both stacksa
andb
by one position. 🔙🔙
These commands are used within the sorting algorithm to manage the stacks and move data efficiently.
To run the Push_swap project, ensure the following:
- Unix-based operating system (Linux, macOS) 🖥️
- GCC compiler 🛠️
Follow these steps to run the project locally:
- Clone the repository:
git clone https://github.com/username/push_swap.git
- Navigate to the project directory:
cd push_swap
- Compile the project using the Makefile:
make
To perform a sorting operation, follow these steps:
- Run the program and pass the numbers you want to sort as arguments:
./push_swap [number1] [number2] [number3] ...
2025 This project was created by Derya ACAR.