Blog 206

David Hebert
2 min readNov 15, 2020

Tell us about something you learned this week.

I cemented the ideas of object classes and constructors. Being able to create multiple objects in the same class can definitely help with coding functional programs.

What are the pros and cons of immutability?

From what I understand, it’s mostly pros. It allows for more control over your code, allows you to work with redux and react without as many issues. The only real con I could find is that sometimes it can be confusing if you use const on a value, but end up trying to change it later.

How can you achieve immutability in your own code?

By using const instead of var or let for values that are not supposed to be changed.

What are Divide and Conquer algorithms? Describe how they work. Can you give any common examples of the types of problems where this approach might be used?

Divide and Conquer algorithms work by splitting a problem into two similar problems and solving them. It does this repeatedly until the original problem is simple enough to be solved on its own.

How do insertion sort, heap sort, quick sort, and merge sort work?

What are the key advantages of insertion sort, quick sort, heap sort and merge sort? Discuss best, average, and worst case time and memory complexity.

Explain the difference between mutable and immutable objects.

Mutable objects can have their value changed after being declared, while immutable objects cannot.

What are the three laws of algorithm recursion? Describe them in your own words and what they mean to you.

  1. A recursive algorithm must have a base case. — This basically means that it needs to be able to be reduced to a problem that it simple enough to be solved directly.
  2. A recursive algorithm must change its state and move toward the base case. — Simple enough, this just means that it must be able to be changed so that it can eventually be put into its base case.
  3. A recursive algorithm must call itself, recursively. — The algorithm must call itself.

--

--