Skip to content

ocrossi/push_swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

push_swap

Screenshot

Subject is in the code session.

This subject is about coding a sorting algorithm with a limit set of instructions. It introduces the concept of complexity in algorithmics.

My algorithm is divided in 2 parts.

For the low level piles (20 or lower) i apply the sorting algorithm adapted to push swap instructions. It consists in storing on b the numbers by decrescent number the inputs, quick sort A pile when it's 3 elements long and then push on a the numbers stored on b.

The bigger level of this algorithm is a divide and conquer strategy.

Divide input in pockets of numbers according to the median of the pile, adapted each iteration of divide groups. Repeat until it comes to the low level case.

Apply low level case

keep splitting median groups if needed

To compile the code you will need GNU Make and gcc installed. you can execute the scripts in the script folder with bash installed too

Usage:

Clone the the repo, enter the directory cloned

  1. make

Screenshot

  1. ./scripts/complexity (1st arg pile size 2nd number of test)

Screenshot

  1. ./scripts/test.sh [input 1] [input2] (1st number 2nd number)

Screenshot

  1. ./push_swap [input] | ./checker [input]

Screenshot

I did not code the complexity script.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors