Question

In: Computer Science

What are the different pointers in stack-based implementation? Explain their usage clearly.

What are the different pointers in stack-based implementation? Explain their usage clearly.

Solutions

Expert Solution

The different pointers in stack-based implementation are given below :

1. Stack Origin :

This pointer is used to hold the memory address of the stack i.e first memory byte of the stack.

The stack origin is a fixed sie pointer whose size is defined on the basis of the type of bit machine.

The stack origin is used during memory allocation. All data is stored in a stack with their address relation to stack origin.

2.Stack Pointer :

This is another pointer used in the stack-based implementation.

This pointer is used to hold the memory address of the location which contains the top element of the stack.

This pointer is decremented every time when an element is pushed into the run-time stack and decrement when the element is popped from the stack.

Both the pointer is shown below using a diagram :

STACK ORIGIN(100)
(99)
(98)
(97)
(96)
..
(10)
STACK TOP(9)
(8)
..
(1)
(0)

Related Solutions

IN JAVA LANGUAGE Linked List-Based Stack Implementation Implement Stack using a Linked List Use the language...
IN JAVA LANGUAGE Linked List-Based Stack Implementation Implement Stack using a Linked List Use the language library LinkedList Stack methods will call the LinkedList methods You can use string as the object Instead of using an array, as the StackLab did, here you will use a Linked List from your language's library. Implement all the methods of Stack : push(), pop(), size(), printStackDown(), etc, using calls to the linked list methods that correspond to the actions need. In the array...
write an implementation of the ADT stack that uses a resizeable array to represent the stack...
write an implementation of the ADT stack that uses a resizeable array to represent the stack items. Anytime the stack becomes full, double the size of the array. Maintain the stack's top entry at the end of the array. Please use c++ for this question.
Write an implementation of the ADT stack that uses a resizeable array to represent the stack...
Write an implementation of the ADT stack that uses a resizeable array to represent the stack items. Anytime the stack becomes full, double the size of the array. Maintain the stack's top entry at the beginning of the array. Use c++ to write this code.
Write an implementation of the ADT stack that uses a resizeable array to represent the stack...
Write an implementation of the ADT stack that uses a resizeable array to represent the stack items. Anytime the stack becomes full, double the size of the array. Maintain the stack's top entry at the beginning of the array. Use c++ to write this code.
Provide an array-based implementation of stack that allows us adding (pushing) items regardless of the capacity....
Provide an array-based implementation of stack that allows us adding (pushing) items regardless of the capacity. That means, when the stack becomes full, it doubles its capacity to be able to hold more items. Specifically, in your implementation start with default capacity 4, when the stack reaches 4 items and you want to add more, make the capacity 8, and so on. Therefore, you can always add items and the stack expands. Name the class ImprovedStack and implement the following...
Explain the difference between array and structure based on their usage in C++ programming. Declare a...
Explain the difference between array and structure based on their usage in C++ programming. Declare a structure called studentScore which contains name of student, registration number of students, course code and marks. Declare structure variable named studentCS680 based on the structure in (b) to store fifty (50) students’ data. Write a program that prompts a user to enter data for 50 students in a structure variable declared in (b) and calculate the average mark.
JAVA Stack - Implementation. You will be able to use the push, pop and peek of...
JAVA Stack - Implementation. You will be able to use the push, pop and peek of Stack concept. Post-Fix calculator - When an arithmetic expression is presented in the postfix form, you can use a stack to evaluate the expression to get the final value. For example: the expression 3 + 5 * 9 (which is in the usual infix form) can be written as 3 5 9 * + in the postfix. More interestingly, post form removes all parentheses...
Write a program that implements a stack of integers, and exercises the stack based on commands...
Write a program that implements a stack of integers, and exercises the stack based on commands read from cin. To do this, write a class called Stack with exactly the following members: class Stack { public: bool isEmpty(); // returns true if stack has no elements stored int top(); // returns element from top of the stack // throws runtime_error("stack is empty") int pop(); // returns element from top of the stack and removes it // throws runtime_error("stack is empty")...
‘Different organizational implementation tools should be designed in order to facilitate the implementation of different types...
‘Different organizational implementation tools should be designed in order to facilitate the implementation of different types of strategy’. Do you agree with this statement? Why or why not? Please illustrate your answers with the two basic generic business-level strategies.
#data structures Assume you are given an implementation of the Stack class. Recall that it has...
#data structures Assume you are given an implementation of the Stack class. Recall that it has methods push(), pop(), top(), isEmpty() and isFull(). Write an Integer function with prototype: public static Integer popBottom(Stack<Integer> stk); Note that it has one parameter, a single stack object stk. The function should delete the item at the bottom of the stack and return this item as the value of the function. If the stack is empty return null. When the function returns the stk...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT