You have a situation where you need to use two stacks You kn
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 use an array representation with both stacks residing in the same array but with two logical pointers to top, i (for stackl) and top2 (for stack2). stack1 grows from left to right; stack2 grows from right to left. Notice this 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 functions of a class. Fill in the blank in the code below. const MAX = 100; typedef int ItemType; struct StackType ItemType info[KAX]; int top1; int top2; void PopS2(StackTypefc stack2, ItemTypeA item) Pre: stack2 has been created and is not empty. Post: The most recently inserted item has been removed from stack2 and its value returned in item. void PopSl(StackTypet stackl, ItemTypeft item) Pre: stack1 has been created and is not empty, Post: The most recently inserted item has been removed from stack1 and its value returned in item. Read the description and code segment above and fill in blank # Read the description and code segment above and fill in blank # 2 Read the description and code segment above and fill in blank # 3 Read the description and code segment above and fill in blank yashtag 4
Solution
Answers:
A. We have to store the top of stack2 in item. Hence the following statement. This is how variables of struct are referenced.
item = stack2->top2
B. Returning the value of the item.
return item;
C. We have to store the top of stack2 in item. Hence the following statement. This is how variables of struct are referenced.
item = stack1->top1
D. Returning the value of the item.
return item;
