diff options
| author | yctct <yctct@yctct.com> | 2026-04-16 18:25:12 +0200 |
|---|---|---|
| committer | yctct <yctct@yctct.com> | 2026-04-16 18:25:12 +0200 |
| commit | 40ad9bfe202f72a5b52eed8ff38da9b27de12adb (patch) | |
| tree | 3191366496651b9b4cbb213aec0966f24984333a /README | |
Diffstat (limited to 'README')
| -rw-r--r-- | README | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -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 |
