Parallel and Distributed Algorithms - Part 1
Introduction to Parallel and Distributed Algorithms. Part 1: Theoretical article.
Welcome back, brave coder šØāš»! Iām really happy and excited to be back today to writing, after a two weeks pause! These two weeks felt like a year for me, haha. But anyway, weāre back and today, we will embark on an epic adventure through the magical land of Parallel and Distributed Algorithms. If these words sound intimidating, don't worry! I was there too, we're going to turn this learning process into a fun, easy, and exciting experience.
Ready? Letās go Ala Barakati Lah š
What the Hell is Parallel and Distributed Algorithms?
Imagine you're a knight š¤ŗ, and your kingdom š° is under attack by an army of monsters š§āāļø. Would you fight them alone, and beat them one by one? If you say yes to this, believe me, thatās like running a single-threaded program. Slow and exhausting š„“ļø!
But what if you had a team of knights š¤ŗš¤ŗš¤ŗš¤ŗ, each one take on a monster at the same time? Thatās a better strategy, right? Thatās parallel algorithms! And if your knights are spread across different castles š°š°š°, each defending their local village, for example, that's distributed algorithms.
See? Thatās easy, you know understand whatās parallel and distributed algorithms mean. Now letās dive into each one of them, and try to explain it in computer science words!
Chapter 1: Parallel Algorithms 
In parallel computing, the goal is to divide and conquer. Hereās the cheat sheet:
- The Hero is the CPU or GPU 
 Think of your computer's processor as the hero of the story. It has great power but also limits. Parallel algorithms help the hero (CPU or GPU) use their full potential/power.
- The Threads or Processes 
 Each thread is like a warrior in your war (task to do). They're good at handling a specific task. When they work together, things get done faster!
- The Tasks 
 Break your big quest (problem) into smaller tasks. For example, if you're baking 100 cakes, donāt do it all by yourself! Assign one cook to mix ingredients, another to bake, and another to decorate!
Example Challenge:
Imagine sorting a treasure chest full of gold coins. A parallel algorithm might:
- Have one thread sort small piles of coins. 
- Have another thread combine those sorted piles. 
- Done! 
Chapter 2: Distributed Algorithms
Now, letās say the monsterās army is so big that you need helps from neighboring kingdoms. Itās here when distributed algorithms come into play:
- The Network Map 
 Your computers (nodes) are like distant castles connected by roads (networks). These nodes work together to solve problems.
- Communication 
 Nodes exchange information via messages. Itās like sending a pigeon with a message on her leg saying, āIāve defeated my monster, how about you?ā
- Fault Tolerance 
 Sometimes, roads get blocked, or pigeons go missing (get hunted lol). Distributed algorithms plan for this, ensuring the mission continues even if a few nodes fail.
Example Challenge:
Letās say you want to count the monsters that attacked all the kingdoms. Each node counts its local monsters and sends the number to a central castle. And the central castle adds up the numbers. Easy-peasy (as long as the pigeons donāt get lost š ).
Chapter 3: Theoretical Concepts
Okay, time to learn about the concepts of both parallel and distributed algorithms. These are the big ideas youāll need to know, donāt bother yourself with anything else:
- Speedup and Efficiency - Speedup: How much faster can your team solve the problem compared to doing it alone? 
- Efficiency: Are all your team members are busy? Or is one of them relaxing? 
 
- Load Balancing 
 You donāt want one knight fighting 100 monsters, while another knight is chilling doing nothing! Distribute the work evenly!
- Latency vs. Throughput - Latency: How fast does a single task get done? 
- Throughput: How many tasks can you complete at once? 
 
- Synchronization 
 If one team member finishes their task too soon, they might need to wait for others to catch up. Thatās synchronization (maybe I will write a dedicated article about this concept soon!). Keep the team in sync!
Why Should You Care?
Parallel and distributed algorithms are the backbone of modern technology:
- Streaming services like Netflix? Parallel algorithms process your favorite shows. 
- Online games? Distributed algorithms keep everyone in sync, whether they're in āSafi, Moroccoā or in āCartagena (9artahenna haha), Colombiaā. 
- NASA, SPACE X, TESLA, and all high level companies use these concepts! So, you must to understand them too! 
Wrapping it up!
Congratulations! Youāve survived Part 1 of the Parallel and Distributed Algorithms Quest. Hereās what youāve learned:
- Parallel algorithms are like a teamwork in the same place. 
- Distributed algorithms are like a long-distance alliance between kingdoms. 
- Key ideas like speedup, load balancing, and synchronization help you slay big problems. 
Next time, weāll dive into the best part which is coding! Until then, happy coding guys, see you later!
Stay tuned for the next one!
š Don't forget to subscribe to my blog and YouTube channel to stay updated with all the latest content, follow me on LinkedIn too, if you like to do so!




