I am learning the MIT course Introduction to Algorithms.

The professor is saying

In particular, as an example, position 2 is a peak if, and only if, b greater than or equal to a, and b greater than or equal to c. So it's really a very local property corresponding to a peak.

My question is, if an array if full of the same integer, like 0s, or 1s, are they all the peak of the array?


This is something you will encounter over and over, not just in science but also in engineering, in law, in programming, and generally in jargon. If there is a definition for a term, then that term means exactly what the definition says it means. No more. No less.

In particular, you may have an intuitive notion of what the term means in English, but this is not English. This is technical jargon. A "peak" doesn't mean what you think it means, it doesn't mean what it means in English, it means exactly what its definition says it means.

So, depending on the definition, all elements could be the peak, or there could be no peak, or any element could be the peak, or maybe it could even be the case that the question doesn't even make sense because there is some precondition to the definition of "peak" that doesn't apply in this case.

Look at the definition. Apply it. Ignore any intuition about what you think the answer should be. Trust the result.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.