function [plain,ssd] = condorcet(election) % [plain,ssd] = condorcet(election): Plain and SSD Condorcet winners % $election$: pairwise matrix or string matrix whose rows are ballots % -- same conventions as $tallies$, below % $plain$: winners from Plain Condorcet voting % $ssd$: winners from SSD Condorcet voting (BONUS) % note: when there are ties, *all* possible answers are returned % ----- << your code for condorcet goes here >> ----- function [i,j,v] = alldefeats(pwm) % [i,j,v] = alldefeats(pwm): defeats in ascending order in pairwise matrix % $pwm$: pairwise matrix % $i,j,v$: $k$-th defeat is $i(k)$ over $j(k)$ with magnitude $v(k)$; % $v$ is sorted in ascending order % ----- << your code for alldefeats goes here >> ----- function t = issubset(a,b) % t = issubset(a,b): "$a$ is a subset of $b$?" % ----- << your code for issubset goes here >> ----- function pwm = tallies(election) % pwm = tallies(election): pairwise matrix specified by election$ % $election$: pairwise matrix or string matrix whose rows are ballots % % the format of a single ballot is the same as for $tally$, below; % each ballot is assumed to have the same number of candidates % ----- << your code for tallies goes here >> ----- function pwm = tally(ballot) % pwm = tally(ballot): pairwise matrix for single ballot $ballot$ % $ballot$: a string vector of holding an ordered sequence of candidates % + candidates are represented by consecutive letters of the alphabet, % starting at $'a'$, and ignoring case ($'a'$ and $'A'$ are the same) % + $ballot(1:2:end)$ is the list of candidates % $ $ballot(2:2:end)$ holds comparisons $'>'$ and/or $'='$ % % example: $tally('d>c=e=b>a')$ % ----- << your code for tally goes here >> ----- function top = topmost(pwm) % top = topmost(pwm): innermost unbeaten sets for pairwise matrix $pwm$ % ----- << BONUS: your code for topmost goes here >> ----- function list = unbeaten(pwm,list) % list = unbeaten(pwm,list): smallest unbeaten set containing $list$ % $pwm$: pairwise matrix % note: $list$ is both a return variable and a parameter % ----- << BONUS: your code for unbeaten goes here >> -----