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

Where is insertion sort used?

0 Answers  


Which sort show the best average behavior?

9 Answers  


What is complete binary tree in data structure?

0 Answers  


What are the parts of root node?

7 Answers   BMC, JCE, TCS,


How to find middle element of linked list in one pass?

0 Answers  






What is array and its types in data structure?

0 Answers  


What are linear and non linear data structures?

0 Answers  


What is the default capacity of hashmap?

0 Answers  


How to get a list of tables, views and columns in firebird database?

0 Answers  


List out the basic operations that can be performed on a stack?

0 Answers  


What is the minimum number of queues needed when implementing a priority queue?

0 Answers  


Does arraylist maintain order?

0 Answers  


Categories