14 of 15
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
![l LTE
10:05
Done
14 of 15
40 Listen
2
(Stacks and Queues)
Assume that a program reads the following imput values one at a time into variable X in the code below
4
6.
20 6
18 6 14 8 12 7
15 24 26
30
99
--
---
Trace the following Java like pseudocode eode and write down (or in the box) its output as exactly it would appear on
the screen
7.
8
Create atack S
Create queue O
S.push (50):
Q. enqueue (50):
10
11
12
Read first input value to X:
While (X != -99)
Switch (X 4)
13
Case 0: S. push (X):
Exit Switch Statement;
Case 1: IC (S.isEmpty !- true)
y - s. top
Y S. tdp
Printout Stack Element: + Y):
s.pop();
Else Printoiit Sorry, atack 1s empty":
Exit Switch Statement:
Case 2: 0. enqueue (X):
Exit Switeh Statement:
Case 3: If (Q.iaErmpty:- true)
Y-O front (:
DELL](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6c734197-1b86-4ce4-b8d0-169fc6822d48%2Fcf1d44fd-f809-4e97-8b54-7880cb9a58f8%2Fz5srj7_processed.jpeg&w=3840&q=75)
Transcribed Image Text:l LTE
10:05
Done
14 of 15
40 Listen
2
(Stacks and Queues)
Assume that a program reads the following imput values one at a time into variable X in the code below
4
6.
20 6
18 6 14 8 12 7
15 24 26
30
99
--
---
Trace the following Java like pseudocode eode and write down (or in the box) its output as exactly it would appear on
the screen
7.
8
Create atack S
Create queue O
S.push (50):
Q. enqueue (50):
10
11
12
Read first input value to X:
While (X != -99)
Switch (X 4)
13
Case 0: S. push (X):
Exit Switch Statement;
Case 1: IC (S.isEmpty !- true)
y - s. top
Y S. tdp
Printout Stack Element: + Y):
s.pop();
Else Printoiit Sorry, atack 1s empty":
Exit Switch Statement:
Case 2: 0. enqueue (X):
Exit Switeh Statement:
Case 3: If (Q.iaErmpty:- true)
Y-O front (:
DELL
![UNJOWN Browser + Webcam
Time Left:1:25:10
Wondemu Damite: Attempt 1
Exit Switch Statement;
Case 1: If (S.isEmpty != true)
{Y =
S.top ()
Printout ("Stack Element: " + Y):
S.pop ();
Else Printout "Sorry, stack is empty":
Exit Switch Statement;
Case 2: Q. enqueue (X):
Exit Switch Statement;
If (Q.isEmpty != true)
{Y = Q.front();
Printout!
Q.dequeue () ;
Case 3:
("Queue Element:
+ Y);
Else Printout "Sorry, queue is empty";
Exit Switch Statement;
} //end of Switch statement
Read next input value to X;
} //end of While statement
Printout ("Stack Elements are: ");
While ((S.isEmpty != true)
Y = S.top)
Printout on newline (Y);
S.pop():
Printout ("Queue Elements are: ");
While ((Q.isEmpty != true)
Y = Q.front()
Printout on newline (Y);
%3!
Q.dequeue () :](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6c734197-1b86-4ce4-b8d0-169fc6822d48%2Fcf1d44fd-f809-4e97-8b54-7880cb9a58f8%2Fknv7cz_processed.jpeg&w=3840&q=75)
Transcribed Image Text:UNJOWN Browser + Webcam
Time Left:1:25:10
Wondemu Damite: Attempt 1
Exit Switch Statement;
Case 1: If (S.isEmpty != true)
{Y =
S.top ()
Printout ("Stack Element: " + Y):
S.pop ();
Else Printout "Sorry, stack is empty":
Exit Switch Statement;
Case 2: Q. enqueue (X):
Exit Switch Statement;
If (Q.isEmpty != true)
{Y = Q.front();
Printout!
Q.dequeue () ;
Case 3:
("Queue Element:
+ Y);
Else Printout "Sorry, queue is empty";
Exit Switch Statement;
} //end of Switch statement
Read next input value to X;
} //end of While statement
Printout ("Stack Elements are: ");
While ((S.isEmpty != true)
Y = S.top)
Printout on newline (Y);
S.pop():
Printout ("Queue Elements are: ");
While ((Q.isEmpty != true)
Y = Q.front()
Printout on newline (Y);
%3!
Q.dequeue () :
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education