From Architecture to IT

CS50 Harvard Class: Introduction to Computer Science Continues!

December 2019 Problem set 3 – Replace some pixels from a bitmap to see a message

I am writing this after it happened. There is a problem in which you have to filter out from a bitmap some red pixels so you can see a hidden text. I never did this problem because in the new year the Pset ( Problem Set) changed- but that is not the real motive.

The real motive is that I got discouraged because of what I perceived as an unapproachable complexity: headers, structs, custom types, etc.  It felt like I was staring at the tip of the mountain and didn’t know which way to take. I tried googling it, learning, searching and nothing. The plethora of errors was adding up to the frustration (SISEGV, pointer errors, syntax errors, insufficiently knowing structures and datatypes in C.

Then I said to myself – enough with these breadcrumbs of information! I need to study C comprehensively or else I will never finish this introductory course.

Then, in the 16 days trip to NY ( antrepreneurial holiday !:P)  I didn’t have much time to study.
After I restarted in January 2020 I found the next chapters easy in comparison with Mario. They were easy because I understood what and how they should be done.  Not knowing the syntax, a problem like Mario in Problem set 1 was Extremely Hard, even though in Python I would have coded it in 30 seconds. A program that would translate from Python to C some basic instructions I think would do a lot of good to beginners in coding or programming! Think I might write that someday !

So I searched on Youtube and I found a guy from India that was extremely calm and relaxed – and had 75 + videos and tutorials ( Naresh Technologies). I started from 0 with every concept in C programming language, learning about all kinds of data structures, syntax, for and while loops, resolving different very small problems ( like seeing if a number is a palindrome or not ). For 5 – 7 days that is all I did and my confidence & knowledge grew a lot, I solved the problem and then I continued in the new year.

January 2020 – Problem set 4 – Recovering jpeg images from a .raw file using C programming language

Harvard studying online, programming language, edx, C programming, Programming basics

In CS50 – the Harvard online programming course – there is a task in which you have to recover some photos from a raw sequence of bytes in C programming language. After checking if the file has a correct input I had to think at how to iterate over the raw data and check if the header of the jpg corresponds with the bytes written in the raw data. If they correspond, then you found an image ! They give you a walk through code so it’s easier to implement – That walk through is a must if you are a beginner in C !

I encountered errors in initializing  the file pointers and I was careful to open the files in “a” – append mode. (so every chunk of memory gets added at the end of the file). If you open the file in “w”(write) then you are replacing the actual contents of the already opened file). The problem is complex and you have to malloc and free the memory you use, otherwise you end up in a long series of Segmentation Faults errors! It was a very insightful lesson because I have really understood how the computer operates under the hood. And it is fascinating – especially the speed in which decisions can be made.

Next thing in the day I followed lecture 5 of this course. These lectures have a great artistic touch with nice abstract introductions. In almost all the courses there is a live demonstration of code in real life using people,  numbers, lockers, volunteers, numbers , etc ! There are short amusing videos about coding concepts that make learning this language quite fun ! The animation with pointers is quite nice.

Leave a Reply

Your email address will not be published. Required fields are marked *


error: Content is protected !!