Class 12 — Prompt 206
- Tell us about something you learned this week.
Started to learn about the basics of using APIs and using fetch to get data from them. This has been the hardest topic for me so far to wrap my head around but I think it will become more second nature with more practice.
- What are the pros and cons of immutability?
Pros: can reuse objects, good for sharing information, can be simpler to think about, dont have to worry about object evolution
Cons: can be difficult to build, performance may suffer
- How can you achieve immutability in your own code?
Strings and numbers are inherently immutable.
- 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?Breaks down a problem into smaller sub-problems. An example would be using 3 separate functions to each do their own specific thing and bringing them altogether at the end as to not complicate one single function. Useful in long, multi-step problems.
- How do insertion sort, heap sort, quick sort, and merge sort work?All of these are different ways to attempt to sort different arrays.
- 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.
Merge: pros- can be applied to any size. cons- may be less efficient
Heap: pros- efficient, can be used as an in place sorting algorithm. cons- quick sort is often more efficient, requires more space for sorting
Quick: pros- regarded as the best sorting algorithm, can deal with large list of items, no additional storage needed. cons- in certain scenarios others may work better
Insertion: pros- Simplicity, good when dealing with a small list. cons- does not perform as well as other sorting algorithms, especially with large lists.
- Explain the difference between mutable and immutable objects.
mutable objects can be changed while immutable objects cannot.
- What are the three laws of algorithm recursion? Describe them in your own words and what they mean to you.
Recursive algorithm must have a base case
Recursive algorithm must change its state and move toward the base case
Recursive algorithm must call itself, recursively