This project aims to sort a list of integers using a limited set of operations on two stacks (a and b).
An efficient sorting algorithm must be implemented, considering its complexity (Big O notation).
- Rules:
all,clean,fclean,re. - Must not relink files under any circumstances.
push_swap.c: Main function of the program.check_error_free.c: Validations and memory management.utils.c: Auxiliary functions for handling lists.utils_extra.c: General utility functions.path_to_sort.c: Algorithms for sorting small lists.algo.c: Implementation of the sorting algorithm (Radix).push.c: Functions to move elements between stacks.swap.c: Swap functions.rotate.c: Functions for rotating elements.reverse_rotate.c: Functions for reverse rotation.
- The program works with two stacks (
aandb). - Initially,
acontains unsorted numbers, andbis empty. - The objective is to sort
ain ascending order with the fewest moves possible. - Only a limited set of operations can be used (
sa,sb,ss,pa,pb,ra,rb,rr,rra,rrb,rrr).
Radix Sort has been implemented, optimized with bitwise operators to reduce the number of buckets and improve performance.
Each number is processed by analyzing its bits and distributing them into stacks efficiently until they are sorted in ascending order.
read,write,malloc,free,exit.ft_printfand any other function from libft.
A checker is included to verify if the generated instruction sequence correctly sorts the stack. The bonus part consists in making your own checker.
This project has been a practical introduction to complexity analysis and algorithm optimization. Big O notation has been studied, different sorting strategies have been explored, and an efficient solution using bitwise operations has been implemented.
