CS50 Debugging Tools
- 75Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
75 questions
- 1The CS50 IDE feature that allows programmers to step through code and inspect variables is called_____.
Hint
Think of the tool that provides breakpoints and a step-by-step side panel.
Answer
debug50
- 2The CS50-specific tool that automatically runs tests to check the correctness of code is_____.
Hint
This tool automates tests that teaching fellows might otherwise perform manually.
Answer
check50
- 3The tool that checks code formatting and identifies spaces that should be added or removed is_____.
Hint
Its purpose is to make code more readable and consistently formatted.
Answer
style50
- 4When a compiler produces a cryptic error message that you do not understand, the tool you should try is_____.
Hint
This tool interprets error messages and provides teaching-fellow-like guidance.
Answer
help50
- 5A programmer may use printf during debugging to determine whether execution has reached a particular_____in the code.
Hint
Printing a marker can reveal how far the program has executed.
Answer
point
- 6In a nested loop, placing printf inside the loop can show when the loop body_____.
Hint
The output can reveal each occasion on which the loop body runs.
Answer
executes
- 7The command-line program that detects memory leaks and invalid memory accesses is_____.
Hint
It reports invalid reads, invalid writes, and lost heap blocks.
Answer
Valgrind
- 8Valgrind can be combined with_____to make its difficult output easier to understand.
Hint
Use the tool that translates cryptic compiler and command-line errors into guidance.
Answer
help50
- 9Rubber duck debugging involves explaining a program aloud, line by line, to a_____.
Hint
The object does not need to respond; speaking exposes gaps in your reasoning.
Answer
rubber duck
- 10The purpose of rubber duck debugging is to reason through code logically and_____by step.
Hint
The technique requires a sequential walkthrough of the program.
Answer
step
- 11The function that requests a block of dynamically allocated memory is_____.
Hint
Its name abbreviates memory allocation.
Answer
malloc
- 12Memory allocated with malloc should eventually be returned to the operating system using_____.
Hint
This function releases a previously allocated block.
Answer
free
- 13If allocated memory is never returned with free, the program has a memory_____.
Hint
Valgrind reports bytes that are definitely lost when this occurs.
Answer
leak
- 14When malloc allocates space for 10 integers, the amount requested can be expressed as 10 times_____.
Hint
Use the operator that determines the size of the integer type on the current system.
Answer
sizeof(int)
- 15The value returned by malloc is an address, also known as a_____.
Hint
A variable storing this value should use a star type declaration.
Answer
pointer
- 16Because malloc returns a pointer to a block of contiguous memory, the block can be accessed using_____notation.
Hint
Contiguous, indexed elements form the same structure used for ordinary collections of values.
Answer
array
- 17For an array containing 10 elements, the valid indexes range from 0 through_____.
Hint
C arrays use zero-based indexing, so the final index is one less than the size.
Answer
9
- 18Reading or writing beyond the valid range of an array is an_____memory access.
Hint
This error occurs when code accesses a nonexistent array position.
Answer
out-of-bounds
- 19Valgrind may report an attempt to modify memory outside an allocated array as an invalid_____.
Hint
This operation changes a value in memory rather than merely examining it.
Answer
write
- 20Valgrind reports that all heap blocks were freed when a program has no remaining memory_____.
Hint
This is the desired result after every allocation has been properly released.
Answer
leaks
- 21The memory region from which malloc obtains dynamically allocated memory is the_____.
Hint
It is distinct from the stack, which stores local variables and function frames.
Answer
heap
- 22The memory region that stores local variables and function call frames is the_____.
Hint
Each function call receives its own region in this area.
Answer
stack
- 23When a program is loaded into RAM, its machine code is placed in the_____segment.
Hint
This segment contains the instructions of the running program.
Answer
text
- 24The operating system treats freed memory as available for reuse by placing it on the_____list.
Hint
The list contains memory that is not currently in use.
Answer
free
- 25If the stack grows into the heap, or the heap grows into the stack, the result can be a stack_____.
Hint
This occurs when finite memory regions collide because too much memory is used.
Answer
overflow
- 26The stack and heap are limited because a computer has a finite amount of_____.
Hint
Eventually the operating system must reject allocations or require programs to close.
Answer
memory
- 27A C string is implemented underneath the hood as an array of_____.
Hint
Each element stores one symbol of the text.
Answer
characters
- 28The C type that is functionally equivalent to a string is_____.
Hint
It represents a pointer to a character.
Answer
char star
- 29A pointer stores the_____of another object in memory.
Hint
It does not necessarily store the object's value directly.
Answer
address
- 30The original swap function failed because the function received_____of the variables rather than their addresses.
Hint
Changing these local values did not change the variables in main.
Answer
copies
- 31To allow swap to modify variables in the calling function, it must receive_____to those variables.
Hint
The function needs the memory locations of the original values.
Answer
pointers
- 32The unary star operator can be used to_____a pointer.
Hint
This operation follows the stored address to access the value there.
Answer
dereference
- 33Dereferencing a pointer that has not been assigned a valid address produces unsafe behavior because it may contain a_____value.
Hint
The bytes may contain leftover data from previous uses of memory.
Answer
garbage
- 34The special pointer value that indicates no valid address is_____.
Hint
It is commonly represented by the address zero.
Answer
NULL
- 35A programmer should never dereference a pointer that has not been_____by the programmer.
Hint
The pointer must first be made to refer to a known valid memory location.
Answer
set
- 36The C feature used to define a custom structure containing multiple related fields is_____.
Hint
It lets programmers create data types such as student or node.
Answer
struct
- 37The keyword used to give a structure a convenient custom type name is_____.
Hint
It can create a type such as student from a structure definition.
Answer
typedef
- 38A structure representing a student can encapsulate fields such as name and_____.
Hint
This was the second student-related field used in the example.
Answer
dorm
- 39The operator used to access a field of a structure value is the_____operator.
Hint
It appears between the structure variable and the field name.
Answer
dot
- 40Grouping related fields such as a student's name and dorm into one data structure is called_____.
Hint
This principle keeps related information together rather than scattering it across arrays.
Answer
encapsulation
- 41An array in C cannot normally contain values of different_____.
Hint
All elements of a conventional C array must share one declared type.
Answer
data types
- 42The size of a conventional C array is fixed and cannot be changed after it is_____.
Hint
Adding capacity requires allocating a new array and copying the old values.
Answer
created
- 43Resizing an array from size n to size n+1 by copying its elements takes O(n) time, which is a_____process.
Hint
The number of copied elements grows proportionally with the array size.
Answer
linear
- 44The C function that can resize a dynamically allocated block of memory is_____.
Hint
Its name combines reallocation with the memory-allocation function.
Answer
realloc
- 45The functions malloc, realloc, and free all operate on memory in the_____.
Hint
This is the region used for dynamic allocation.
Answer
heap
- 46A dynamically growing array can be represented by a pointer initially set to_____.
Hint
At the beginning, the array has no allocated memory.
Answer
NULL
- 47In the dynamic-array example, size records how many elements are being used, while capacity records how many elements can be_____.
Hint
Capacity describes the total available room.
Answer
stored
- 48When an array's size equals its capacity, the program must allocate_____space before inserting another element.
Hint
There is no unused position available in the current allocation.
Answer
more
- 49If realloc fails, it returns_____.
Hint
This special value indicates an invalid or unavailable pointer.
Answer
NULL
- 50The keyboard combination used to signal end of file or end of input is_____.
Hint
It indicates that the user is done entering input without terminating the program itself.
Answer
Control-D
- 51The keyboard combination that terminates or interrupts a running program is_____.
Hint
Unlike EOF, this command kills or breaks out of the program.
Answer
Control-C
- 52A linked list is made of nodes connected by storing the_____of the next node.
Hint
Each node contains a pointer field that acts like a breadcrumb.
Answer
address
- 53A linked-list node in the example contains an integer and a pointer called_____.
Hint
This field identifies the following node in the list.
Answer
next
- 54The pointer marking the beginning of a linked list is commonly called_____.
Hint
It provides the entry point from which all other nodes can be reached.
Answer
first
- 55The pointer value marking the end of a linked list is_____.
Hint
It indicates that there is no next node.
Answer
NULL
- 56Unlike an array, a linked list does not require its nodes to be stored_____in memory.
Hint
The nodes can be scattered because pointers connect them.
Answer
contiguously
- 57Searching for a value in a linked list generally takes O(n) time because traversal begins at the_____.
Hint
A singly linked list only provides access to the first node initially.
Answer
beginning
- 58Inserting a node at the beginning of an unsorted linked list takes constant time, written as O(1), because only a fixed number of_____must be updated.
Hint
The new node points to the old first node, and the first pointer is updated.
Answer
pointers
- 59Inserting a node while preserving sorted order may take O(n) time because the list must be_____until the correct position is found.
Hint
The program follows links from the beginning and may reach the end.
Answer
traversed
- 60A linked list with pointers in both directions is called a_____linked list.
Hint
Each node has both a next pointer and a pointer to the previous node.
Answer
doubly
- 61In C, the arrow operator provides shorthand for dereferencing a pointer and accessing a field in a_____.
Hint
It combines the operations represented by star and dot notation.
Answer
struct
- 62A hash function maps an input, such as a name, to a value used to select a_____.
Hint
Each bucket contains a subset of the data.
Answer
bucket
- 63A hash table commonly combines an array of buckets with linked lists stored in each_____.
Hint
The array provides quick access to a category, while the list stores collisions.
Answer
bucket
- 64Using the first letter of a name as a hash function creates 26 buckets for the English_____.
Hint
The buckets correspond to letters A through Z.
Answer
alphabet
- 65In the worst case, a hash table can still require O(n) time if all inputs are assigned to the same_____.
Hint
Then the hash table effectively contains one long linked list.
Answer
bucket
- 66A good hash function aims to distribute data as_____as possible among its buckets.
Hint
The goal is to keep the linked lists at similar lengths.
Answer
uniformly
- 67A tree in which every node's left descendants are smaller and right descendants are larger is a binary search_____.
Hint
This structure supports searching by repeatedly choosing left or right.
Answer
tree
- 68The top node of a tree, where traversal begins, is called the_____.
Hint
It is analogous to the first pointer in a linked list.
Answer
root
- 69Each node in a binary search tree contains pointers to a left child and a_____child.
Hint
The two directions correspond to values smaller and larger than the current node.
Answer
right
- 70A trie is a tree in which each node is an_____.
Hint
Each position represents a possible next character.
Answer
array
- 71The word trie is short for_____.
Hint
The name refers to quickly retrieving words.
Answer
retrieval
- 72In a trie, each level generally represents one_____in a stored word.
Hint
To store a word, follow one pointer for each symbol in sequence.
Answer
letter
- 73Lookup time in a trie depends primarily on the length of the_____rather than the number of stored words.
Hint
Looking up names such as Bob and Billy takes steps proportional to their character counts.
Answer
word
- 74The main resource cost of a trie is its high use of_____.
Hint
Each node may contain a large array of possible character pointers.
Answer
memory
- 75To distinguish a word that ends at a node from a longer word continuing through that node, a trie needs information indicating whether to_____or continue.
Hint
This is necessary when storing words such as Bob and Bobby.
Answer
stop

Ask anything
We've read this whole study set, so questions about it get the best answers.