CS106B Assignments 1 to 3

I’m loving C++ and CS106B so far. Learning a lot of new stuff like the collection classes – vector, stack, queue, maps and sets. And…..

Recursion!!!! Took a while to wrap my head around it. I still haven’t actually “gotten” it but at least I’m not totally clueless about it. I’m doing the newer assignments for recursion as I am using the newer CS106B libraries.

So here are the links to the assignents 1, 2 and 3 that I have done so far.

Assignment1 – Simple C++

Assignment2 – ADTs/Collection Classes

Assignment3 – Recursion

Hopefully I’ll be posting each of the next assignments as a seperate posts and talk a little about the challenges I faced.

Setting up CS106B on Linux

Since I have switched to Linux completely, setting up C++ for CS106B was a little tricky. The SEE version of the course only offers IDE for Windows and Mac. No linux supported. But if we check the course sites for the past couple of terms, Linux is supported. The only problem is that the instructor is not Julie Zelinski for the recent versions and the assignments are a bit different from that offered in the open courseware version.

So, setting up an IDE in Linux is a bit of work if one wants to do the old assignment using the new libraries. I found two solutions and here they are –

  1. Using the Old Libraries
    A very helpful gentleman has put up a version of CS106B libraries used in the SEE course for Linux. Here is the link – http://sourceforge.net/projects/progabstrlib/
    These are relatively easy to setup and use, if one follows the readme file included.The only issue with these libraries occurs if you are following the course along with the latest CS106BX reader (which I would recommend as it is the updated version). The libraries used in the reader are the updated ones and have different functions and syntax.
  2. Using the Latest Libraries and the new Reader –
    Follow these steps:-
    * Download the linux files for all the assignments from http://web.stanford.edu/class/archive/cs/cs106b/cs106b.1136/
    * Create a new directory for any c++ program you want to work on using the new libraries
    * Copy the “StanfordCPPLib” to your directory from any of the assignments you downloaded
    * Copy spl.jar and Makefile to the same directory
    * Create your own cpp file in the same directory (for example, name.cpp)
    * Now you should have your cpp file, the “StanfordCPPLib” directory, spl.jar and the Makefile in your project directory
    * Open Makefile in gedit or any other text editor.
    * The Makefile would have the name of the original project whose Makefile you copied. Replace all instances of that name with the name of your cpp file
    For ex. if the project you copied the Makefile from was  “0-Warmup” and your cpp file is name.cpp then replace all instances of “0-Warmup” with “name”
    * Now, when you are ready to compile the program simply open the terminal and cd to the directory that contains all these files and type “make filename” (for ex. “make name”)
    * If there are no compile errors you will get back to the prompt, then type “./filename” and your program should run.

Hope that is helpful and not too confusing. If someone reads this and doesn’t understand any part or if something doesn’t work, please feel free to comment and I will try my best to help.