🌍 CS50x: Introduction to Computer Science · subject
CS50x: Introduction to Computer Science Memory Syllabus
Every chapter and topic of Memory examined in CS50x: Introduction to Computer Science — 4 chapters, 12 topics, plus 50 flashcards written against it.
Memory syllabus — full chapter and topic list
Expand any chapter to see its topics and sub-topics. This is the whole examinable outline for Memory in CS50x: Introduction to Computer Science, not a summary of it.
-
Pointers and Addresses
3 topics- Hexadecimal
- Pointers and Dereferencing
- Segmentation Faults
-
Dynamic Memory
4 topics- Stack and Heap
- Dynamic Memory Allocation
- Call Stacks
- Buffer Overflow
-
Custom Types and Files
3 topics- Defining Custom Types
- File I/O and File Pointers
- Working with Images
-
Debugging Memory
2 topics- Valgrind
- Memory Leaks
Memory flashcards for CS50x: Introduction to Computer Science
20 of 50 cards from the Memory deck — real questions with worked answers.
What is the hexadecimal (base-16) number system and which symbols does it use?
A positional number system with base $16$. It uses sixteen symbols: the digits $0$–$9$ for values zero through nine and the letters A–F for values $10$ through $15$.
Why is hexadecimal convenient for representing computer memory and addresses?
Because $16 = 2^{4}$, one hex digit maps exactly to $4$ bits, so one byte ($8$ bits) is exactly two hex digits. This makes binary data far more compact and readable than base-2.
What does the prefix 0x mean in a value like 0xFF in C?
It signals that the number is written in hexadecimal (base $16$), distinguishing it from decimal. It has no effect on the value itself; $\text{0xFF} = 255$ in decimal.
Convert the decimal number $255$ to hexadecimal, showing the place values.
$$255 = 15 \times 16^{1} + 15 \times 16^{0} = \text{0xFF}$$ since each hex digit position represents a power of $16$.
What is the general formula for the decimal value of a hexadecimal number with digits $d_{n} d_{n-1} \dots d_{0}$?
$$\text{value} = \sum_{i=0}^{n} d_{i} \times 16^{i}$$ where each digit $d_{i}$ is between $0$ and $15$ (A–F standing for $10$–$15$).
What is a pointer in C?
A variable that stores a memory address — typically the address of another variable. On a modern 64-bit system a pointer occupies $8$ bytes.
What does the & (address-of) operator do in C?
Applied to a variable, it yields that variable's memory address. Example: if int n = 50;, then &n is the address in memory where n is stored.
What does the * (dereference) operator do when applied to a pointer?
It 'goes to' the address stored in the pointer and accesses the value there. If int *p = &n;, then *p reads (or writes) the value of n.
What does the declaration int *p; mean, and what is the role of * in the declaration versus in an expression?
It declares p as a pointer to an int. In a declaration, * marks the variable as a pointer type; in an expression, *p dereferences the pointer to access the pointed-to value.
What is a NULL pointer and why should you initialize pointers you don't yet have an address for to NULL?
NULL is a special value meaning the pointer points to nothing. Initializing to NULL prevents the pointer from holding a garbage address, and lets you safely test if (p == NULL) before dereferencing.
What is a segmentation fault?
A runtime error that occurs when a program tries to access a 'segment' of memory it isn't allowed to touch — e.g., reading or writing outside its permitted address space. The operating system terminates the program.
Name three common causes of segmentation faults in C.
(1) Dereferencing a NULL or uninitialized (garbage) pointer, (2) accessing an array out of bounds, and (3) using memory after it has been freed (use-after-free).
What typically happens if you dereference a NULL pointer, and why is that behavior actually useful?
The program crashes with a segmentation fault. This is useful because it fails immediately and predictably, rather than silently corrupting some unknown region of memory.
What is the stack region of a program's memory used for?
It stores local variables and function call frames. Memory on the stack is managed automatically: it is allocated when a function is called and reclaimed when the function returns.
What is the heap region of a program's memory used for?
It is the pool of memory for dynamic allocation via malloc (and friends). Heap memory persists until the programmer explicitly releases it with free — it is managed manually.
In the classic memory layout diagram, how are machine code, globals, heap, and stack arranged, and in which directions do the heap and stack grow?
From top: machine code, then global variables, then the heap, with the stack at the bottom. The heap grows downward and the stack grows upward, toward each other — so they can collide if either grows too large.
Compare stack allocation and heap allocation with respect to management, lifetime, and speed.
Stack: automatic management, lifetime tied to the function's scope, very fast. Heap: manual management (malloc/free), lifetime lasts until explicitly freed, slower and vulnerable to leaks if free is forgotten.
What is a stack overflow, and what commonly causes one?
When the stack grows beyond its allowed space and overruns other memory — most commonly caused by infinite (or extremely deep) recursion, or by very large local arrays.
What is the purpose and behavior of malloc in C?
malloc(size) dynamically allocates size bytes on the heap and returns a pointer (void *) to the first byte. The memory is uninitialized (contains garbage), and malloc returns NULL if allocation fails.
What are the three key rules for using free correctly?
(1) Only free memory that was obtained from malloc/calloc/realloc, (2) free each block exactly once (no double free), and (3) never access memory after it has been freed.
Planning Memory for CS50x: Introduction to Computer Science
Memory is about 11% of the CS50x: Introduction to Computer Science syllabus by topic count — 12 of 112 topics, spread over 4 chapters. At roughly 45 minutes per topic plus 12 minutes per sub-topic, a first pass runs to about 9 hours.
The heaviest chapters are Dynamic Memory (4 topics), Pointers and Addresses (3 topics), Custom Types and Files (3 topics) . Front-load those while your energy is high; the short chapters are better revision filler later.
Work top-down: read the chapter, then tick topics off individually rather than marking the whole chapter done. Sub-topics are where silent gaps hide.
Memory (CS50x: Introduction to Computer Science) FAQ
What is in the CS50x: Introduction to Computer Science Memory syllabus?
Memory is split into 4 chapters — Pointers and Addresses, Dynamic Memory, Custom Types and Files and Debugging Memory, containing 12 topics and 0 sub-topics in total.
How many chapters are there in Memory for CS50x: Introduction to Computer Science?
4 chapters. Memory accounts for about 11% of the topics in the whole CS50x: Introduction to Computer Science syllabus (12 of 112).
How long should I spend on Memory for CS50x: Introduction to Computer Science?
Budget around 9 hours for a first pass through Memory — about 45 minutes per topic plus 12 minutes per sub-topic across its 12 topics. Add revision cycles on top.
Are there flashcards for CS50x: Introduction to Computer Science Memory?
Yes — a 50-card Memory deck. Sample cards are printed on this page, and the full deck is free in the Examius app with spaced repetition scheduling.