Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Stack Class help

indianjindianj Posts: 20Member
hi, i was going through java exercise and i did not understand this exercise. if you know anything, please post your comment here.

In the linked list implementation of the stack class, where does teh push method place the new entry on the linked list?

A. At the head
B. At the tail
C. After all other entries that are greater than the new entry.
D. After all other entries that are smaller than the new entry.

thanks
harry

Comments

  • VilanyeVilanye Posts: 684Member
    : hi, i was going through java exercise and i did not understand this exercise. if you know anything, please post your comment here.
    :
    : In the linked list implementation of the stack class, where does teh push method place the new entry on the linked list?
    :
    : A. At the head
    : B. At the tail
    : C. After all other entries that are greater than the new entry.
    : D. After all other entries that are smaller than the new entry.
    :
    : thanks
    : harry
    :

    Stacks have no concept of greater then or less then. Whether it is a or b depends on the method, although find how mew nodes are generally added to the list and that will be the likely answer.
    [italic][blue]Just my 2 bits[/blue][/italic]

  • electra_prelectra_pr Posts: 9Member
    : : hi, i was going through java exercise and i did not understand this exercise. if you know anything, please post your comment here.
    : :
    : : In the linked list implementation of the stack class, where does teh push method place the new entry on the linked list?
    : :
    : : A. At the head
    : : B. At the tail
    : : C. After all other entries that are greater than the new entry.
    : : D. After all other entries that are smaller than the new entry.
    : :
    : : thanks
    : : harry
    : :

    first you have to imagine the stack..
    a stack is like a stack of dishes where you put a new dish at the top of the stack.that means above all..
    a Stack can be expressed as LIFO which means Last In First Out because you remove the top object of the stack(the one that you pushed last).
    now as it concerns the linked list, the answer to your question is either a or b (it depends on what do you mean head and tail of the list...if you push a node after tail and delete the last node then the answer is "tail" or if you push before the head and delete the first node then the answer is "head")..
    i hope that this answer helps you and do well on your exercise!

Sign In or Register to comment.