Peek

verb

say it: “PEEK” /pik/

Reading the next item of a stack or a queue without removing it.

What is peek on a stack or a queue?

Peek reads the item a stack or a queue would hand out next, without removing it: the top of a stack, or the front of a queue. Like glancing at who's next in line, it's O(1) and changes nothing.

In a sentence

  • “The barista can peek at the next order without taking it off the screen.”

Level: Apprentice · More Data Structures terms at this level

Updated