An open API service indexing awesome lists of open source software.

https://github.com/zainabdnaya/push_swap_42

sort data on a stack, with a limited set of instructions, using the lowest possible number of actions
https://github.com/zainabdnaya/push_swap_42

42 sort sort-data stacks swap

Last synced: about 1 year ago
JSON representation

sort data on a stack, with a limited set of instructions, using the lowest possible number of actions

Awesome Lists containing this project

README

          

# push_swap
sort data on a stack, with a limited set of instructions, using the lowest possible number of actions

## Explanation about The algorithm that I use :
algorithm push_swap
## To Test
Try to use : ./push_swap -h "this command will show what to do "
## Concept of this Project ##

The idea is simple, You have two stacks called Stack A and Stack B.

Stack A is given a random list of unorganized numbers.

You must take the random list of numbers in Stack A and sort them so that Stack A is organized from smallest to largest.

There are only a few moves you’re allowed to used to manipulate the stacks that we’re going to call “Actions”.

The main goal of this project is to organize Stack A in as few actions as possible.

## MOVES ##

the moves are named: sa, sb, ss, ra, rb, rr, rra, rrb, rrr, pa, pb.

I use Double linked list to implement these moves :

## sa || sb :arrows_clockwise: ##
-swap 2 first element
Screen-Shot-2021-04-03-at-12-44-32-PM
## :arrow_heading_up: ra || rb :arrow_right_hook: ##
-put the first element last,and all elemnt go UP by one
Screen-Shot-2021-04-03-at-2-51-42-PM

## :arrow_heading_down: rra || rrb :arrows_counterclockwise: ##
-put the last element First, so all elements go DOWN by ine element
Screen-Shot-2021-04-03-at-5-26-13-PM

## pa || pb :arrow_right: ##
-take the first element at the top of a stack and put it at the top of other_stack.
Screen-Shot-2021-04-03-at-6-41-55-PM
Screen-Shot-2021-04-04-at-3-27-57-PM

## Checker:
-Thanks to the checker program, you will be able to check if the
list of instructions you’ll generate with the program push_swap is
actually sorting the stack properly.

## This is how much instructions the algorithm Do with 100 random number
Screen-Shot-2021-04-11-at-2-46-15-PM

Screen-Shot-2021-04-11-at-2-33-56-PM