Professional Documents
Culture Documents
Stack ADT
Stack ADT
Stack ADT
h>
//Pre-processor macro
#define stackCapacity 5
Q3: What are the advantages of using a stack for reversing a linked list?
Ans. Using a stack simplifies the process of reversing the linked list by taking
advantage of the LIFO property. It provides an intuitive and straightforward
solution that can be easily implemented.
Q4: Are there any drawbacks to using a stack for reversing a linked list?
Ans. Using a stack requires additional space to store the nodes, resulting in
increased space complexity. If the linked list is extremely large, it can lead to
memory limitations. In such cases, alternative methods like in-place reversal may
be more suitable.