From 40ad9bfe202f72a5b52eed8ff38da9b27de12adb Mon Sep 17 00:00:00 2001 From: yctct Date: Thu, 16 Apr 2026 18:25:12 +0200 Subject: First commit --- README | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 README (limited to 'README') diff --git a/README b/README new file mode 100644 index 0000000..1951da5 --- /dev/null +++ b/README @@ -0,0 +1,53 @@ +sort_stack +========= + +Description +---------- + +Brief overview: the program takes in a list of integer arguments and sort them. + +I put this program together to learn: + +- how to choose an algorithm +- how to implement an algorithm +- how to optimize an algorithm +- how to use linked list + +About linked lists: I understand that linked lists is not optimal for this use since elements are not contigious. It would expensive to use linked lists to solve such problem. + +This program uses: + +- my own interpretation of the "turk algorithm" when there are more than 5 elements to sort +- the "mini-turk" algorithm when there are 4 or 5 elements +- hard-coded algorithms when there are 2 or 3 elements + +Improvement: + +- I could further optimize the choice of element to move by taking both costs, of stack A and stack B, into consideration. + +## Instructions + +Build the program: + + make + +Run the program: + + bin/push_swap [arguments] + +Delete objects files: + + make clean + +Delete objects files and program: + + make fclean + +Recompile: + + make re + +## Resources + +- https://medium.com/@ayogun/push-swap-c1f5d2d41e97 +- Harvard CS50 lecture on data structures -- cgit v1.2.3