1
In a data structure proof I had the following question:
In a stack type data structure, the element that will be removed of the structure is the one that is stored
a) longer ago.
b) less time ago.
c) at the base of the structure.
d) in the structure header.
e) at the centre of the.
At the time of answering I was in doubt between:
b) less time ago.
d) in the structure header.
Mainly because I saw them as being equivalent, the element that is stored less time is stored at the top of the structure, which would be equivalent to the header, right?
Thus, it is incorrect to state that in a stack type data structure, the element that will be removed from the structure is the one that is stored in the stack header?
I believe it is not always true, because when the stack is implemented with a chained list, the header will be pointing to the top of the list, not necessarily to the last element of the stack. I’m just not sure if this is really it, I might be wrong about the header concept.
– Woss
@Andersoncarloswoss is even possible to implement a stack as a linked list, but it’s not a good idea. There are no advantages for the stack to have this chaining. Chaining does not solve an existing problem. There are disadvantages of memory consumption and processing. The best way to implement a stack is with a array simple.
– Maniero