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

Why is quicksort faster than merge sort?

0 Answers  


What is default size of hashmap?

0 Answers  


What are the advantage of linked list over array?

0 Answers  


What is the average number of comparisons needed in a sequential search to determine the position of an element in an array of 100 elements, if the elements are ordered from largest to smallest?

19 Answers   ABB, SDE,


What is the difference between static and dynamic data?

0 Answers  






Is duplicate allowed in hashmap?

0 Answers  


Is hashmap part of collection?

0 Answers  


Is hashmap keyset ordered?

0 Answers  


What is unhashable type list?

0 Answers  


What is a undirected graph?

0 Answers  


What are types of Collision Resolution Techniques and the methods used in each of the types?

0 Answers  


Why is sorting important?

0 Answers  


Categories