applications of stacks and their uses?



applications of stacks and their uses?..

Answer / shreyank

Keeping track of nested invocation calls in a procedural
programming language, such as C/C++.
Each function call results in a new entry being placed into
the program run-time stack. This new
entry contains memory space for local variables (which can
grow dynamically) and for a return
pointer to the instruction in the function that invoked the
current function (caller/callee). As
functions terminate, their stack entry is "popped out," with
the return values written to the proper
location in the caller.
Since nested procedural/ function invocation levels are
entered and exited in LIFO order, a stack
is the most appropriate data structure to handle this
functionality.
Evaluating arithmetic expressions.
Stacks can be used to parse arithmetic expressions and
evaluate them efficiently, as we shall
see as part of this assignment.
To eliminate the need for direct implementation of recursion.
As recursive function calls require a lot of overhead, it is
often the case that recursive algorithms
are "unrolled" into non-recursive ones. Since recursive
calls are entered/exited in LIFO order the
use of stacks to mimic recursion is a natural choice.

Is This Answer Correct ?    6 Yes 0 No

Post New Answer

More Data Structures Interview Questions

What is unmodifiable list?

1 Answers  


Difference between calloc and malloc in data structures?

1 Answers  


What happens when arraylist is full?

1 Answers  


Does linked list allow null values?

1 Answers  


What are linked lists used for?

1 Answers  


Write a Program for Insert in a sorted list

1 Answers  


Define an abstract data type (adt)?

1 Answers  


Does hashmap maintain insertion order?

1 Answers  


What do you mean by Runtime Error

1 Answers  


What is data structure and why it is important?

1 Answers  


Does treemap allow null key?

1 Answers  


What is bubble sort technique?

1 Answers  


Categories