applications of stacks and their uses?
Answer Posted / 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 View All Answers
What do you mean by 2-3 tree?
What are the disadvantages of circular list?
Explain quick sort?
Write is a binary search tree? Write an algorithm and tell complexity?
what is the difference between Linear Array and Linked List?
Describe avl tree or height balanced binary search tree.
Define rehashing?
Which interfaces are implemented by hashmap?
How to sort 1 million floating point numbers?
What are the types of queues?
List some applications of tree-data structure?
Write the stack overflow condition.
What is the use of sorting?
Define non-linear data structures?
How to check array contains value or not?