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

Describe full binary tree and complete binary tree.

491


What is a sorting algorithm in data structure?

475


Which is faster hashmap or hashtable?

505


Is set sorted?

487


How hashmap increases its size?

566






What type of memory allocation is referred for Linked lists?

802


What is mean by sorting?

500


What is entryset method in map?

465


What is the difference between Strings and Arrays?

522


Which method will arrange the element of an array in alphabetical order?

1562


Describe tree database. Explain its common uses.

543


How do you access the values within an array?

610


What is different between array and list?

482


Explain the difference between hashset and hashmap?

523


How does insertion sort works?

504