Using Msglang features, define a processbased sorting structure for positive and negative numbers. This structure will consist

Question:

Using Msglang features, define a processbased sorting structure for positive and negative numbers. This structure will consist of four bins represented as global references

(posevenbin, posoddbin, negevenbin, negoddbin), each of which holds a list of numbers. Each bin is initially an empty list. The sorting structure itself consists of seven processes organized as a perfect binary tree. The first process, named main, accepts the input number and forwards the number and its own address to either of its two children, pos and neg, based on whether the number is positive or negative. Both pos and neg have two children of their own, poseven and posodd, and negeven and negodd, and they forward the number that they receive to _even if it is even, and _odd if it odd. Along with the number, each process also receives the address of the main process.

Once the poseven process receives a number, it adds it to the global reference posevenbin and sends the message “poseven” to the main process using the address that it received. The processes posodd,

negeven, and negodd behave similarly; that is, once the posodd process receives a number, it adds it to the global reference posoddbin and sends the message “posodd” to the main process using the address that it received, and so on. Care should be exercised in the design of the main process to allow it to accept messages from external entities, as well as from the leaf processes poseven, posodd, negeven, and negodd.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: