CS50x Week 7: Forensics (Problem Set)

There are many image file formats such as BMP, JPG, PNG, and GIF. They can be grouped into lossy format and lossless format. Lossy format uses lossy compression that cuts away some data of the image to make an image that appears to be perfect copy, but not a perfect copy. lossless format uses lossless … Continue reading CS50x Week 7: Forensics (Problem Set)

6.00.1x Week 4

Our code does not always work as we intended, so we need to have some ways to debug it. Testing and debugging Testing methods Ways to test the program with examples to see if it work as intended. Debugging methods Ways to fix the program after you know it does not work as intended. Testing … Continue reading 6.00.1x Week 4

CS50x Week 5

Memory in a program Diagram below represents the memory segments of a running program: Text This segment has 1s and 0s. Initialized data This segment has global variable. Unintiailized data This segment has global variable. Heap This segment is for dynamically allocated variable allocated by malloc function. When malloc is called, the function grabs some … Continue reading CS50x Week 5

CS50x Week 4: Breakout (Problem set)

GUI (Graphical User interface) is interface that interacts with user through graphics as opposed to text user interface that interacts through text. For example, a game of tetris uses the GUI, while old game such as Discworld MUD uses text user interface. This week, we used an API (Application programming interface) provided by SPL (Stanford … Continue reading CS50x Week 4: Breakout (Problem set)

CS50x Week 4

Topics in this week’s lectures and shorts: Merge sort. Pointers. When is pointer used? Array are pointers. String is an array of characters. Merge sort Merge sort is a sorting algorithm that uses recursion. Recursion function as explained in 6.00.1x Week 3, is a function that calls a smaller version of itself. The pseudocode and … Continue reading CS50x Week 4

6.00.1x Week 3 (Problem Set)

There are two problems in this week’s problem set, one requires us to calculate the radiation exposure, another one requires us to program a hangman game. Radiation exposure Radioactive substance will undergo radioactive decay and emit radiation, over time, the amount of radioactive substance will reduce. The time required for a radioactive substance to reduce … Continue reading 6.00.1x Week 3 (Problem Set)

6.00.1x Week 3

This week, we learnt about recursion and different compound data types. Recursion Recursion means repeating similar version of something. In programming, a recursion function is a function that calls a smaller version of itself. It is useful for problems that can be represented as smaller version of themselves. The concept of recursion can be condensed … Continue reading 6.00.1x Week 3

CS50x Week 3: Game of Fifteen

This week I learned different sorting and searching algorithms. Sorting means arranging the elements in an array in ascending or descending order. Searching means finding an element in an array. Sorting algorithms Bubble sort Selection sort Insertion sort Quick sort Searching algorithms Binary search Bubble sort Imagine you have a list of numbers, from left … Continue reading CS50x Week 3: Game of Fifteen

6.00.1x Week 2 (Problem Set)

This week’s problem set deals with programming scripts that show what is the minimum amount of money a student has to pay in order to pay off his credit card balance in one year. There are 12 months in a year, and each month, interest will be incurred on the balance, the updated balance after … Continue reading 6.00.1x Week 2 (Problem Set)

6.00.1x Week 2

In week 2, I learnt to write functions in Python. The format of function in Python is as follows:

whereas in C, it is written as:

To program a basic function such as function to find the square root of a number, there are many approaches. We can use: 1. Linear search (exhaustive … Continue reading 6.00.1x Week 2