
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
Solve 100% sure answer don't use chat gpt I have

Transcribed Image Text:Z-Z-X;
Z=Y-Z:
ENQUEUE (Q.Z):
DEQUEUE (Q,Y):
X=Y-Z:
ENQUEUE (Q.Y):
Value of Y?
Value of X?
3rd element in the Queue?
Front in the Queue?
Value of X?
No. of elements in the Queue?

Transcribed Image Text:TEST I. STACKS AND QUEUES SIMULATION. Simulate the following algorithms and answer the corresponding
questions written on the opposite side of each statement. (40 points - 1 point each)
ALGORITHM 1:
CLEARSTACK(S);
X=1;
Y=2;
Z=3;
PUSH (S,Y);
PUSH (S,Y);
PUSH (S,Y*Y+2);
PUSH (S,5);
POP (S,X);
Top of the stack?
Value of Y?
2nd element of stack?
POP (S,Z);
POP (S,Y);
PUSH (S,X+Y);
PUSH (S,Y*Z);
PUSH (S,X+1);
X=Y;
Value of X?
Bottom of the Stack?
No. of Elements in the Stack?
Value of X?
Y=Z;
Z=X;
PUSH (S,X+Y+Z);
POP (S,Y);
PUSH (S,Z);
PUSH (S,X+Y);
PUSH (S,Y*Z);
POP (S,Z);
POP (S,X);
Z=Z-X;
Z=Y-Z;
PUSH (S,Z);
POP (S,Y);
X=Y-Z;
PUSH (S,Y);
ALGORITHM 2:
CLEARQUEU(Q);
Value of Z?
Value of Y?
4th element of Stack?
Top of the Stack?
No. of elements in Stack?
Value of Y?
Value of X?
Value of Y?
Value of X?
3rd element of Stack?
Top of the Stack?
Value of X?
No. of elements in Stack?
X=1;
Y=2;
Z=3;
ENQUEUE (Q,Y);
ENQUEUE (Q,Y);
ENQUEUE (Q,Y*Y+2);
Front of the queue?
Value of Y?
2nd element of queue?
ENQUEUE (Q,5);
DEQUEUE (Q,X);
DEQUEUE (Q,Z);
DEQUEUE (Q,Y);
ENQUEUE (Q,X+Y);
ENQUEUE (Q,Y*Z);
ENQUEUE (Q,X+1);
X=Y;
Value of X?
Rear of the Queue?
No. of ElementQ in the Queue?
Value of X?
Y=Z;
Z=X;
ENQUEUE (Q,X+Y+Z);
DEQUEUE (Q,Y);
ENQUEUE (Q,Z);
ENQUEUE (Q,X+Y);
ENQUEUE (Q,Y*Z);
DEQUEUE (Q,Z);
DEQUEUE (Q,X);
Value of Z?
Value of Y?
4th element in the Queue?
Front in the Queue?
No. of elementQ in the Queue?
Value of Y?
Value of X?
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
Similar questions
- The implementation of a queue in an array, as given in this chapter, uses the variable count to determine whether the queue is empty or full. You can also use the variable count to return the number of elements in the queue. On the other hand, class linkedQueueType does not use such a variable to keep track of the number of elements in the queue. Redefine the class linkedQueueType by adding the variable count to keep track of the number of elements in the queue. Modify the definitions of the functions addQueue and deleteQueue as necessary. Add the function queueCount to return the number of elements in the queue. Also, write a program to test various operations of the class you defined.arrow_forwardHow is an array stored in main memory? How is a linked list stored in main memory? What are their comparative advantages and disadvantages? Give examples of data that would be best stored as an array and as a linked list.arrow_forward
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning

C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning

Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage

EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT

C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr

New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning