Question: Q2(4 marks): A program reads the following names from left to right and add them to a stack S1. Jameel, Saeed, Tahir, Akbar, Halim, Sarah,

 Q2(4 marks): A program reads the following names from left to

Q2(4 marks): A program reads the following names from left to right and add them to a stack S1. "Jameel", "Saeed", "Tahir", "Akbar", "Halim", "Sarah", "Riaz", "Emad" botrom The program then performs the following operations: S2=[ zameely." saeed"s " "takir" 9 "Akbar". "halim"g "sara"pfo" saeed"g "tahir" while (stack S1 is not empty) \{ - If the element name starts with "A" to " P " enqueue in queue Q1 - If the element name starts with " Q " to "Z" push it in stack S2 " Riaz"] What are the contents of stack S2 and queue Q1 at the end of the loop? Clearly label your answers

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!