answersLogoWhite

0

A Linked-List is basically a series of Nodes. Each Node contains two things: The contents, and the pointer to the next Node in the Linked-List. So you can traverse the Linked-List by following the "next" pointers in each Node, a bit like following road directions from city to city.

A stack is an abstract data type where you have two operations: "push" and "pop". Pushing means to put an item in the stack, Popping means to get the first element of the stack. When you push an item onto a stack, you put the item at the top: so its like cutting in line to the very front. The last one in is now first, and thus, the first one out. Another helpful image is a "stack" of trays at a cafeteria -- you can only get the tray from the top of the stack, or put a tray on top of the stack. The very first tray in the stack is actually the one at the very bottom, and thus, the last one to be used. "First in, Last Out."

A stack deals with what comes first/last, while a Linked-List describes how data is stored. A stack needs to store data, so a stack can be implemented as a Linked-List.

User Avatar

Wiki User

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

BeauBeau
You're doing better than you think!
Chat with Beau
SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa
More answers

Stacks don't have to be implemented using linked lists. A stack can also be implemented using an array which makes better use of memory. Linked lists have the advantage in that they can grow and shrink dynamically which can often improve stack performance. To achieve similar performance with an array you must allocate more memory than is required each time the array grows, typically by doubling the size of the allocation.

User Avatar

Wiki User

8y ago
User Avatar

The stack is a memory structure where your programs can store data. The stack pointer is the variable that "points" to the current location of the top of the stack.

User Avatar

Wiki User

16y ago
User Avatar

Add your answer:

Earn +20 pts
Q: Why stack is implemented by link list?
Write your answer...
Submit
Still have questions?
magnify glass
imp