Johannes Baum
Nov 17, 2020

While one could argue whether the naming should be head or tail, in my implementation peek should deliver the tail.

The reason is that a peek should return the item in the queue, that a dequeue operation would remove from it.

If you need a LIFO data structure (which has a peek just as you described) you should use a stack.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Johannes Baum
Johannes Baum

Written by Johannes Baum

Creator of GridEngine (https://github.com/Annoraaq/grid-engine) 👾 Software Engineer 🚀 JavaScript/TypeScript

No responses yet

Write a response