This project has been created as part of the 42 curriculum by alauer.
Table of Contents
- Description
- Instructions
- Resources
The pushswap project is an educational project of the 42 curriculum to deepen foundational knowledge in algorithms, time complexity and potentially bitwise operations. The project consists of a sorting problem, where students are expected to sort a list of unique integers of variable size, with given operations in a specific number of operations.
For my implementation I have chosen to represent the two stacks as two doubly linked lists. After the input is sanitized, I normalize it by list rank and then sort them in 3 steps to achieve the required op count. I hardcoded specific operations for up to 5 list items, as they dont differ and used an binary LSD radix sort for anything bigger than n = 5. As this algorithm struggles in very low items, the hardcoded operations for n <= 5 provided the necessary speed up to match the requirements.
Compilation
make - compile the program
make clean - clean object files
make fclean - clean object files and library
make re - clean and make
Testing
Use the tester provided by 42 or https://github.com/gemartin99/Push-Swap-Tester for an extended overview.
Binary LSD Radix Sort: https://www.cs.cornell.edu/courses/JavaAndDS/files/sort7Radix.pdf https://yuminlee2.medium.com/radix-sort-algorithm-764a260f2a04
Doubly Linked Lists: https://medium.com/@Dev_Frank/c-linked-list-doubly-linked-list-561851cd732a
Algorithms and Time Complexity: https://nostarch.com/algorithmic-thinking-2nd-edition https://www.geeksforgeeks.org/dsa/understanding-time-complexity-simple-examples/
AI (Claude) was used in this project to get a lead on debugging, after I tried debugging with printf, my own tests, the aforementioned testers and gdb.