CS50 Problem Set 3 - Plurality Solution (Step by Step Walkthrough for Beginners)

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 พ.ย. 2024

ความคิดเห็น • 128

  • @semple888
    @semple888 2 ปีที่แล้ว +62

    These walkthroughs help me so much,
    Can you please keep uploading the rest of the weeks of CS50.
    thank you so much for helping everyone.

  • @kevinplascencia1131
    @kevinplascencia1131 2 ปีที่แล้ว +56

    I wouldn't be able to finish pset1 and pset2 without your help, in pset3 however, I was able to finish the first assignment all by myself and I watched your video to solve the 2nd assignment, I feel like I am getting better and you're helping me a lot, thank you so much.

    • @Jack_______oh
      @Jack_______oh ปีที่แล้ว

      By the first assignment do you mean the lab, or this problem?
      I still feel as lost on this one as I did with previous problem sets. I have a lot of pseudo code written out and have implemented some of it, but I get tripped up when it comes time to sort the data after the votes have been counted. If you figured that out on your own, props, because I am totally lost on it.
      Gonna watch this video to hopefully work it out.
      EDIT: Lol. This solution was much simpler than what I was attempting. Still so much to learn!

    • @Нива-ш7з
      @Нива-ш7з ปีที่แล้ว

      @@Jack_______oh yeah it always seem so easy after you realize the solution. I didn't know about nested loops so I couldn't do mario, but after the videos I went back to it and I could do it in minutes

  • @MrBobbtyGT
    @MrBobbtyGT 2 ปีที่แล้ว +29

    These walkthroughs are extremely helpful. The way you write out the problems in a word document helps to visualize the actual code. Great videos

  • @desistarrecords
    @desistarrecords 2 ปีที่แล้ว +7

    You're doing such a great job. Not having a CS background and still nailing the couree and teaching/helping others. It's such an achievement.

  • @oliviacolton3661
    @oliviacolton3661 2 ปีที่แล้ว +14

    Still don’t understand what you get out of this, but you’re saving my life. Thank you!

  • @alliemiles5109
    @alliemiles5109 2 หลายเดือนก่อน +1

    This young man is the best on the net! He really breaks things down and makes them completely understandable! Thank you Rahul!!! I am sad that your last problem set walkthrough is this one. If I join your channel can I perhaps get access to subsequent walkthroughs?

  • @mitchschlesinger4326
    @mitchschlesinger4326 ปีที่แล้ว +6

    You do a great job explaining the "why" as well as the "how to." Keep up the good work!

  • @keithb0000
    @keithb0000 ปีที่แล้ว +1

    Our dude left us to become tiktok famous in his country. Thanks for all the help so far dude! Wish you completed the whole CS50 with us!

  • @zaheer25
    @zaheer25 2 ปีที่แล้ว +2

    I love how you walk through the problem. The main thing I have learnt from your videos is how to walk through the code and make sense of it. With Pset2 I relied a lot on your video. This time I tried to think the way you were thinking and got pretty far on my own. Thank you!

  • @austin9070
    @austin9070 2 ปีที่แล้ว +1

    The sudo code you write in word document really help visualize the solution.....it need not let me look at the actual code....
    Great video 🤞

  • @chidebrutechs
    @chidebrutechs 2 ปีที่แล้ว +2

    I'm still in PSET1 but I love your explanations...they are on point, keep on the good work...you are unlocking many dreams...CS50 isn't for the faint-hearted, your push is welcomed wholeheartedly bro. Much love from KE

  • @Split-Sanity
    @Split-Sanity 3 หลายเดือนก่อน

    Im here in 2024 and these videos have been great could you please finish the walkthroughs im struggling without your help I have watched all your walkthrough videos and I cant continue without these videos

  • @coffeemiss1150
    @coffeemiss1150 ปีที่แล้ว +1

    The best series of videos for CS50's problem sets since the explanations are from learners' perspectives. Thank you so much Rahul~

  • @a.iso.thirdgenerationstudios
    @a.iso.thirdgenerationstudios ปีที่แล้ว

    to put your thinking into words that I can understand is a mystery that only you have been solving. thank you.

  • @rebekahmenn2118
    @rebekahmenn2118 2 ปีที่แล้ว +1

    I would not have gotten this code without your video. I still don't understand it entirely, but I definitely learned something. Thank you!

  • @ansh4131
    @ansh4131 3 หลายเดือนก่อน

    For the first time , i did some coding in project by myself in C , Thanks for the walkthrough , i could understand the concept and finally able to it.

  • @gabsmary
    @gabsmary 2 ปีที่แล้ว +8

    Cara, não desiste de fazer os vídeos, as explicações são maravilhosas.

    • @matheuslima793
      @matheuslima793 2 ปีที่แล้ว

      Br tu acha em tudo quanto é lugar kkkk
      o mlk é pica nas aulas

  • @eva3696
    @eva3696 ปีที่แล้ว +1

    A very professional and simple way of explanation of not simple things ( I’m a beginner) thanks to you I started to understand and even sometimes know what we need to do the next step and etc , a very pleasant voice and high quality of the video thank you for your efforts , your video I want to watch again and again 👍🏻

  • @coltoneaston4621
    @coltoneaston4621 2 ปีที่แล้ว +15

    21:45 bruh 😂

  • @iHaterzXD
    @iHaterzXD 2 ปีที่แล้ว +4

    Dude 21:43 had me laughing so hard. Great video! I was able to get through updating the candidate vote count, but was unable to figure out that the "print winner" portion should be broken down in two steps. Your videos are extremely helpful, thanks so much for taking the time to create them.

    • @sahilvermaH
      @sahilvermaH 9 หลายเดือนก่อน

      david malan handsome cs50 🤣🤣

  • @bells5967
    @bells5967 2 ปีที่แล้ว

    You have no idea how helpful and simple your help is. Thank you.

  • @martinhansen5521
    @martinhansen5521 2 หลายเดือนก่อน

    20:20 watch out for the small change from < to ; at line 85

  • @ajaramillo1109
    @ajaramillo1109 ปีที่แล้ว

    Please keep uploading these walkthroughs they help so much! I understand it better when you explain it.

  • @Aripepe
    @Aripepe 2 ปีที่แล้ว +3

    Thanks again for explaining it so well. We missed you man! :)

  • @ricardo-hf6er
    @ricardo-hf6er ปีที่แล้ว

    come back for the rest of cs50!!
    us new coders need you!

  • @brandonclark3530
    @brandonclark3530 ปีที่แล้ว

    thank you, man. i was beginning to feel I cannot understand this. you're a good teacher

  • @shayan4572
    @shayan4572 2 ปีที่แล้ว +2

    It would be great if you continue uploading these videos

  • @austinjday3768
    @austinjday3768 2 ปีที่แล้ว

    honestly this guy is my hero

  • @MichaelNealeYT
    @MichaelNealeYT 2 ปีที่แล้ว

    Thank you for making these videos. I appreciate how you step through the expected outcomes and give some more explanation before showing your solution. I try to use your videos as a last resort and struggle as long as I possibly can.

  • @louiejacobson552
    @louiejacobson552 7 หลายเดือนก่อน

    Killer maine! You're a beast! Wish we had more of your videos explaining general topics like functions. Hope you're doing well out there.

  • @shahdelsayed8090
    @shahdelsayed8090 2 ปีที่แล้ว

    wooow tbh i never knew i could do it as a total beginner thank u soo muchhh

  • @marwan9995
    @marwan9995 2 ปีที่แล้ว

    thnks man you help me and make me understand more what i learnd in cs50.
    my english not that good but i understand your clean language.

  • @finbarharris7069
    @finbarharris7069 ปีที่แล้ว

    love the videos man, there so helpfull. This is the first week i was able to go ahed by myslef and solve the print_winner section. Keep it up x

  • @الطيبعثمان-ظ6ف
    @الطيبعثمان-ظ6ف 2 ปีที่แล้ว +1

    man where are you ,
    we are waiting for you

  • @henriquedelben
    @henriquedelben 2 ปีที่แล้ว +1

    I was trying to implement a merge sort algorithm to order all candidates of the array by the number of votes each one had, but it turned out I'd need to create another function to implement the divide part and then another to implement the merge part, this way is really more simple and makes more sense in a real life type of occasion since in a pluralized vote, the number of cadidates wouldn't be much bigger than 10, so it wouldn't make the program slow or something

  • @mynamehereforsure
    @mynamehereforsure 2 ปีที่แล้ว

    Perfect timing, I was looking for your walkthrough for this pset a few days ago

  • @AlejandroDeLaRosa05
    @AlejandroDeLaRosa05 2 ปีที่แล้ว

    thank you for all your videos! you have no idea how much they've helped me. Sometimes just semantics alone lead me to errors but you are able to explain concepts pretty well.

  • @1d_4e32
    @1d_4e32 ปีที่แล้ว

    amazing vid as always so grateful for these rahul!

  • @QK_Engineer
    @QK_Engineer 2 ปีที่แล้ว +1

    You’re the best bro! Keep up these videos they are so helpful!

  • @tommybc
    @tommybc 18 วันที่ผ่านมา

    Your tutorials are great, thank you for making them. In this one, up to timestamp 19:43 you have this code for the for loop in your line 85: for (int i = 0; i < candidate_count < i++). This does not compile as it should be, (int i = 0; i < candidate_count; i++), but you don't explain that error in the code we watch you write in the body of the video. How come? Thanks.

  • @maxmccann3617
    @maxmccann3617 ปีที่แล้ว

    For anyone else who was confused, argc DOES NOT need to be greater than 2 as he stated in the video. Argc needs to be equal to or greater than two. The program is designed to run with only one candidate. Also, in case you get an error when you compile, in the video, he fixed a type-o on line 85 without showing it.

    • @DallasKeana
      @DallasKeana ปีที่แล้ว

      which type o

    • @maxmccann3617
      @maxmccann3617 ปีที่แล้ว

      @@DallasKeana should be a semicolon after candidate_count and no less than symbol.

  • @zuku4399
    @zuku4399 2 ปีที่แล้ว

    thanks! it really helped me understand another way of solving the problem

  • @fai9092
    @fai9092 ปีที่แล้ว

    thank you so much for the help throughout these courses

  • @parsahoseiniyan6397
    @parsahoseiniyan6397 2 ปีที่แล้ว

    perfect. your videos are so helpful. and they help to think more logically

  • @MrJaywhelan
    @MrJaywhelan ปีที่แล้ว

    loving this videos! how come you haven't added any more since?

  • @davidcottrell1308
    @davidcottrell1308 2 ปีที่แล้ว

    Thanks..very nicely and thoroughly explained.....keep it up....

  • @bedstuy89
    @bedstuy89 2 หลายเดือนก่อน

    hey brother you are an absolute lifesaver. thank you for all your hardwork. any chance you can make a video on problemset 3 runoff? thanks so much
    peace be upoon you

  • @yasminetabbech2490
    @yasminetabbech2490 2 ปีที่แล้ว +2

    when he says " its very simple right " i want to jump out of a cliff , ITS NOT SIMPLE FOR BEGINNEEERS . hahah
    Thanks alot tho you are helping alot

  • @liamfinn564
    @liamfinn564 2 ปีที่แล้ว

    You should post more of these, man

  • @courtneylynne1103
    @courtneylynne1103 ปีที่แล้ว

    Your videos are so helpful! I hope you upload more soon 🙂

  • @libo8318
    @libo8318 2 ปีที่แล้ว

    Please keep making man ! you are awesome

    • @CS50MadeEasy
      @CS50MadeEasy  2 ปีที่แล้ว

      Next PSet coming soon :)

  • @cristianm5658
    @cristianm5658 2 ปีที่แล้ว +1

    thanks for these walkthroughs, it is helping me a lot to learn and you are the best!
    lol 21:45

  • @ollietron128
    @ollietron128 ปีที่แล้ว

    Thanks for your videos, they're really helping me to grasp the problems. Do you think watching these videos as help violates the academic honesty guidelines?

    • @woopslynx
      @woopslynx ปีที่แล้ว +1

      I think technically they do but its almost impossible without external help in a few cases

  • @shankarenputten952
    @shankarenputten952 2 ปีที่แล้ว +1

    Plzzz release the walkthrough of the other problem set.
    I cant wrap my mind around pset3: runoff

  • @relaxation2018
    @relaxation2018 2 ปีที่แล้ว +1

    hi will you make a video on problem set 4?

  • @leudisfit6001
    @leudisfit6001 ปีที่แล้ว

    amazing video

  • @haiyihuang3299
    @haiyihuang3299 ปีที่แล้ว

    thank you so much! your explain is so helpful ! will you do more of these problem sets? :(

  • @justinzhou
    @justinzhou ปีที่แล้ว

    thank you

  • @Everson_Code
    @Everson_Code 4 หลายเดือนก่อน

    Thanks.

  • @Nonsense855
    @Nonsense855 ปีที่แล้ว

    thank u so much bro

  • @greenrbtsiqi
    @greenrbtsiqi 2 ปีที่แล้ว +2

    For the bool vote function, why is the condition set as "i < candidate_count" instead of "i < voter_count"? I understand it as if the number of votes is smaller than the total number of voters, then it should keep on counting. If "i < candidate_count", then it seems to be counting the number of votes up to the number of candidates. For example, if there are 3 candidates and 7 voters, by using "i < candidate_count", it feels like we are counting only 3 votes. Please let me know your thoughts. Thank you.

    • @lakshay964
      @lakshay964 2 ปีที่แล้ว +1

      The loop is to find if the vote submitted by the user is actually a valid vote or not so we run through every candidate's name and how many names will there be? Equal to the no. of candidates and not voters. Hope it helps

  • @otrongkhoa1544
    @otrongkhoa1544 ปีที่แล้ว

    I have expected you would have used some kinds of complex sorting algorithms like merge sort v.v. Are the trade-offs of time and space worth to implement these ?

  • @MagicalShizzz
    @MagicalShizzz 2 ปีที่แล้ว

    awesome! thanks so much!

  • @artgrantolli4790
    @artgrantolli4790 2 ปีที่แล้ว +1

    yoo bro this was very helpful can u do a video on lab4 and problem set 4 aswell ?

  • @limweiloong8256
    @limweiloong8256 ปีที่แล้ว

    hi bro will u be doing more ? this is really helpful and it makes it a lot easier for uws begginers. pls continue to help us out :D

  • @SirMika9
    @SirMika9 ปีที่แล้ว

    Damn, you print_winner solution is nice. I did more complicated and it was so simple. I sorted the entire candidates array lol. But at least it worked and I am able to do sort function by mysefl, so I am happy :D I really like your way of thinking the problem to a simple solution on paper. I need to be better at that. Thanks for sharing your solution, so we can compare and learn more after we finished the problem ;)

  • @desistarrecords
    @desistarrecords 2 ปีที่แล้ว

    Please upload all.

  • @Domlalvaro
    @Domlalvaro 2 ปีที่แล้ว

    watching you making your exercise, Im fell afraid off just like: "My God, Will I ever learn and begin to understand this?"😥

  • @oluwatunmiseesther8832
    @oluwatunmiseesther8832 2 ปีที่แล้ว

    You are the best though...keep it up bruv

  • @arnschoeny
    @arnschoeny ปีที่แล้ว

    if 'name' is the only parameter being passed to the function vote, how does it work that you can compare 'name' to 'candidate[i].name'. Is 'candidate.name' a global variable?

  • @sereynavives1389
    @sereynavives1389 ปีที่แล้ว

    can you please do runoff and following weeks ! i need the help

  • @BestYTshorts4uo
    @BestYTshorts4uo 2 หลายเดือนก่อน +1

    // Print the winner (or winners) of the election
    void print_winner(void)
    {
    int max_votes = 0;
    // First pass: find the maximum number of votes
    for (int i = 0; i < candidate_count; i++)
    {
    if (candidates[i].votes > max_votes)
    {
    max_votes = candidates[i].votes;
    }
    }
    // Second pass: print the names of all candidates with the maximum number of votes
    for (int i = 0; i < candidate_count; i++)
    {
    if (candidates[i].votes == max_votes)
    {
    printf("%s
    ", candidates[i].name);
    }
    }
    }

  • @repp181
    @repp181 ปีที่แล้ว +1

    when I try to compile, I have an error on line 71 saying error: use of undeclared identifier 'i'
    if (strcmp(candidates[i].name, name) == 0) with the arrow pointing the [i]
    can someone help me ?

  • @MohamMeD-kd8gj
    @MohamMeD-kd8gj 2 ปีที่แล้ว

    please post all problem sets and labs please please

  • @artiphoria
    @artiphoria 2 ปีที่แล้ว

    Man, you're awesome and the idea of this program is ultimately stupid and unreasonable. As , how come I enter the names of the candidates, and also chose each number of elected candidate? I know it's for educational purpose, but reality counts.

  • @mannasingh1931
    @mannasingh1931 ปีที่แล้ว

    thank u bro

  • @courtneynel7433
    @courtneynel7433 2 ปีที่แล้ว +1

    is line 85 correct? I'm getting a "plurality.c:85:46: error: expected ';' in 'for' statement specifier
    for (int i = 0; i < candidate_count < i++)

    • @andrewcraigbrown2933
      @andrewcraigbrown2933 2 ปีที่แล้ว +3

      He made a mistake and edited out himself fixing it. '< i++' should be '; i++'

  • @arjaymarioncodilla6711
    @arjaymarioncodilla6711 2 ปีที่แล้ว

    Thankyou!!

  • @Ls-yg4od
    @Ls-yg4od ปีที่แล้ว

    i was stuck cuz i was typing for (i = 0; i < strlen(name); i ++) and it wasnt working untile i tried for (i =0; i < candidate_count; i ++)

  • @yahyasamet5499
    @yahyasamet5499 2 ปีที่แล้ว

    nice brooo

  • @agustin8160
    @agustin8160 2 ปีที่แล้ว +3

    :( vote returns false when given name of invalid candidate
    vote function did not return false
    :( vote leaves vote counts unchanged when voting for invalid candidate
    vote function modified vote totals incorrectly
    Does anybody knows why this is happening?

    • @bookwormd8627
      @bookwormd8627 ปีที่แล้ว +2

      I know its been close to a year but I'm replying in case anyone else is having this problem.
      Both of your errors are connected, you're probably missing a return false line in the bool vote function:
      bool vote(string name)
      {
      for (int i = 0; i < candidate_count; i++)
      {
      if (strcmp(name, candidates[i].name) == 0)
      {
      candidates[i].vote++;
      return true
      }
      }
      return false;
      }
      If you don't have that line, the program counts a vote for an invalid candidate

  • @jayfrayy2368
    @jayfrayy2368 2 ปีที่แล้ว

    I'm like 90% done pset 3 runoff but I'm stuck on a few things are you going to be making a video soon?

  • @farrasdarysantosa8682
    @farrasdarysantosa8682 5 หลายเดือนก่อน

    21:34 bro got humours

  • @tramthuy6190
    @tramthuy6190 2 ปีที่แล้ว

    hi, what does it mean when the code is "return 2" in populate array of candidates?

  • @TheRealPlayer00
    @TheRealPlayer00 2 ปีที่แล้ว

    Hey, did you stop with the tutorials? :(

  • @adebowaledollars1
    @adebowaledollars1 2 ปีที่แล้ว +1

    Can someone pls explain
    (1)why my code was counting the vote of the first candidate only because I had the return true line outside of the curly bracket
    for(int j=0; j

    • @gatewaynippon
      @gatewaynippon 2 ปีที่แล้ว +1

      return true; should be inside the curly brackets just below the candidates[i].votes ++ .
      This essentially means that the for loop will iterate all the candidates one by one and increment the vote count by one for the candidate whose name matches with the name the voter has voted for(hence a valid name) and return true and then for loop will keep on executing until all candidates have been iterated through.
      If you put return true; outside curly braces of if statement,
      the code iterates the first candidate ,counts its vote and then returns true (and moves on to next lines of code!) ,without iterating further.
      Hope this helps!

    • @adebowaledollars1
      @adebowaledollars1 2 ปีที่แล้ว +1

      @@gatewaynippon thank you, this helps.

  • @oluwatunmiseesther8832
    @oluwatunmiseesther8832 2 ปีที่แล้ว

    Please do 'credit' pset 1 assignment, I'm stuck, I don't know what to do

  • @RohanPadmukh-y9g
    @RohanPadmukh-y9g ปีที่แล้ว +1

    my code all good but just one mistake i placed one comparison operator incorrect '' 😂😂😂😂😂😂

  • @ashleygrant6370
    @ashleygrant6370 2 ปีที่แล้ว

    where'd you go my friend lab4 is murder and I need your genius brain to hold my hand through this mess

  • @ahmademad1
    @ahmademad1 2 ปีที่แล้ว

    where are you now my friend

  • @akaa2007
    @akaa2007 2 ปีที่แล้ว

    NOO PLEASE MAKE WALK THROUGHS FOR THE REST OF THE PROJECTSSS

  • @jonniejonnjon
    @jonniejonnjon 9 หลายเดือนก่อน

    why do they use "return 2" instead of "return 1"?

    • @darrelljustice45
      @darrelljustice45 7 หลายเดือนก่อน

      From my understanding, anything other than "return 0" is used to show failure, and each different return/exit value, such as return 1 or return 2, shows different parts in code that there was a failure or invalid input.

  • @Izanagli
    @Izanagli 2 ปีที่แล้ว +1

    it weird how i follow step by step and the IDE always says my "int = 0" is a fatal error.

    • @Izanagli
      @Izanagli 2 ปีที่แล้ว

      line 71. the "[i]" comes up as an error please help

    • @luchiya_darkness
      @luchiya_darkness 2 ปีที่แล้ว +3

      You can't assign(=) a value to a data type. You need to write which variable you are assigning 0 to. In your case, int i = 0, i is name of variable, int - just data type

  • @salahammar1521
    @salahammar1521 ปีที่แล้ว

    just my question is i cant do this alone i have to watch walkthroughs to be able to understand is that normal ???

    • @freddyhernandez8457
      @freddyhernandez8457 ปีที่แล้ว +1

      Yes, it's normal!! but you have to have a growth mindset, go ahead and spend hours trying, then watch a video and go through another part on your own, in my case, it took me 2 hours to do this exercise, and I came here to realize that I could improve myself code and see how to use better logic.

  • @TalkThisOut
    @TalkThisOut 2 ปีที่แล้ว +1

    noice!

  • @joeyestrada9071
    @joeyestrada9071 2 ปีที่แล้ว

    No matter what I keep getting "use of undeclared identifier i" and it's so annoying...

  • @barboodG
    @barboodG 2 ปีที่แล้ว

    Bro where is runoff

  • @kousenmujawar2387
    @kousenmujawar2387 ปีที่แล้ว

    Can someone explain me this code
    !vote(name)

  • @abdulaikamara2471
    @abdulaikamara2471 ปีที่แล้ว

    posting your Github account would be highly grateful, thanks

  • @jacoboapito9577
    @jacoboapito9577 2 ปีที่แล้ว

    i love you