Question: language c++ Algorithm to PUSH item on Stack using Linked structure: Algorithm: PUSH(ITEM), [ Here the initial value of TOP is NULL ] 1. Create

 language c++ Algorithm to PUSH item on Stack using Linked structure:Algorithm: PUSH(ITEM), [ Here the initial value of TOP is NULL ]1. Create dynamic NODE to store (Info and Next) for top nodeand store its address into NewNode pointer [Insert ITEM in new TOP

language c++

Algorithm to PUSH item on Stack using Linked structure: Algorithm: PUSH(ITEM), [ Here the initial value of TOP is NULL ] 1. Create dynamic NODE to store (Info and Next) for top node and store its address into NewNode pointer [Insert ITEM in new TOP position.] 2. Set NewNode -> Info = ITEM and NewNode -> Next = TOP 3. Set TOP = NewNode [ Adjust new TOP address ] 4. End. Algorithm to POP item from Stack using Linked structure: Algorithm: POPO This procedure deletes the TOP element of STACK and assigns its value to the variable ITEM. 1. (Check for empty stack] If TOP = NULL, then Print: UNDERFLOW/ Stack is empty, and End. 2. Set ITEM = TOP -> Info [Assign TOP element to ITEM.] 3. Set T = TOP [Load the address of current TOP into T] 4. TOP TOP -> Next. [Reset TOP by shifting it to lowerext node.] 5. Release T [ Send back the memory occupied by deleted node.] 6. Return ITEM and End Algorithm to produce PEAK item from Stack using Linked structure: Algorithm: PEAKO This procedure Produce the TOP element of STACK without deleting it and assigns its value to the variable ITEM. 1. Check for empty stack] If TOP = NULL, then Print: UNDERFLOW/ Stack is empty, and End. 2. Set ITEM TOP -> Info [Assign TOP element to ITEM.] 3. Return ITEM and End Algorithm to TRAVERSE Stack using Linked structure: Algorithm: TRAVERSE(). This function produces all elements of the STACK without deleting them. 1. [Check for empty stack] IF TOP = NULL, then Print: UNDERFLOW/ Stack is empty, and End. 2. Set T = TOP [Load the address of current TOP into T] 3. Repeat while ( T not NULL) a) Print: T -> Info b) T = T -> Next. [End of Loop of step-3.] 4. End #include #include struct NODE int info; struct NODE *next; }; struct NODE *TOP = NULL; void PUSH (int item) { } int POP ) } int PEAK { } void TRAVERSE() { } bool IsEmpty() { int main() { struct NODE *T; int item, choice; cout"; cin>> choice; switch(choice) { case 1: cout>item; PUSH(item); break; case 2: if(IsEmpty()) {cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!