in DS
725 views
0 votes
0 votes
Can there be “Stack Overflow” in Linked list Implementation of stack? If Yes, how?
in DS
725 views

3 Comments

Theoretically, no. Practically, yes.

Every program is assigned a heap memory, where it can dynamically allocate memory if needed. Once it gets full (Heap Overflow), your ADT Stack won’t be able to create more nodes, thus creating Stack Overflow.
2
2

@DebSujit So no Stack Overflow right? That’s Heap Overflow. Or is it Stack Overflow because of Heap Overflow? But it sounds technically incorrect.

0
0
Stack Overflow because of Heap Overflow. Anyway, if this happens it equates to bad programming, as for any stack implementation there should be a upper bound, which checks and minimizes wastage of memory.
1
1

1 Answer

4 votes
4 votes
Best answer
Stack overflows are not expected to occur when a stack is implemented with a linked list. Although, it could occur if we ran out of memory in our machine.
selected by

Related questions