Question

The code in StreamMerge (see Section 7.1) assumes that EOS is larger than the other values in the stream. This exercise explores removing that assumption. (a) Run the original program. To make the program concrete, have process one send the stream $1,3,5,7,9$, EOS and process two send the stream 4,8 , EOS. (b) Run the program from part (a) with the following values of EOS: 99, -99 , and 6. Compare each of the outputs from these runs with the output from the program in part (a); explain any differences (c) The program in part (b) implicitly assumes that EOS appears only at the end of the stream. Or, if EOS does appear midstream, it is still interpreted as EOS, and thus terminates the stream; subsequent numbers are just ignored. Confirm this behavior by running the program with EOS set to 5 . (d) Rewrite the code in StreamMerge so EOS can be an arbitrary integer value that is not necessarily larger than the other values in the stream. (Assume that EOS appears only as stated in part (c).) This program's behavior should be identical to the original program's behavior except for the value of EOS it outputs. Run the modified program for the values of EOS given in part (b).

   The code in StreamMerge (see Section 7.1) assumes that EOS is larger than the other values in the stream. This exercise explores removing that assumption.
(a) Run the original program. To make the program concrete, have process one send the stream $1,3,5,7,9$, EOS and process two send the stream 4,8 , EOS.
(b) Run the program from part (a) with the following values of EOS: 99, -99 , and 6. Compare each of the outputs from these runs with the output from the program in part (a); explain any differences
(c) The program in part (b) implicitly assumes that EOS appears only at the end of the stream. Or, if EOS does appear midstream, it is still interpreted as EOS, and thus terminates the stream; subsequent numbers are just ignored. Confirm this behavior by running the program with EOS set to 5 .
(d) Rewrite the code in StreamMerge so EOS can be an arbitrary integer value that is not necessarily larger than the other values in the stream. (Assume that EOS appears only as stated in part (c).) This program's behavior should be identical to the original program's behavior except for the value of EOS it outputs. Run the modified program for the values of EOS given in part (b).
Show more…
The JR programming language : concurrent programming in an extended Java
The JR programming language : concurrent programming in an extended Java
Ronald A Olsson;… 1st Edition
Chapter 7, Problem 2 ↓

Instant Answer

verified

Step 1

(a) Running the original program with process one sending the stream $1,3,5,7,9$, EOS and process two sending the stream $4,8$, EOS, the output will be $1,3,4,5,7,8,9$.  Show more…

Show all steps

lock
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
The code in StreamMerge (see Section 7.1) assumes that EOS is larger than the other values in the stream. This exercise explores removing that assumption. (a) Run the original program. To make the program concrete, have process one send the stream $1,3,5,7,9$, EOS and process two send the stream 4,8 , EOS. (b) Run the program from part (a) with the following values of EOS: 99, -99 , and 6. Compare each of the outputs from these runs with the output from the program in part (a); explain any differences (c) The program in part (b) implicitly assumes that EOS appears only at the end of the stream. Or, if EOS does appear midstream, it is still interpreted as EOS, and thus terminates the stream; subsequent numbers are just ignored. Confirm this behavior by running the program with EOS set to 5 . (d) Rewrite the code in StreamMerge so EOS can be an arbitrary integer value that is not necessarily larger than the other values in the stream. (Assume that EOS appears only as stated in part (c).) This program's behavior should be identical to the original program's behavior except for the value of EOS it outputs. Run the modified program for the values of EOS given in part (b).
Close icon
Play audio
Feedback
Powered by NumerAI
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever