Skip to content

This project aims to develop the most efficient algorithm to sort a sequence of numbers in the fewest steps possible. The sorting process is optimized using stack data structures, and data is transferred between two stacks. Various sorting algorithms (Bubble Sort, Quick Sort, etc.) are evaluated to select the most suitable one. The project provides

Notifications You must be signed in to change notification settings

deryaxacar/42-Push_swap

Repository files navigation

42 - Push_swap 🧮

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. 🔍📊

🎯 Project Objective

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.

📈 Key Goals

  • 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.

💡 Commands Used

Here are some of the main commands used in the Push_swap project:

  • sa: Swap the first two elements of stack a. 🔄
  • sb: Swap the first two elements of stack b. 🔄
  • pa: Push the top element from stack b to stack a. ↔️
  • pb: Push the top element from stack a to stack b. ↔️
  • ra: Rotate all elements of stack a upwards by one position. 🔁
  • rb: Rotate all elements of stack b upwards by one position. 🔁
  • rra: Reverse rotate all elements of stack a by one position. 🔙
  • rrb: Reverse rotate all elements of stack b by one position. 🔙
  • rr: Rotate both stacks a and b upwards by one position. 🔁🔁
  • rrr: Reverse rotate both stacks a and b by one position. 🔙🔙

These commands are used within the sorting algorithm to manage the stacks and move data efficiently.

📋 Requirements

To run the Push_swap project, ensure the following:

  • Unix-based operating system (Linux, macOS) 🖥️
  • GCC compiler 🛠️

🔧 Installation

Follow these steps to run the project locally:

  1. Clone the repository:
    git clone https://github.com/username/push_swap.git
  2. Navigate to the project directory:
    cd push_swap
  3. Compile the project using the Makefile:
    make

🗸 Usage

To perform a sorting operation, follow these steps:

  1. 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.

About

This project aims to develop the most efficient algorithm to sort a sequence of numbers in the fewest steps possible. The sorting process is optimized using stack data structures, and data is transferred between two stacks. Various sorting algorithms (Bubble Sort, Quick Sort, etc.) are evaluated to select the most suitable one. The project provides

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published