trobert42 / push_swap

Sorting numbers with two stacks in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sorting integers with two stacks

The Push_swap project involves sorting an array of integers using two stacks and a set of instructions. The goal is to create a program that sorts the integers received as arguments. This project aims to teach basic algorithms, complexity concepts, and C language programming. The instructions include writing code in C, adhering to coding norms and properly freeing heap-allocated memory space. The stacks 'a' and 'b' contain unique integers, and the task is to sort stack 'a' in ascending order using instructions such as sa, sb, ss, pa, pb, ra, rb, rra, and rrb, which swap, push, and rotate elements within the stacks.

Project Name push_swap
Description A sorting algorithm using stacks with a limited set of instrutions and using the lowest possible number of actions
Technologies C
External libraries read(), write(), malloc(), free(), exit()

Usage

  gcl https://github.com/trobert42/push_swap.git
  cd push_swap
  make
  ./push_swap [list of numbers]

💬

Big thanks to Nicolas for helping me understand the LIS (Longest Increasing Subsequence), on which i based my sorting code on it o/

About

Sorting numbers with two stacks in C


Languages

Language:C 92.5%Language:Shell 5.6%Language:Makefile 1.9%