Could someone please look over my questions/answers that I have put in bold. Or the answer I put after A:. I am preparing for a test and want to make sure I know what to do. Thanks
Code:
1) Client code needs a stack variable S capable of storing up to ten integers. Declare the stack variable S.
A) Stack(10) S; B) Stack S C) Stack S=10; D)Stack S(10); E) None of the above
2) Add the integer 7 to top of stack variable S assuming stack is not full.
A:
S.Push(7);
3) Remove the top most integer from top of stack variable S and store value into previously declared integer variable W assuming stack is not empty.
A:
W=S.Pop();
4) Output "Full" if previously declared stack variable S is full.
A:
if(S.IsFull())
cout << "Is Full";
5) Return the top most value on the stack without modifying the contents in the stack.
A:
int temp = S.Push();
S.pop(temp);
6) Using two Stack variables, S1 and S2, where contents of S1 are Top{1,2,3} and contents of S2 are Top{4,5}. Describe S2 after following statement: S2=S1;
A) {1,2,3} B){4,5} C){3,2,1} D)Error: illegal statement E)None of the above.
7) Which describes what happened to the original contents in S2?
A) S2 remains stored in S2 and can be accessed using public member functions
B. S2 was automatically deallocated by Stack destructor
C) S2 remains in memory allocated to the client but is inaccessible
D) S2 remains in memory allocated to client and is accessible through the variable S1 and public member function
E) None of above
-Dont believe it is C,D,E. I chose B.
8) Suppose the client code wishes to create a Queue object named Q. Which of the following code
segments successfully completes that task?
A) Q = Queue; C) ~Queue Q; E) None of the answers provided
B) Queue Q; D) Queue Q(10);
9) Suppose the client code includes a Queue object named Q. Which of the following code
segments successfully uses the Add method to enqueue the integer value 3 to the object Q ?
A) Add(Q, 3); C) Q.Add(3); E) None of the answers provided
B) Q.Add('3'); D) Both B and C
10) Suppose the client code includes a Queue object named Q. Which of the following code
segments successfully uses the Remove method to dequeue the next integer value stored
in Q and place that integer into the variable W ?
A) W = Remove(Q); C) Q.Remove(W); E) None of the answers provided
B) W = Q.Remove(); D) W.Remove(Q);