Problem-solving strategies 👨🏻‍💻, event loop🔄 , npm 🆚 yarn

By Prajwal Haniya

Techletter #56 | January 21, 2024

Strategies for problem-solving in Computer Science

Problem-solving strategies refer to systematic approaches or techniques used to tackle and resolve computational problems.

Some of the strategies are:

  1. Iteration

    The iterative strategy consists in using loops (e.g. for, while) to repeat a process until a condition is met. Each step in a loop is called an iteration.

  2. Recursion

    A function calls itself until it reaches a base case & then returns a value. In other words, a recursive function is a function that solves a problem by solving smaller instances of the same problem. Recursion is based on the principle of divide and conquer, where a complex problem is broken down into simpler subproblems.

  3. Brute force

    Consider all possible solutions and select the one that satisfies the problem constraints. While not always the most efficient approach, brute force can be useful for small input sizes or as a baseline for comparison with more sophisticated algorithms.

  4. Backtrack

    Backtracking is a problem-solving strategy where you explore different possibilities and, if you hit a roadblock, you go back to the previous decision point and try a different option. It’s often used when you’re trying to find a solution to a problem with a lot of choices, and you want to efficiently explore those choices without wasting time on paths that lead to dead ends. It’s like navigating through options until you find the right one.

  5. Heuristics

    A heuristic method, or simply a heuristic, is a method that leads to a solution without guaranteeing it is the best or optimal one. A very common heuristic approach to problems is the greedy approach. It consists in never coming back to previous choices. It’s the opposite of backtracking. Try to make the best choice at each step, and don’t question it later.

  6. Divide & Conquer

    Break down a bigger problem in several small parts & then conquer it.

  7. Dynamic Programming

    Dynamic programming is identifying repeated subproblems in order to compute them only once.

  8. Branch & Bound

    Many problems involve minimizing or maximizing a target value: find the shortest path, get the maximum profit, etc. They’re called optimization problems. When the solution is a sequence of choices, we often use a strategy called branch and bound. Its aim is to gain time by quickly detecting and discarding bad choices.

How does the event loop work in nodejs? A simplified guide

One of the reasons for the high performance of nodejs is the event loop. It helps in managing asynchronous operations.

Event Loop Phases

Resource Link

Yarn vs npm

npm uses npm i to install packages and they are installed sequentially and it generates package-lock.json.

yarn uses yarn to install packages and they are installed parallely, so it’s quicker than npm.

What did I watch this week?

  1. System Design Mock Interview
  2. Latency Vs Throughput
  3. Advice from a Whatsapp engineer
  4. Building a flying umbrella
  5. Sam’s advice for people in their 20s
  6. Vim as your editor

What did I Read this week?

  1. System Design: DoorDash — a prepared food delivery service
  2. Yarn vs npm
  3. How chad built a No-code startup
  4. Product management is broken, a change is coming