Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have a situation where you need to use two stacks. You know that together th

ID: 3812283 • Letter: Y

Question

You have a situation where you need to use two stacks. You know that together they never have more than MAX elements. You decide to an array representation with both stacks residing in the same array but with two logical pointers to top, top 1(for stack 1) and top 2 (for stack 2) Stack 1 grows from the left to right; stack 2 grows from right to left. Notice that is not a linked list. Use the following definitions and declarations. Note that the stack is being passed as a parameter to these functions; they are not member class. You may assume that when the parameter user is stack 1, the user passes the stack where the top is top1 and that when the parameter is the stack 2, the user the stack where the top is top 2. Fill in the blank in the code below. const MAX = 100; typedef int itemType;//components on the stacks struct StackType {ItemType info[MAX]; int top1;//top for stack1 int top2;//top for stack 2}; void CreateStack1 (StackType&stack1;)//Post: stack1 has been set to empty {stack top1 = -1;} void Createstack2(StackType&stack2;)//Post: stack2 has been set to empty {stack2.top2 = MAX; Boolean isFull(StackType stack)//Pre: stack has been created.//Post: return FALSE if there is room for another item; otherwise. {_____;}.

Explanation / Answer

if(stack==NULL)
   return false;
if(stack.top2-stack.top1==1)
   return true;
return false;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote