Misleading statement in Stacks intro

While learning linear data structures, I find the intro to Stacks misleading. It states “Like a queue, a stack is a linear collection of nodes that adds (pushes) data to the head, or top, of the stack” but I thought a queue can only add to the tail.
And again “unlike a queue, a stack removes data (pops) from the head of the stack.” I also think a queue as well removes from the head… I am a bit confused :confused:

I think the key emphasis is that it’s a linear collection (that’s the point in common).

I do agree it doesn’t sound very clear.

The term “head” could be misleading but it still holds and works with some implementations (but not others). For example, if it’s implemented as a linked list, then the head is indeed the point of contact. If it’s implemented with a dynamic array, the tail would be the point of contact. But still there’s very little room for ambiguity because stacks really only interact at a time with their structure, if you call it tail or head: it’s still going to be the same item. Still… it should be clarified.

Out of curiosity, could you link to the exercise where you saw this explanation?

2 Likes

Here is the link and a screengrab
https://www.codecademy.com/paths/front-end-engineer-career-path/tracks/fecp-22-linear-data-structures/modules/wdcp-22-stacks/informationals/stacks-informational

I’ll share this and see what they say!

thanks @toastedpitabread and @bunmi2020 ! I shared this feedback with the curriculum team and they’ll take a look at how to make it better :+1:

3 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.