The pancake algorithm. can somebody explain this more clearly to me?

351 views

I understand if you keep flipping the largest pancake, you will eventually put it in order assuming there are only five pancakes.

But when they say this, I get lost and kinda scared.

How is 2(n-2)+1 = 2n-3

Pn <= 2n-3

New to programming, and trying to understand what these numbers mean.

In: 2

2 Answers

Anonymous 0 Comments

>How is 2(n-2)+1 = 2n-3

Pn <= 2n-3

New to programming, and trying to understand what these numbers mean.

Those don’t have anything specifically to do with programming, they’re just mathematical statements about the pancake algorithm.

>2(n-2)+1 = 2n-3

That’s just a mathematical equation.

2(n-2)+1

2n – 4 + 1

2n – 3

>Pn <= 2n-3

This is just a statement that says the pancake number (Pn) for any given number of pancakes (n) will always be less than or equal to 2n-3.

So if you have 7 pancakes, the pancake number will be less than or equal to 2*7-3 = 14-3 = 11.

You are viewing 1 out of 2 answers, click here to view all answers.