Episode 5: Are Computers Female?

Episode 5: Are Computers Female?

CS50 Week 4: Memory

I bet you've heard that women's brains are wired to have more interconnection across the 2 hemispheres which makes them better at multitasking and causes them to think of issues not in isolation but rather in relation to everything else.

Our plastic brains keep changing due to experiences & learning and some researchers insist that this difference in male and female brains is wrought not by innate biological wiring but by societal expectations and cultural upbringing. A reasonable conclusion however is that it's both. Feel free to read more about it here: psychologytoday.com/us/blog/so-happy-togeth..

What matters to us on this article however, whether of cultural or neurological cause, is that the difference Exists. Why? Because a computer's memory is probably more like the female brain.

(# Yeah, that's an expert opinion based on my vast knowledge and experience in computer and neuroscience 😅lol)

Data is scattered all over the computer's memory but computers are still able to retrieve everything when needed and make the necessary correlations. In C programming, this is aided by powerful but slightly annoying tools called pointers and malloc.

(# There is so much more to computer memory and with discussions of the heap and stack it's also possible to make the argument that this compartmentalization is more like the male brain. If you're comfortable with this discussion let me know what you think in the comments)

Pointers & Malloc

A pointer is a variable that stores the address of another variable. It literally points to where some specific data is stored in memory. Malloc (Short for Memory Allocation) is a method used to dynamically allocate a block of memory. Think of it like making a reservation in a restaurant where you specify how many guests the table should seat. Memory is a finite resource and with malloc you also need to remember to free the allocated memory.

These are things you would never come across while using a high level language like python because memory allocation is dealt with by the internal memory management system behind the scenes.

Algorithms and memory

As alluded to in the last article (Episode 4), when it comes to algorithms, the space/time dynamic comes into play where an algorithm which may be very time efficient may use up more memory. Just to reference that analogy again, Mercy's algorithm is better but it requires more kitchen space and utensils; it uses more memory. This is just an extra dynamic to consider in as much as more space is squeezed into tiny hardware today thanks to microchips. Here is one for perspective:

slide_storage_6_new-100383590-gallery.idge.png

Problem set 4 - Adding filters to images

The problem sets were aimed at practicing the use of command line arguments, working with external files and 2D arrays.

We implemented a program that can apply different filters to a .bmp image. The first thing you need to understand is that an image is really just a 2D array of pixels.

mario pixel.png

Each pixel has values specifying the amount of Red, Green and Blue colour (RGB) in that particular pixel. You might have seen something like (255, 255, 255) or (#FFFFFF) while using an image editor. It follows therefore that you can loop through an image and make specific changes to the RGB values of each pixel to apply the desired filter (E.g. Grayscale, sepia, blur etc.)

To blur an image for instance, you can apply a box blur algorithm which works by taking each pixel and giving each of it's RGB colours a new value by averaging the colour values of neighboring pixels.

Good Stuff!

Hexadecimal

If you're still here, I salute you; this one wasn't an easy read. I'll mention one last thing and wrap it up.

Hexadecimal is another number system which uses 16 digits (0 1 2 3 4 5 6 7 8 9 A B C D E F) and is therefore a more concise way of expressing data. Hexadecimals are usually prefixed by '0x' to distinguish them from normal decimal numbers (The pointers we talked about earlier can store a memory location as 0xF2F1AC07). A hash symbol could also be used (#FFFFFF is colour white for example). I won't get into the intricacies but the table below should help paint a clearer picture.

decimal-binary-hexadecimal-table-2.png

Up next: Data Structures. Stay tuned.