Is it 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 header?

Asked

Viewed 104 times

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.

  • 1

    @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.

1 answer

1


You would need to define what a header is. A stack has no header. So either you’re talking about something else in this hypothetical answer or you’re using the term in an unusual way, at least for me.

I think it’s even talking about stack in option d.

The only one that makes sense is the b.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.