Giter Site home page Giter Site logo

ahaddad98 / push_swap Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 446 KB

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

C 95.87% Makefile 4.13%
push-swap c sort quick-sort-algorithm

push_swap's Introduction

push_swap

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

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 🔃

-swap 2 first element

Screen-Shot-2021-04-03-at-12-44-32-PM

⤴️ ra || rb ↪️

-put the first element last,and all elemnt go UP by one 

Screen-Shot-2021-04-03-at-2-51-42-PM

⤵️ rra || rrb 🔄

-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 ➡️

-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 instriction 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

push_swap's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.