Skip to main content

Command Palette

Search for a command to run...

CS50 #Week 3 — A Clear Guide to Algorithms

Published
4 min read
CS50 #Week 3 —  A Clear Guide to Algorithms
A
I’m a curious learner and aspiring software developer who enjoys building real-world systems, exploring new technologies, and learning in public. I write about coding, personal growth, and turning ideas into practical systems—while simplifying complex concepts for others.

This week of CS50 honestly hit different.

Even though I come from a computer science background — and I’ve already studied searching, sorting, and Big-O — Week 3 felt like that moment when you clean your room and suddenly find things you forgot you even owned.
It wasn’t about learning something new…
It was about understanding the fundamentals better than ever before.


🔍 Searching — More Useful Than I Remember

Searching seems simple: linear vs. binary.
But CS50’s visuals and clarity made the ideas feel fresh.

Check every item one by one — like looking through every pocket when you lose your keys.

Works only on sorted data, but the efficiency is insane.
Jump to the middle → cut the problem in half → repeat.

It reminded me why O(log n) is such a powerful curve compared to O(n).
You don’t notice it with small lists — but at scale, it’s a game changer.


📊 Sorting — My Favorite Topic This Week

Sorting is something I used to take for granted.
But CS50 gives each algorithm its own personality.

Bubble Sort — The Slow Friend

Keeps swapping until everything is in the right order.

Selection Sort — The Organized One

Find the smallest item and place it properly.
Still O(n²), but more structured.

Merge Sort — The Genius

Split → sort → merge.
Watching recursion work step-by-step made me finally appreciate recursion instead of fearing it.


🔢 Big-O, Ω, Θ — A Clean Mental Reset

Most of us only think about worst-case Big-O.
But CS50 forces you to remember:

  • Ω (best case) matters

  • Θ (tight bound) matters

  • Understanding growth > memorizing formulas

It felt like remembering the plot of a movie I watched years ago.


🔁 Recursion — Surprisingly Enjoyable

Recursion used to feel like mysterious magic.
This week, it felt like clean logic:

  • A base case

  • A smaller version of the problem

  • Combine the results

Seeing merge sort use recursion made everything click perfectly.


🧩 Problem Set 3 — The Real Adventure

This week’s problem sets were honestly some of the most fun so far.


🕵️‍♂️ 1. Identify the Sorting Algorithm

You're given three mystery programs:

  • sort1

  • sort2

  • sort3

With datasets:

  • sorted

  • reversed

  • random

Your mission:
figure out which algorithm each program uses without seeing the code.
Just run them, observe behavior, compare performance.

It felt like algorithm detective work 😂 — and it teaches you how runtime patterns reveal an algorithm’s identity.


🗳️ 2. Plurality — Basic Voting { code }

A great introduction to structs, arrays, loops, and comparisons.

  • Count votes

  • Track candidates

  • Print the winner

Simple, but excellent fundamental practice.


🔄 3. Runoff — Ranked-Choice Voting { code }

A real step up in complexity.

  • Voters rank candidates

  • Lowest-ranked is eliminated

  • Votes get redistributed

  • Repeat until someone wins

So many edge cases — but extremely satisfying when everything works.


🏆 4. Tideman — The Most Brain-Stretching One { code }

This was the real boss fight of Week 3.

Simulate the Tideman voting system, which avoids vote splitting and ensures a true majority preference.

Tasks include:

  • Recording preferences

  • Pairing candidates

  • Sorting pairs by strength

  • Locking pairs without creating cycles (the tricky part!)

  • Printing the winner of the final graph

Tideman forces you to think in terms of graphs, cycles, order of locking, and recursion logic.
It’s the kind of problem that frustrates you… then teaches you more than you expected.

Easily one of the best algorithmic exercises in CS50 so far.


✨ Reflection — Why This Week Mattered

Looking back, this week wasn’t just about algorithms — it was about rediscovering the beauty behind them. I realised that I often “know” algorithms in a mechanical way, but not always in a deep, conceptual way. Revisiting best-case, worst-case, and tight-bound analysis also made me understand why these distinctions actually matter. Merge sort finally made recursion feel practical instead of abstract, and the problem sets pushed me to analyse behaviour rather than just write code.

This week genuinely changed the way I understand computer science. I thought I already knew searching, sorting, and Big-O, but the lectures and exercises helped me see these topics with much more clarity.

I also want to be completely honest about how I learned. I used AI, YouTube, and online explanations whenever I was stuck, and those resources helped me understand the logic behind the problems. The final problem, Tideman, was especially challenging for me. I struggled a lot with the graph cycle-detection logic, and after many attempts, I eventually watched a full solved video to understand how it really worked.

I don’t see this as something negative. I learned that good learning isn’t about doing everything alone — it’s about staying curious, seeking help when needed, and coming back stronger. What matters is that I stayed committed, understood the concepts in the end, and kept moving forward


Stay tuned for my next post
This is just the beginning of my CS50 adventure 🚀

More from this blog

Weekly update

7 posts

A quiet record of weekly growth, learning, and making. Simple notes from a continuous journey of improvement