Running Time Lecture
Regarding the lecture we dived more in depth into algorithm efficiency utilizing both slides and in-class activities. The professor began in a methodical manner first by introducing a variety of different time complexities with constants and then systematically correcting us of our first glance intuition. For instance many people were perplexed at the idea of time complexities like 5n and 10n not having any difference in terms of worst case running time, however a quick sketch of the functions with the assumption of a massively huge n value (length of the input parameter) helped clarify things.The second phase of the lecture had us tackle various sample programs and guess at their worst case running time in terms of Big O notation. The trickiest examples involved double loops with the loop variable increasing by an exponent, and programs that had if condition blocks with for loops included in them for added confusion.
It seems that the best technique to handle eccentric looking programs is to test with small values of n to get a sense of a pattern and then figure out whether a loop is running logn times, n times, n^3 etc; additionally Big O concerns extremely large values and therefore one should not be lured into certain if statements based on how much code is within it as shown in this example:
I personally fell prey to the elif n > 97 statement and concluded the running time was n, when really it was constant. Never again will that happen I swear!
Despite this week's material being less intensive than other weeks featuring recursion, I felt like it had more relevance due to the fact that I had been optimizing code for assignment 2 frantically. First by using better data structures like deque and ordered dictionaries and secondly by reducing as many nested loops as possible. For instance my grid peg solitaire used to have an n cubed running time because of a misplaced loop, but I managed to cut it down to just one nested loop bringing it to n squared running time.
Assignment Interview Preparation
The biggest tips I found regarding programming interviews is to understand how to translate programs into either intuitive diagrams or simple English. In addition, many people recommend that you are also able to dive anywhere in the code and be able to describe what that block of code actually does in the context of the entire program.
To better prepare myself I met with group members for a kind of 3 way interview session - we challenged each other to explain different parts of the assignment and occasionally smirking at the kind of comments we left in (ie: one member loved putting in Dark Knight Rises movie references). One habit we worked on was our penchant for getting bogged down describing the code on a micro level rather than a macro one - that is not always relating a segment of code to the overall functionality of the program. Thankfully we ironed such interview wrinkles out before adjourning our drill session.
For the interview I'm hoping that a big picture approach to explaining the code will allow me to stay within a 5 minute time-frame. However, just incase the interviewer decides to talk about one block of code for 5 minutes I've also familiarized myself with every swap, loop, or assignment statement. Bring it on Noel.
For the interview I'm hoping that a big picture approach to explaining the code will allow me to stay within a 5 minute time-frame. However, just incase the interviewer decides to talk about one block of code for 5 minutes I've also familiarized myself with every swap, loop, or assignment statement. Bring it on Noel.
Week 3 to Week 11 Reflections
I began my SLOG and CSC148 journey expecting increased difficulty and deeper thinking, and I wasn't wrong. As we got into more interesting data structures like trees and linked lists I found my CSC 108 skills becoming less and less predominant and more akin to a reinforcing scaffolding - it was soon clear that I had to develop different mental tools to fill the rest of the 'building' out. However difficult it was to utilize the new data structures and recursion techniques, I feel like the course has forced me to evolve from a fledgling computer scientist to a less... helpless computer scientist (not so dramatic of a level up I know!). To put it another way, the recursive and tree elements of this course are analogous to learning counter attack and 'tell' reading techniques from the martial arts world while CSC 108 taught the mechanics of punching and kicking.


