- Tell us something that you learned this week?
This week in class we worked on an open source code together as a class! It was neat in the way that we were all working on the project at the same time. Where one of us got stuck another picked up the slack and we kept making improvements to the code that we were working on!
2. What are the pros and cons of immutability?
A big pro to immutability is the fact that nobody can change or alter the code that you have written. This would be the best way to go if you are working solo on a project and nobody is going to ever see your code. The cons to having immutable code is exactly that! Once complete you will not be able to make changes later on down the road. This can be bad when working with another developer who saw something that could use some improvement!
3. How can you achieve immutability in your own code?
One way to help your code be immutable is to use CONST rather than LET when making a variable! Let allows that variable to be changed further down the code. While Const insures you that the value of that variable will remain the same throughout!
4. 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?
It is used effectively in soreting, merging and multiplying large numbers! An example that we learned in class is binary search. This was a way to take a large list of items and then break down that list in half depending on what half the item that we were looking for it is on. It then breaks down that half in half by the same principle. it repeats this until it has singled out what we are looking for or it discovers that what we are looking for does not exist in the current context.
5. Explain the difference between mutable and immutable objects.
The difference is that immutable cannot be changed and mutable can be changed. The easiest example is variables being announced with const and let. Const is permanent while let is not. Let is expected to change once or even multiple times throughout the code.
6. What are the three laws of algorithm recursion?
The three laws of recursion are as follows:
A. a recursive algorithm must have a base
B. A recursive algorithm must change its state and move toward the base case.
C. A recursive algorithm must call itself, recursively.