I’ve watched the second lecture of 6.006. This lecture discussed different sorting algorithms and the advantages of each; the quickest is MergeSort, which can sort a list in nlogn time. This lecture was mainly a review of sorting as we learned it in 6.0001, the main difference being the analysis done on each algorithm and the conversations that followed on complexity and recurrence trees. I need to review some of the math behind solving recurrence relations, but other than that, this lecture was pretty comfortable and interesting.
It appears that there are no lecture recording for 6.005, so I have to make do with the readings posted on OCW. I’m hoping that will be enough for me to complete the assignments. The second reading focused on “Basic Java.” This reading continued to highlight some of the main differences between Python and Java and discussed the following methods for lists: .size(),.add(), .isEmpty() (Python analogs are len, append, and if not). A short discussion on mutable and immutable types followed with the relevant snapshot diagrams. This was still mainly review from 6.0001, so nothing too bad here.
Following these concepts was an introduction to more Java data structures.A Map is to Java as a dictionary is to Python. We use the following methods on maps:
map.put(key,val) <—> (map[key]=val in Python)
map.get(key) <—> (map[key] in Python)
map.containsKey(key) (<—-> key in map in Python)
map.remove(key) (<—-> del(map[key]) in Python)
How to declare generic types: List<String> cities;
Set<Integer> numbers
Map<String,Integer> hash
Notice how the types of each basic data structure are capitalized and how we must declare which variable types are contained in the generic type. This is very different than in Python.
This concludes the 2nd reading for 6.005. I’m going to move onto learning some basic SQL syntax next to complement my Python and aid my ambitions to build and manipulate databases.
I have started using sqlzoo.net to learn some of the basic syntax rules of SQL. I’ve been introduced to the following functions: FROM, SELECT, WHERE, SUM and COUNT. This website has some pretty basic problems you can solve to get you coding in SQL right away. Here is a basic query I wrote to select the countries with the largest area in each continent. The table here is called ‘world.’
SELECT continent, name, area FROM world x
WHERE area >= ALL
(SELECT area FROM world y
WHERE y.continent=x.continent
AND population>0)
I’ve spent the last hour or so on leetcode solving problems. I’ve solved two leetcode questions today; not amazing but not bad either. I am getting better at these, but a lot of the easy questions still require me to think pretty hard about them. It’s good practice though.
Here is the code for one of the problems I solved today, which implements a dynamic programming solution using the bottoms up approach.
The following parts of this blog post are only tangentially related to programming. I decided to update my resume to include the MIT OCW classes I’ve completed as well as some of the more substantial projects I’ve done. I am also beginning to reach out to alumni in my network to pick their brains and ask for guidance in this journey. That’s all for today!