https://github.com/ejarvinen/42push_swap
Bucket-sort algorithm implementation with two stacks
https://github.com/ejarvinen/42push_swap
bucket-sort linked-list
Last synced: 4 months ago
JSON representation
Bucket-sort algorithm implementation with two stacks
- Host: GitHub
- URL: https://github.com/ejarvinen/42push_swap
- Owner: ejarvinen
- Created: 2024-04-03T07:45:31.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-02T18:49:10.000Z (5 months ago)
- Last Synced: 2025-02-02T19:34:09.095Z (5 months ago)
- Topics: bucket-sort, linked-list
- Language: C
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 42Push_swap
## Description
**Push_swap** is an algorithmic project designed to sort a stack of integers using a limited set of operations. The goal is to sort the numbers in ascending order with the minimum number of moves. This project has enhanced my understanding of sorting algorithms and their complexities. My implementation utilizes [bucket sort](https://en.wikipedia.org/wiki/Bucket_sort) to sort the two stacks and it's optimized for stack sizes <= 500.## Features
- Sorting using two stacks (`a` and `b`).
- Efficiently finding the shortest sequence of operations.
- Various operations including swap, push, rotate, and reverse rotate.## Available Operations
- `sa`, `sb`, `ss`: Swap the top two elements.
- `pa`, `pb`: Push from one stack to another.
- `ra`, `rb`, `rr`: Rotate stack (first becomes last).
- `rra`, `rrb`, `rrr`: Reverse rotate stack (last becomes first).## Installation
1. Clone the repository:
```
git clone https://github.com/ejarvinen/42Push_swap.git
cd 42Push_swap
```
2. Update and initialize submodules:
```
git submodule init
git submodule update
```
3. Build the project using the Makefile:
```
make
```
## Usage
To use `push_swap`, run the following command with a set of integers:
```
./push_swap 4 67 3 87 23
```