How ahmadnajikam/push_swap works
Push_Swap is a command-line sorter: it validates integer arguments, builds two linked-list stacks, selects a requested or adaptive strategy, then emits allowed stack operations for an external checker to execute. The documented strategies are selection sort, chunk sort, and radix sort; adaptive behavior and benchmarking are also represented. Source excerpts establish the main routing, validation, operations, and strategy calls. The adaptive and benchmark internals are unsampled, so their detailed links are omitted.
Main entry points: parsing.c Stack initialization · push_swap_ops.c Stack operations · main.c Program entry · rotate_ops.c Rotation operations
Components 17
Input and validation
- Program entry
main.c - Argument validation
error_handling/check_errors.c - Mode selection
mode/mode_handling.c - Number parsing
utils/handle_numbers.c
Sorting runtime
- Stack initialization
utils/parsing.c - Linked-list stacks
utils/stack_utils.c - Index preparation
algorithms/general_utils.c - Stack operations
operations/push_swap_ops.c - Rotation operations
operations/rotate_ops.c
Sorting strategies
- Selection strategy
algorithms/simple/simple.c - Chunk strategy
algorithms/medium/medium.c - Radix strategy
algorithms/complex/complex.c - Adaptive strategy
algorithms/adaptive/adaptive.c
Output and metrics
- Benchmark metrics
bench/bench.c - Formatted output
utils/ft_dprintf/ft_dprintf.c
Other components
- CLI user
- External checker
Connections 23
- CLI user → Program entry: runs
README.md - Program entry → Argument validation: validates
main.c - Argument validation → Mode selection: checks flags
error_handling/check_errors.c - Argument validation → Number parsing: checks numbers
error_handling/check_errors.c - Program entry → Stack initialization: parses arguments
main.c - Stack initialization → Linked-list stacks: builds stacks
utils/parsing.c - Stack initialization → Index preparation: fills indices
utils/parsing.c - Stack initialization → Mode selection: selects mode
utils/parsing.c - Stack initialization → Selection strategy: dispatches
utils/parsing.c - Stack initialization → Chunk strategy: dispatches
utils/parsing.c - Stack initialization → Radix strategy: dispatches
utils/parsing.c - Stack initialization → Adaptive strategy: dispatches
utils/parsing.c - Selection strategy → Stack operations: pushes/swaps
algorithms/simple/simple.c - Selection strategy → Rotation operations: rotates
algorithms/simple/simple.c - Chunk strategy → Stack operations: pushes
algorithms/medium/medium.c - Chunk strategy → Rotation operations: rotates
algorithms/medium/medium.c - Radix strategy → Stack operations: pushes
algorithms/complex/complex.c - Radix strategy → Rotation operations: rotates
algorithms/complex/complex.c - Stack operations → Formatted output: prints moves
operations/push_swap_ops.c - Rotation operations → Formatted output: prints moves
operations/rotate_ops.c - Stack initialization → Benchmark metrics: records benchmark
- Stack operations → External checker: emits operations
README.md - Program entry → Formatted output: reports errors
main.c