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


Please Help Members By Posting Answers For Below Questions

What do you mean by 2-3 tree?

507


What are the disadvantages of circular list?

501


Explain quick sort?

568


Write is a binary search tree? Write an algorithm and tell complexity?

516


what is the difference between Linear Array and Linked List?

584






Describe avl tree or height balanced binary search tree.

518


Define rehashing?

615


Which interfaces are implemented by hashmap?

518


How to sort 1 million floating point numbers?

680


What are the types of queues?

580


List some applications of tree-data structure?

492


Write the stack overflow condition.

590


What is the use of sorting?

515


Define non-linear data structures?

565


How to check array contains value or not?

580