Objective:

We'll study three data storage structures: the stack, the queue, and the priority queue in this lab, and see how these structures differ from arrays. Make sure you can predict what its going to happen.

At the end of this lab, you need to submit a word document including some text answers and screenshots of your lab result. The way to get the screen shots is to press Key "Print Screen" from your keyboard to get the image of the whole screen, then use Start->All Programs->Accessories->Paint, click Edit->Paint to get the image, use text to add your own name (to replace Qi Zhu), then cut and paste the part of image you want into your homework file such as .doc).

1: Operations on Stack.html

(1.) Click Start > Windows System -> Command Prompt

(2.) Change the directory by typing "cd C:\COSC3331\Chap04\Stack".

(3.) Run "appletviewer Stack.html", see Figure 1.

Q1: What is the initial value of the variable Top (check the source code)?

Fig. 1 Initial State for a 10-Element Stack see image.

(4.) Use the blank of Number and click Push to insert some numbers in sequence of 50, 30, 10, 60, 20, 70, and 40, then we have Figure 2. see image.

(5.) Click Pop twice to remove the top two elements for Figure 3.

Fig. 3 Stack after Some Pop Operations see image.

(6.) Click Peek. Q2: What is the difference between Pop and Peek operations?

(7.) Click Push to insert numbers 90, 40, 30 in that sequence for Figure 4.

Fig. 4 Final State after Some More Push Operations see image.

2: Operations on Queue.html

(1.) Under Command Prompt, change the directory by typing "cd C:\COSC3331\Chap04\Queue". Run appletviewer Queue.html.

(2.) Click New to create an empty 10-element Queue for Figure 5. Q3: What are the initial values of the variables Front and Rear (check the source code)?

Fig. 5 Initial State for a 10-Element Queue see image.

(3.) Use the blank of Number and click Ins to insert some numbers in sequence of 50, 30, 10, 60, 20, 70, and 40, then we have Figure 6.

Fig. 6 Queue after Some Insertion Operations see image.

(4.) Click Rem twice to remove the first two elements for Figure 7.

Fig. 7 Queue after Some Remove Operations see image.

(5.) Click Peek. Q4: What is the difference between Rem and Peek operations?

(6.) Click Ins again to insert numbers 90, 40, 30, 50 in that sequence, then we have Figure 8. Q5: What technique in array it used to allow 50 inserted into the queue?

Fig. 8 Final State after Some More Insertion Operations see image.

3: Operations on PriorityQ.html

(1.) Under Command Prompt, change the directory by typing "cd C:\COSC3331\Chap04\PriorityQ". Run appletviewer PriorityQ.html.

(2.) Click New to create an empty 10-element Priority Queue for Figure 9.

Fig. 9 Initial State for a 10-Element Priority Queue see image.

(3.) Use the blank of Number and click Ins to insert some numbers in sequence of 50, 30, 10, 60, 20, 70, and 40, then we have Figure 10. Q6: What is the difference between priority queue and the regular queue at insertion operations?

Fig. 10 Priority Queue after Some Insertion Operations see image.

(4.) Click Rem twice to remove the first two elements for Figure 11.

Fig. 11 Priority Queue after Some Remove Operations see image.

(5.) Click Peek.

(6.) Click Ins again to insert numbers 90, 40, 30, 50 in that sequence, then we have Figure 12.

Fig. 12 Final State after Some More Insertion Operations see image.

Part I: Answer the questions:

Q1: What is the initial value of variable Top (check the source code)?

Q2: What is the difference between Pop and Peek operations?

Q3: What are the initial values of variables Front and Rear (check the source code)?

Q4: What is the difference between Rem and Peek operations?

Q5: What technique in array it used to allow 50 inserted into the queue?

Q6: What is the difference between priority queue and the regular queue at insertion operations?

Part II: Screen shots

Submit the screenshots for Figures 2, 3, 4, 6, 7, 8, 10, 11, and 12 (totally 9 figures) through Blackboard. (Don't forget to include your name in the program). (At the end of this lab, you need to submit a word document including some screenshots of your lab result. The way to get the screen shots is to press Key "Print Screen" from your keyboard to get the image of the whole screen, then use Start->All Programs- >Accessories->Paint, click Edit->Paint to get the image, use text to add your own name (to replace Qi Zhu), then cut and paste the part of image you want into your homework file such as .doc).

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.