Using Eventlang features, define an event-based sorting structure for positive and negative numbers. This structure will consist

Question:

Using Eventlang features, define an event-based sorting structure for positive and negative numbers. This structure will consist of four bins represented as global references (posevenbin, posoddbin, negevenbin, and negoddbin), each of which holds a list of numbers. Each bin is initially an empty list.

The sorting structure itself consists of seven events organized as a perfect binary tree. The handler for the first event, named main, checks the input number and announces pos or neg, based on whether the number is positive or negative. The handlers for the pos and neg events each announce poseven and posodd, and negeven and negodd events if the number received is even or odd, respectively.

The handler for the poseven event adds the number to the global reference posevenbin. The handlers for the events posodd, negeven, and negodd behave similarly; that is, once the posodd event is announced, the handler adds the received number to the global reference posoddbin, and the process continues.

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

Step by Step Answer:

Question Posted: