
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question

Transcribed Image Text:case 2:
if (!stack.isEmptyStack())
Consider the following statements: (4, 10)
linkedStackType<int> stack;
linkedQueueType<int> queue;
int num;
cout « stack.top () << " ";
stack.pop ();
else if (!queue.isEmptyQueue ())
{
cout <« queue.front () << " ";
queue.deleteQueue () ;
Suppose the input is:
48 35 72 88 92 11 10 15 44 52 67 36
Show what is written by the following segment of code:
else
stack.push (0) ;
queue.addQueue (0);
cin >> num;
cout « "Stack and queue are empty." <« endl;
break;
} //end switch
while (cin)
{
cin >> num;
} //end while
switch (num % 3)
{
case 0:
cout « endl;
cout <« "stack: ";
while (!stack.isEmptyStack ())
stack.push (num);
break;
case 1:
cout « stack.top () <« " ";
stack.pop ();
queue.addQueue (num);
break;
cout « endl;
cout <« "queue: ";
while (!queue.isEmptyQueue ())
{
cout « queue.front () <« " ";
queue.deleteQueue () ;
}
cout <« endl;
48 72 0 15 stack: 36 queue: 0 88 10 52 67
48 730 15 stack: 37 queue: 0 88 10 52 67
48 74 0 15 stack: 38 queue: 0 88 10 52 67
48 75 0 15 stack: 39 queue: 0 88 10 52 67
Expert Solution

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

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.Similar questions
- Assume a linked list contains following integers: 5, 2, 4, 6, 8, 3, 15 and the pointer head is pointing to the first node of the list. What will be the value of variable a after the following statements are executed: Node<int> *curNode=head; int a=0; while(curNode!=NULL){ a+=curNode->getItem(); curNode=curNode->getNext(); if(curNode!=NULL) curNode=curNode->getNext(); } A.32 B.43 C.19 D.18arrow_forwardConsider the following statements: stackType<int> stack; int x; Suppose that the input is: 14 53 34 32 13 5 -999 Show what is output by the following segment of code: cin >> x; while (x != -999) { if (x % 2 == 0) { if (!stack.isFullStack()) stack.push(x); } else cout << "x = " << x << endl; cin >> x; } cout << "Stack Elements: "; while (!stack.isEmptyStack()) { cout << " " << stack.top(); stack.pop(); } cout << endl;arrow_forwardProject Overview: This project is for testing the use and understanding of stacks. In this assignment, you will be writing a program that reads in a stream of text and tests for mismatched delimiters. First, you will create a stack class that stores, in each node, a character (char), a line number (int) and a character count (int). This can either be based on a dynamic stack or a static stack from the book, modified according to these requirements. I suggest using a stack of structs that have the char, line number and character count as members, but you can do this separately if you wish.Second, your program should start reading in lines of text from the user. This reading in of lines of text (using getline) should only end when it receives the line “DONE”.While the text is being read, you will use this stack to test for matching “blocks”. That is, the text coming in will have the delimiters to bracket information into blocks, the braces {}, parentheses (), and brackets [ ]. A string…arrow_forward
- 0:00 I ZVV 58 Stack s - new Stack(); s. push(10); s. push(20); s. push(30); s. push(40); // stack created with elements- 10 20 30 40 59 60 61 62 63 64 65 sum(s); 66 public static void sum(stack s){ Integer sum = 0; stack tmp = new Stack(); // move the stack to new stack, it will be in reverse orde // simultaneously sum the elements while (Is.isEmpty())( tmp.push(s.pop(); sum t tmp.peek(); 67 68 69 70 71 72 73 74 sum t= tmp.peek (); 74 75 // move to original stack while (Itmp.isEmpty()){ s.push(tmp.pop()); system.out.println("sum= "+sum.tostring()); OUTPUT- 10 pushed into stack 20 pushed into stack 30 pushed into stack 40 pushed into stack 40 pushed into stack 30 pushed into stack 20 pushed into stack 10 pushed into stack 10 pushed into stack 20 pushed into stack 30 pushed into stack 40 pushed into stack Sum= 100 Sum of 10, 2O, 30, 40 = 100 I hope it helps. For any doubt, feel free to ask in comments, and give upvote if u get the answer.arrow_forward5. What is the output of the following program segment? linkedQueueType queue; queue.addQueue (10); queue.addQueue (20); cout tempQueue; tempQueue = queue; while (!tempQueue.isEmptyQueue ()) cout << tempQueue.frcnt () << " "; tempQueue. deleteQueue (); cout << endl; cout << queue.front () << " " << queue.back() '<< endl; 6 Supnose thiat queue is a queueTyne ohiect and the size of the array imarrow_forwardjava Suppose queue is defined as LinkedQueue<Integer> queue = new LinkedQueue<>(); Show what is written by the following segment of code. SHOW YOUR WORK.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education