Plurality voting with priorities for tie-breaking algorithm implementation -
i trying implement plurality voting algorithm priorities used break ties. mean priorities following. example, have 3 classes - a, b , c. priority goes a, c , b, starting highest - lowest - b. when , c have equal votes , more b, win plurality vote because of higher priority.
the idea have tie-breaking implement many if-statements. if not wrong, these 10 case of 3 classes. how can generalized can implement algorithm k-classes? can please code? imperative language c, java, js, c#, python, etc or pseudo-code.
thank much!
you can sort based on number of votes first. iterate through sorted list, , entries equal number of votes, sort again, time using priority.
Comments
Post a Comment