How does the record preferences function in pset3 work?

How does the record preferences function in pset3 work?

The record_preferences function is called once for each voter, and takes as argument the ranks array. The function should update the global preferences array to add the current voter’s preferences. The add_pairs function should add all pairs of candidates where one candidate is preferred to the pairs array.

When to not add pairs in CS50 pset3?

The add_pairs function should add all pairs of candidates where one candidate is preferred to the pairs array. A pair of candidates who are tied (one is not preferred over the other) should not be added to the array.

When to return true or false in Tideman?

The function should return true if the rank was successfully recorded, and false otherwise (if, for instance, name is not the name of one of the candidates). The record_preferences function is called once for each voter, and takes as argument the ranks array.

How to solve the ” Tideman ” problem in CS50?

For example, if there are three candidates Alice, Bob and Charlie, then Alice will be [0], Bob will be [1] and Charlie will be [2]. If the voter votes for Bob in rank 1, Charlie in rank 2 and Alice in rank 3 then the outputted ranks array will be [1, 2, 0] for that voter.

How to sort pairs in order of strength of victory?

The sort_pairs function should sort the pairs array in decreasing order of strength of victory, where strength of victory is defined to be the number of voters who prefer the preferred candidate. If multiple pairs have the same strength of victory, you may assume that the order does not matter.

When to increment pair count in CS50 pset3?

Recall that pair_count is initially equal to zero, as defined within the main function. pair_count should then be incremented, which allows the next pair to be inserted at the next position in the array.

What is the goal of the Tideman problem?

Goal: To write functions to determine the winner of a tideman election and to print the name of the winner. Before reading further it is important to understand how a tideman voting system works, which is explained in the problem description.