Question: You are to write the function Vector computePowerIndexes ( Vector& blocks ) which receives a Vector of size N containing the block counts for a

You are to write the function
Vector computePowerIndexes(Vector& blocks)
which receives a Vector of size N containing the block counts for a block voting system. The function counts critical votes to determine the voting power per block. The output returned by the function is a Vector of size N with the Banzhaf power indexes for each block. For example, calling computePowerIndexes on the vector of block counts {50,49,1} returns a vector of per-block power indexes {60,20,20}.
Although the explanation above describes the process in terms of first finding coalitions and then determining which participants are critical, the actual code is easier to structure by instead proceeding to count the critical votes specific to a target block and repeating that process for all blocks.
Set aside the target block and recursively explore all the subsets (coalitions) that do not include the target. As you form a coalition, you do not need to store a collection of the participating blocks, just tally the amassed vote total for each coalition.
Once a coalition is formed and its votes are summed, consider the impact of the target block's vote. Without the target block does the coalition lose, and with the target block, does the coalition win? If the answer to both of these questions is yes, then the block is a critical voter for that coalition.
Repeat the exploration for every block in the system to count each block's critical votes.
Once you have the counts of critical votes for all blocks, the conversion to percentage is simple looping and arithmetic.
After testing and debugging your function, predict what you expect to be the Big O of the computePowerIndex function. Then use the timing operation to measure the execution time over 5 or more different sizes. Choose sizes so that the largest operation completes in under a minute or so.

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 Programming Questions!