Member-only story

[CS]CS50 Week3: Algorithms

Penny N.
3 min readOct 11, 2020

--

I thought we would be asked to implement sorting and searching methods we learned in week 3 in this week’s assignments, but it turned out the assignments have nothing to do with them😂

Since the problem sets are getting complex as entering week 3, CS50 provides predefined programme structure and breaks down the programme into small functions. All we need to do is to complete the functions that are left empty.

Assignment 1: Plurality

Background:

In a plurality election, every voter gets one vote, and the candidate with the most votes wins.

Spec:

Complete the vote function. Validate the input name. If it matches one of the names of candidates, update that candidate’s vote and return true. Otherwise return false.

Complete the print_winner function. Print out the name of the candidate(s) who received the most votes

--

--

Penny N.
Penny N.

Written by Penny N.

A passionate self-taught  iOS developer. Write to record my learning and share the knowledge

No responses yet