![]() Balanced Parenthesis Stack: This type of stack is used to check the balance of parentheses in an expression.Memory Management Stack: This type of stack is used to store the values of the program counter and the values of the registers in a computer program, allowing the program to return to the previous state when a function returns.Recursion Stack: This type of stack is used to keep track of function calls in a computer program and to return control to the correct function when a function returns.Expression Evaluation Stack: This type of stack is used to evaluate postfix expressions.Infix to Postfix Stack: This type of stack is used to convert infix expressions to postfix expressions.In addition to these two main types, there are several other variations of Stacks, including: This type of stack is implemented using a linked list, as it allows for easy resizing of the stack. When the stack is full, it automatically increases its size to accommodate the new element, and when the stack is empty, it decreases its size. Dynamic Size Stack: A dynamic size stack can grow or shrink dynamically.If the stack is empty and an attempt is made to remove an element from it, an underflow error occurs. If the stack is full and an attempt is made to add an element to it, an overflow error occurs. Fixed Size Stack: As the name suggests, a fixed size stack has a fixed size and cannot grow or shrink dynamically.So, it can be simply seen to follow the LIFO/FILO order. the plate which has been placed at the bottommost position remains in the stack for the longest period of time. The plate which is at the top is the first one to be removed, i.e. Consider the simple example of plates stacked over one another in a canteen. There are many real-life examples of a stack. Software Engineering Interview QuestionsĮnd procedure Understanding stack practically:.Top 10 System Design Interview Questions and Answers.Top 20 Puzzles Commonly Asked During SDE Interviews.Commonly Asked Data Structure Interview Questions.Top 10 algorithms in Interview Questions.Top 20 Dynamic Programming Interview Questions.Top 20 Hashing Technique based Interview Questions.Top 50 Dynamic Programming (DP) Problems. ![]() Top 20 Greedy Algorithms Interview Questions.Top 100 DSA Interview Questions Topic-wise.Hence, we will be using a Linked list to implement the Queue. But it also has the same drawback of limited size. Similar to Stack, the Queue can also be implemented using both, arrays and linked list. Implementing Queue functionalities using Linked List Dequeue will always take place from the front end of the Queue. Dequeue – It specifies the deletion of an existing element from the Queue.Enqueue will always take place from the rear end of the Queue. Enqueue – It specifies the insertion of a new element to the Queue.Here, we will define two operations on Queue. Since we can access elements from both ends and the element inserted first will be the one to be deleted first, hence Queue is called First in First Out data structure (FIFO). A new element is added from the rear of Queue and deletion of existing element occurs from the front. It is also used to implement backtracking.Ī Queue is also a linear data structure where insertions and deletions are performed from two different ends.Call and return mechanism for a method uses Stack.It is also used to implement recursion.Undo feature in the text editors are also implemented using Stack.Stack can be used to implement back/forward button in the browser.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |