Skip to content

The push_swap project is a sorting algorithm that sorts an array of integers using two stacks, stack A and stack B, and a set of predefined operations. The objective of the project is to sort the integers in stack A in ascending order using the minimum number of operations.

Notifications You must be signed in to change notification settings

UchihaShaco/Push_swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Push_swap

Project Overview

The push_swap project is a sorting algorithm that sorts an array of integers using two stacks, stack A and stack B, and a set of predefined operations. The objective of the project is to sort the integers in stack A in ascending order using the minimum number of operations.

The push_swap project consists of the following components:

Stack Operations

The push_swap algorithm uses the following stack operations to manipulate the stacks:

  • sa: Swap the first two elements of stack A.
  • sb: Swap the first two elements of stack B.
  • ss: Apply sa and sb simultaneously.
  • pa: Push the first element of stack B to the top of stack A.
  • pb: Push the first element of stack A to the top of stack B.
  • ra: Rotate stack A upward by one position.
  • rb: Rotate stack B upward by one position.
  • rr: Apply ra and rb simultaneously.
  • rra: Rotate stack A downward by one position.
  • rrb: Rotate stack B downward by one position.
  • rrr: Apply rra and rrb simultaneously.

Sorting Algorithm

The push_swap algorithm works by dividing the array of integers into chunks and pushing the integers onto stack A. The algorithm then sorts the integers in stack A by applying a series of stack operations.

The algorithm uses a combination of heuristics and optimization techniques to minimize the number of operations required to sort the integers. The push_swap algorithm can sort arrays of up to several hundred integers in a few seconds.

Conclusion

The push_swap project is a challenging and interesting project that requires skills in algorithm design, data structures, and stack operations. The project provides an excellent opportunity to develop problem-solving skills and to gain experience in writing efficient and optimized code.

About

The push_swap project is a sorting algorithm that sorts an array of integers using two stacks, stack A and stack B, and a set of predefined operations. The objective of the project is to sort the integers in stack A in ascending order using the minimum number of operations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published