translate pancakes sorting:

This commit is contained in:
CoderWang
2020-03-07 14:41:44 +08:00
parent 3784d6eea7
commit 48fbbab6af

View File

@ -107,10 +107,10 @@ The time complexity of the algorithm is easy to calculate, because the number of
Obviously, this result is not optimal (shortest). For example, a bunch of pancakes `[3,2,4,1]`. The flip sequence obtained by our algorithm is `[3,4,2,3,1,2]`, but the fastest way to flip should be ` [2,3,4] `: Obviously, this result is not optimal (shortest). For example, a bunch of pancakes `[3,2,4,1]`. The flip sequence obtained by our algorithm is `[3,4,2,3,1,2]`, but the fastest way to flip should be ` [2,3,4] `:
* Initial state: [3,2,4,1] * Initial state: `[3,2,4,1]`
* Turn over the first two: [2,3,4,1] * Turn over the first two: `[2,3,4,1]`
* Turn over the first three: [4,3,2,1] * Turn over the first three: `[4,3,2,1]`
* Turn over the first 4: [1,2,3,4] * Turn over the first 4: `[1,2,3,4]`
If your algorithm is required to calculate the **shortest** operation sequence for sorting biscuits, how do you calculate it? In other words, what is the core idea and what algorithm skills must be used to solve the problem of finding the optimal solution? If your algorithm is required to calculate the **shortest** operation sequence for sorting biscuits, how do you calculate it? In other words, what is the core idea and what algorithm skills must be used to solve the problem of finding the optimal solution?