Nikzy7 / Algorithm-Snippets

Repo containing snippets of popular algorithms
17 stars 36 forks source link

Implementing Pancake sort #40

Closed AlessandroArosio closed 4 years ago

AlessandroArosio commented 4 years ago

Implementing PancakeSort in Java language.

This algorithm takes the name because it resembles sorting pancakes with a big spatula, where the cook uses it to flip some of the pancakes on the top.

To achieve a correct sorting, the first step is to find the max element position (method findGreatestElement), then "flipping" the numbers until the max element position, and repeat.

issue #1