Date Modified Tags CS50 / CS161

CS 161

This summer I made the decision to go back to school to pursue a degree in Computer Science. I found out about Oregon State's Post Baccalaureate Computer Science program and immeadiately applied and was later accepted! The program is designed for students who already have a bachelors in something but would like to pursue a degree in computer science.

For the first term I decided to be conservative and just take the first class in the program, CS 161 - Intro To Computer Science 1. I wanted to make sure I didn't bite off more than I could chew!

CS 161 uses C++ which has been great for me because I already have prior experience with it from the C++ class I took at a local community college last spring.

I have been really impressed with the program so far. Oregon State's online systems are all top notch and I haven't had any issues. The instructor for the class is very responsive to students questions and I have yet to see a student's question go unanswered by him in the class's designated page on Piazza.

I have been even more impressed with the students I have met and interacted with online. Everyone has such interesting backgrounds and bring a lot of valuable, diverse perspectives to the program. After talking to a lot of the other students online, the common theme I am seeing is that the person got a bacehlors in something and then was somehow exposed to the power of programming which then drew them to enroll in the program! The contrast in doing something else and then being drawn to computer science seems to create a unique passion in these people that I think might prove to be very valuable in their career.

Interestingly, I feel like I am getting much more social interaction through this online program than I would with a traditional on-campus CS program. The program has setup a private Google Plus group where students can share important resources, keep each other informed, and form study groups through Google Hangouts where we can chat and interact with each other in real-time. I have one large study group I am a part of and then a few other smaller ones. The program also uses Piazza as a question and answer platform and students are very active on it.

Because all the services OSU uses have mobile apps, everywhere I go I have my class and my fellow students with me. I actually have a folder on my iPhone that I have labeled "Oregon State" where I keep everything that I commonly use for the program.

OSU folder on my phone{: .img-responsive .center-block }

If I want to see an assignment or check a grade I can log into Canvas and do that.

If I am out and about and a student posts a C++ related question that I know how to answer, I can just log into Piazza and answer their question right then.

If I am completely stuck on understanding the overloading of class constructor functions in C++ then I can log in to Google hangouts and ask for help from one of my hangout groups.

If I come across a great CS related post on reddit I can pullup Google Plus and share it with everyone in the program.

Anyway, this is program is exactly what has been taken up all my free time lately! Much of the class at first was a review due to my prior experience in C/C++ but I still read all the chapters in our textbook and this may actually turn out to be the first textbook I have ever read fully!

Even though the concepts were a review for me, I still managed to miss a lot more questions on the first exam than I expected I would! :) I definitely need to slow down next time and take the test slow.

We are now getting into Object Oriented programming with C++ and I definitely don't have as much OO experience as I should so I have been learning quite a bit this week.


If you are interested in learning programming then you should definitely check out CS50! The class is simply amazing and the professor David Malan is one of the most exciting lecturers I have ever experienced. The class is very challenging but you will learn so much!

I started taking CS50 about a month before I started the OSU program because I wanted to get more exposure to basic computer science concepts. The class has definitely delivered that and more.

I am now done with Problem Set 5 which was the most challenging for me so far and I have heard may be the most challenging problem set in the program. Basically, I had to implement my own data-structure/code in C that would then be used to load a large dictionary into memory and check that the words passed to it were in the dictionary. Next the dictionary is unloaded freeing all dynamically allocated memory and keeping track of the size of the dictionary that was loaded/unloaded.

The data structure that I wound up creating was a hash table of linked lists.

a hash table of linked lists{: .img-responsive .center-block }

The values (words) passed in to my hash function were mapped to an index of the hash table based upon the first letter they started with. The word "apple" would get mapped to the first bucket it my hash table. The word "beta" would get mapped to the second element of my hash table, etc. Once the values were assigned to an index they were then stored in a linked list.

Why go to all of this trouble? It would indeed be simpler to just create an array of arrays and store all the words (character arrays) in that array.

a hash table of linked lists{: .img-responsive .center-block }

However, due to the way in which memory is managed in lower level languages like C, you would need to know the max size of the array you would need at compile time. You would then have to set aside that amount of memory and would never be able to use it for anything else.

A further complication is that normal arrays in C represent contiguous blocks of memory and because of this you would not be able to dynamically resize them. Using a linked list data structure allows you to spread your data throughout the computers available memory without it having to be side by side. Then you link them together with a pointer.

So, you see the power of a linked list. The problem with singly linked lists though is that you lose the ability to use array notation to randomly access elements within the list. This is a problem because you then have to loop through all the elements in the list in order to find the element you are looking for.

This is where the hash function and hash table concept come in to help out. The hash function helps to kind of pre-sort your linked list into separate buckets so that you only have to search the 'A' bucket to find words that start with 'A', etc.

Finally, as I alluded to earlier the memory I used for my hash table was all dynamically allocated with malloc so that the memory was only used when it was needed. Then, when the hash table dictionary was no longer needed I called free() to free up the memory and return it to the operating system. I verified with valgrind that no memory leaks existed.

If I would have had more time I would have modified my hash function to use more of the keys data by further sorting the words into buckets based upon the first two letters that the word started with.

You can see my implementation of dictionary.c here on my GitHub.

I haven't had a lot of time for CS50 in the past week because of all the work I have been doing for CS 161. However, I still hope to have it finished by the end of the year. Needless to say, CS 161 takes priority!

Posting more often

I am going to try to start posting updates much more frequently and try to build more of an on-line presence! I have been inspired by a lot of other blogs I have seen by people who are much more involved in the community.

Some future posts I am thinking of:

  • Using BCP with SQL Server through Python
  • Automating SQL Server with Python
  • Using Python to automate your PDF creation
  • Creating quick and dirty GUIs with Python's tkinter
  • Getting away from VBA - How to use Python with Excel and why you should
  • Hussar Python - A guide to using Python in Windows without admin rights with WinPython, a highly-portable, highly-powerful Python distro.

In other news PyCon 2016 has started accepting early bird registrations and I am trying to go this year. Unfortunately, my current company will not pay for a Python programming convention so I will need to fund my own trip. The real cost is actually the hotel because PyCon 2016 is 7-10 days. I also think I will try to help out and volunteer at PyCon because it may help me to meet new Python friends and network.


comments powered by Disqus