The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Implement the following specification for a client Boolean function that returns true if two stacks are identical and false otherwise.
Â
Boolean Identical(StackType stack1, StackType stack2)
Function: Determines if two stacks are identical. Preconditions: stack1 and stack2 have been initialized. Postconditions: stack1 and stack2 are unchanged. Â Function value = (stack1 and stack2 are identical)
You may use any of the member functions of Stack Type, but you may not assume any knowledge of the stack’s implementation. Assume any knowledge of the stack’s implementation.
Â
The following code segment is a count-controlled loop going from 1 through 5. At each iteration, the loop counter is either printed or put on a stack depending on the result of the Boolean function Ran Fun(). (The behavior of Ran Fun() is immaterial.) At the end of the loop, the items on the stack are popped and printed. Because of the logical properties of a stack, this code segment cannot print certain sequences of the values of the loop counter. You are given an output and asked to determine whether the code segment could generate the output.
Â
for (count = 1; count <= 5; count++)
Â
if (RanFun())
Â
cout << count;
Â
else
Â
stack.Push(count);
Â
while (!stack.IsEmpty())
Â
{
Â
stack.Pop(number);
Â
cout << number;
}
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll