Flashcard Deck · 20 cards · Public

CS50 - Computer Science Fundamentals

Master core computer science concepts with this comprehensive CS50 flashcard deck. Cover low-level C programming, pointer arithmetic, memory management, Big-O analysis, and fundamental algorithms.

Cards in this deck

(20 cards)

Preview terms and definitions before starting your study session.

#1
Term
What are the four stages of C compilation?
Definition
1. Preprocessing: Expands lines starting with # (e.g., #include, #define) and strips comments.
2. Compiling: Translates preprocessed source code into assembly code.
3. Assembling: Converts assembly code into machine code / object code (.o).
4. Linking: Combines object code with external libraries (e.g., cs50.c or standard math libraries) into a single executable binary.
#2
Term
What is a pointer, and what do & and * do in C?
Definition
A pointer is a variable that stores the memory address of another variable.
  • & (Address-of operator): Returns the memory address where a variable is stored (e.g., &x).
  • * (Dereference operator): Accesses or modifies the value stored at the memory address held by a pointer (e.g., *p).
#3
Term
What is dynamic memory allocation using malloc() and free()?
Definition
malloc(size) allocates a contiguous block of memory of size bytes on the heap and returns a void* pointer to the first byte. If allocation fails, it returns NULL.
free(ptr) releases the memory block back to the system to prevent memory leaks.
#4
Term
What is the difference between Stack and Heap memory?
Definition
  • Stack: Stores function parameters and local variables. Managed automatically in a Last-In, First-Out (LIFO) order with fixed size. Fast, but limited capacity.
  • Heap: Used for dynamic memory allocation (malloc). Managed manually by the programmer, persists until explicitly freed, but slower and prone to fragmentation.
#5
Term
What is a memory leak and how do you prevent and detect it?
Definition
A memory leak occurs when dynamically allocated heap memory is no longer needed but is not released via free(), causing available system memory to deplete.
  • Prevention: Call free() for every malloc() once done.
  • Detection: Use memory debugging tools like valgrind.
#6
Term
What is a buffer overflow?
Definition
A buffer overflow happens when a program writes data beyond the boundary of an allocated buffer in memory. This overwrites adjacent memory, leading to data corruption, program crashes, or security vulnerabilities (e.g., code injection).
#7
Term
How do , , and notations describe algorithmic performance?
Definition
  • Big-O (): Represents the upper bound (worst-case scenario) of runtime or space complexity.
  • Big-Omega (): Represents the lower bound (best-case scenario).
  • Big-Theta (): Represents a tight bound when upper and lower bounds match ().
#8
Term
Rank common Big-O complexities from fastest to slowest.
Definition
1. - Constant time
2. - Logarithmic time
3. - Linear time
4. - Linearithmic time
5. - Quadratic time
6. - Exponential time
7. - Factorial time
Showing 8 of 20 cards in this deck.
Study All Now