# report | Algorithm | project | 作业Asp | unity代写 | assignment代写 | ios | mips作业 – Kartik Mohanram, University of Pittsburgh

### Kartik Mohanram, University of Pittsburgh

report | Algorithm | project | 作业Asp | unity代写 | assignment代写 | ios | mips作业 – 这道题目是利用Algorithm进行的编程代写任务, 包括了report/Algorithm/Asp/unity/ios/mips等方面, 这个项目是assignment代写的代写题目

In this project, you will implement one solution to the instant runoff voting^1 method (abbreviated IRV henceforth) for preferential voting^1 in stant run off vot ing noun: an elec- toral system whereby voters rank candi- dates in order of preference. In the event that one candidate fails to achieve a suf- ficient majority, the candidate with the fewest number of first-preference rank- ings is eliminated and these votes redis- tributed, the process being repeated un- til one candidate achieves the required majority.

that has seen widespread adoption in multiple contexts/scenar ios thr- oughout the world. I can think of no better way to get you up-to-speed than to point you to the Wikipedia entry on IRV. In particular, once you gr unity 代写3D unity”> Asp the generalities of IRV and its vari- ants after a screen or two of reading, please proceed to the Five vot- ers, three candidates example that will form the basis for introducing your class project. This example demonstrates full preferential voting, i.e., every voter assigns every candidate a unique rank/preference.^22 Wikipedia: In a full preferential vot- ing method, voters are required to mark a preference for every candidate stand- ing. Ballots that do not contain a com- plete ordering of all candidates are in some jurisdictions considered spoilt or invalid, even if there are only two can- didates standing.

This class project requires that you implement IRV in its full preferen- tial voting form assuming that the data is well-formed, i.e., you may assume that there are no spoilt/invalid votes. Once you understand and maybe even formulate a simple process for implementing the algo- rithm outlined there, please return to this document to understand the input/output format and the general programming framework that has been released to the class. Simultaneously, I suggest that you also open and read the filemain.asmthat will serve as the single source file that integrates a simple test harness to get you going. All your code, with embedded documentation, will go into this single file, which you will submit by the project deadline.

#### 1 Input+output format

``````The test data (input as well as output) is located in the filestest1.asm,
test2.asm, etc. and a single test file will be explicitly referenced from
main.asmon program execution. The rest of this section uses the
Wikipedia example (reproduced below) to orient you to the specifics
of the test file format.
``````
``````Figure 1 : Wikipedia IRV example
``````
``````For the example outlined on Wikipedia, yourtest1.asmfile uses
the following format and relies on three variables: votes, results,
andgolden_results.
.data
results: .word 0,0,0,
golden_results: .word 1,3,2,
The first word at thevotesvariable is the number of voters. The
second word at thevotesvariable is the number of candidates. The
preferential votes of all the voters are then setup as a flattened two-
dimensional array, and the rest of the entries in thevotesarray define
the votes (preferences) of each voter in turn/sequence. For example,
voter as preferences read1,3,2following the entries5,3. You should
interpret this to mean that voter a ranks candidate 1 first, candidate 2
third, and candidate 3 second, consistent with the Wikipedia example.^33 A common trap is to interpret1,3,2to
mean that voter a prefers candidates 1 , 3 ,
and 2 in that order; while this input for-
mat and interpretation is definitely pos-
sible (with consistent/equivalent out-
comes as in this particular case), it is not
compatible with a general IRV setup in
practice, since names are committed to
the ballot with boxes in which ranks are
to be recorded. Thus,3,1,2means the
voter ranks the candidates in the order
2 , 3 , and then 1 , and not in the order 3 ,
1 , and 2.
``````
``````You are expected to record the winner and loser of each round
till the  Algorithm terminates (output) using pre-allocated space at the
resultsvariable. Note that forncandidates, you will have a maxi-
mum ofn1 rounds, each with a winner and a loser, and hence there
will be 2(n 1 )zeroes against this variable. If the algorithm terminates
in less thann1 rounds, then the extra entries are to be left as-is. For
your benefit, the expected (i.e., golden) results are also provided in
thegolden_resultslocation. For the Wikipedia example, the winner
of the first round is candidate 1 while candidate 3 is eliminated. On
round two, candidate 2 is the winner while candidate 1 is eliminated.
It is your responsibility to craft additional test cases beyond the four
tests released in this package^4. Each of the remaining three test cases^4 Please note that your documenta-
tion/ report should explicitly clarify
were crafted to test your implementa-
tion.
``````
``````described/discussed in the rest of this section illustrate some salient
``````
``````points regarding the specifics of this IRV algorithm (how to resolve
ties, when to declare a winner, etc.).
``````

#### 2 Tests 2 4

##### 2. 1 Test 2 : When to declare a winner, and how to resolve ties
``````.data
results: .word 0,0,0,0,0,
golden_results: 1,3,0,0,0,
``````
``````Declaring a winner: If one or more candidates secure 50 % of the
total votes cast at the end of the round, the first candidate to do so in
order of the candidate listing on the ballots is declared the winner. In
this test case, both candidates 1 and 2 secure 2 votes each at the end
of the first round of IRV. Simply declare candidate 1 the winner since
she/he has secured 50 % ( 2 -out-of- 4 ) of the votes cast in the election.
Eliminating a candidate: On every round, the candidate who se-
cures the least number of votes is eliminated. If multiple candidates
are in contention for elimination (i.e., they are tied in bottom place at
the end of a round), simply eliminate the first candidate tied for bot-
tom place in order of the candidate listing on the ballots.^5 For this^5 By enforcing a listing rule that says can-
didate names appear on the ballot in the
order of the time of official filing of their
respective candidacies, it would make
more sense to eliminate the first candi-
date tied for bottom place in reverse or-
der of the candidate listing, i.e., the last
candidate tied for bottom place in or-
der of the candidate listing, but lets just
keep things simple here.
``````
``````particular test case, candidates 3 and 4 both secure zero first place
votes at the end of the first round, and candidate 3 is eliminated. This
is a strange test case since the election terminates with ties all around,
but it is there to capture these scenarios succinctly.
Deadlock: The above elimination strategy guarantees that no test
case will result in deadlock. For example, in a simple scenario where
two/three voters cast ballots for two/three candidates, respectively,
and each candidate receives 1 top vote, the first candidate is the winner
of round 1 while the second candidate is eliminated (in both scenarios).
Draconian, sure, but it keeps the ball rolling and does away with the
need to resolve these cases using other more complex rules in assembly
code. Build two such test cases and use them as a reference from the
word go ...
``````
##### 2. 2 Test 3 : Redistribution test
``````.data
4,1,2,3,4,1,2,3,4,2,3,1,4,2,3,1,4,2,3,1,
4,2,3,
results: .word 0,0,0,0,0,
golden_results: .word 1,3,1,2,4,
``````
``````This test will stress your code in terms of how well you are redis-
tributing the votes of eliminated candidates. In particular, at the end
of each round, you have to redistribute the votes of the eliminated can-
didates. However, when you start this process, you may find that the
new top choice of a voter may have already been eliminated. You have
to ensure that in such cases, you setup your re assignment process such
that you ensure that an uneliminated candidate emerges as the voters
top preference. This may be easy to track between successive rounds,
but it is harder to track when the distance between rounds is greater