CS50x Week 10

Javascript – Allows interaction with user. E.g. onclick, add html via .html(“string”), change CSS, etc. JQuery – library based on Javascript. Use Google chrome’s console log to debug when programming, can check for variable value or play with Javascript. To recap, HTML gives structure, CSS gives style, PHP gives logic, Javascript + JQuery gives dynamic/ … Continue reading CS50x Week 10

CS50x Week 9: C$50 Finance(Problem Set)

We are done with C programming language, now we are stepping into web programming. This week, we will learn about HTML, CSS, PHP, and SQL. HTML is HyperText Markup Language, it is the standard markup language used to display websites. To see the html of a website, right click anywhere with blank space on a … Continue reading CS50x Week 9: C$50 Finance(Problem Set)

CS50x Week 8: Mispellings (Problem Set)

This week’s problem set requires us to implement a spell-checker. The usage is speller [dictionary] text, where speller is our program, dictionary is optional, text is a file that contains the paragraphs that need to be spell-checked. If user does not specify a dictionary, a default dictionary will be used. The main body of the … Continue reading CS50x Week 8: Mispellings (Problem Set)

CS50x Week 8

Trees We learned trie last week, trie is a type of data structure called tree. Tree has a node at the top, called root, then it has 0 or more nodes, called children. If a node does not have any child, it is called leaf. Binary tree When each node of a tree has at … Continue reading CS50x Week 8

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)

CS50x Week 7

scanf()

The first argument of scanf is %i, a specifier for integer, scanf expects an integer from the terminal, when an integer is encountered, it will be stored in x. The second argument is the address of x.

This above shows how scanf can be used to input data into array. In each … Continue reading CS50x Week 7

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

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