CS50 Debugging Tools
- 97Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
97 questions
- 1The CS50 IDE feature that allows programmers to step through code and inspect variables is the_____.
Hint
Think of the tool opened by debug50.
Answer
debugger
- 2The CS50-specific tool that automatically runs tests to check the correctness of code is_____.
Hint
It automates many tests that teaching fellows might perform.
Answer
check50
- 3The tool that checks code formatting and suggests changes to spaces is_____.
Hint
Its purpose is improving readability and coding style.
Answer
style50
- 4When a compiler or command produces a cryptic error message, students can prefix the command with_____for explanatory feedback.
Hint
This tool interprets difficult error messages.
Answer
help50
- 5Programmers can use_____to print variables or messages while tracing where a bug occurs.
Hint
It is a standard C output function.
Answer
printf
- 6In a nested loop, placing a_____inside the loop can reveal when each iteration is reached without repeatedly stepping through a debugger.
Hint
Think of a simple output-based tracing technique.
Answer
printf
- 7A breakpoint is used by a debugger to pause execution at a selected point in the_____.
Hint
It marks a location where execution should stop temporarily.
Answer
code
- 8Valgrind is a command-line tool used to detect memory leaks and other errors involving_____.
Hint
It is especially useful after using malloc.
Answer
memory
- 9Rubber duck debugging involves explaining code aloud, line by line, to a_____.
Hint
The listener does not need to respond.
Answer
rubber duck
- 10Debug50 is built on the older command-line debugger known as_____.
Hint
Its name is an acronym for GNU debugger.
Answer
GDB
- 11The C function used to request a block of memory from the heap is_____.
Hint
Its name means memory allocation.
Answer
malloc
- 12Memory allocated with malloc should eventually be returned to the operating system with_____.
Hint
This function releases dynamically allocated memory.
Answer
free
- 13If allocated memory is never released, the program has a memory_____.
Hint
Valgrind reports bytes that are definitely lost.
Answer
leak
- 14On many modern systems, an int occupies_____bytes, although programmers should use sizeof rather than hard-coding this value.
Hint
Four bytes equal 32 bits.
Answer
4
- 15The sizeof operator is used to determine the number of_____occupied by a data type or object.
Hint
It avoids assuming a particular machine representation.
Answer
bytes
- 16Malloc returns the_____of the allocated block rather than the integer value stored in that block.
Hint
The result is kept in a pointer.
Answer
address
- 17A pointer variable stores the_____of another object in memory.
Hint
It acts like a location or breadcrumb.
Answer
address
- 18Accessing memory outside the valid range of an array is an_____access.
Hint
An array of length 10 has valid indexes 0 through 9.
Answer
out-of-bounds
- 19A program may appear to work after an invalid memory access because it has gotten_____.
Hint
The operating system may have given the program extra accessible memory by coincidence.
Answer
lucky
- 20Valgrind can report an invalid read or write along with the source file and_____where it occurred.
Hint
This information helps locate the offending statement.
Answer
line
- 21Valgrind reports that all heap blocks were freed when dynamically allocated memory has been properly_____.
Hint
The relevant C function is free.
Answer
released
- 22The region of memory from which malloc obtains dynamically allocated memory is the_____.
Hint
It is distinct from the stack.
Answer
heap
- 23Local variables and function call frames are stored in the_____.
Hint
Each function call receives its own region there.
Answer
stack
- 24The machine-code instructions of a running program are loaded into the_____segment.
Hint
This segment contains executable instructions.
Answer
text
- 25Calling malloc obtains memory from the heap, while declaring local variables normally uses the_____.
Hint
Compare dynamic allocation with function-local storage.
Answer
stack
- 26If the stack grows into the heap or the heap grows into the stack, the resulting problem is called a stack_____.
Hint
It occurs when finite memory regions collide.
Answer
overflow
- 27When memory is freed, it is marked as available and returned conceptually to the operating system's_____list.
Hint
This list tracks reusable memory.
Answer
free
- 28A C string is implemented underneath as an array of_____.
Hint
The relevant type begins with char.
Answer
characters
- 29In C, string is effectively a synonym for the type_____.
Hint
This type is written using char and the pointer operator.
Answer
char star
- 30The star operator in a declaration indicates a_____to a value of the specified type.
Hint
It means the variable stores an address.
Answer
pointer
- 31Applying the star operator to a pointer to access the value at its address is called_____the pointer.
Hint
It means following the stored address.
Answer
dereferencing
- 32A pointer that has not been initialized may contain a_____value left over from previous memory use.
Hint
The value is unknown rather than necessarily zero.
Answer
garbage
- 33A pointer should never be dereferenced until it has been assigned a_____address.
Hint
The address must refer to memory the program may access.
Answer
valid
- 34The value_____is a special pointer value that indicates no valid address.
Hint
It is commonly represented numerically as zero.
Answer
null
- 35The original swap function failed because it received_____of the variables rather than their addresses.
Hint
Changes to these values affected only local variables in swap.
Answer
copies
- 36Passing pointers to swap allows the function to modify the original variables by using their_____.
Hint
The pointers act as breadcrumbs to the caller's memory.
Answer
addresses
- 37A struct allows C programmers to define a custom_____containing related fields.
Hint
It combines multiple values into one entity.
Answer
data type
- 38A header file typically contains code that can be shared across multiple_____.
Hint
Examples include stdio.h and custom header files.
Answer
programs
- 39The typedef declaration can give a structure a shorter custom_____.
Hint
It lets code refer to the structure without repeating the full declaration.
Answer
name
- 40A student structure in the lecture contained a name and a_____.
Hint
These were the two pieces of information used to represent a student.
Answer
dorm
- 41The_____operator accesses a field of a structure value.
Hint
It appears between the structure variable and the field name.
Answer
dot
- 42Grouping a student's name and dorm into one structure is an example of_____.
Hint
Related information is kept together in one data structure.
Answer
encapsulation
- 43A structure represents a real-world entity in code as an_____.
Hint
It is a simplified, useful representation.
Answer
abstraction
- 44Using a single array of student structures avoids maintaining separate arrays whose matching indexes must be kept in_____.
Hint
The name at one index must correspond to the dorm at that same index.
Answer
sync
- 45A C array normally cannot contain elements of different_____.
Hint
All elements must share one declared element type.
Answer
data types
- 46The size of a standard C array is fixed when the array is_____.
Hint
Adding elements later requires another strategy.
Answer
created
- 47To add an element to a full fixed-size array, a programmer must allocate a new array and_____the old values.
Hint
The existing elements must be moved into the larger block.
Answer
copy
- 48Resizing an array from n elements to n+1 elements takes O(n) time because all existing elements may need to be_____.
Hint
The work grows with the number of existing elements.
Answer
copied
- 49The C function that can change the size of a dynamically allocated memory block is_____.
Hint
Its name means reallocate.
Answer
realloc
- 50If sufficient space is unavailable immediately after an allocated block, realloc may move the data to a new location and return a new_____.
Hint
The caller must use the returned pointer.
Answer
address
- 51Calling malloc separately for each element avoids requiring contiguous memory, but removes constant-time_____access.
Hint
Array indexing normally jumps directly to an element.
Answer
random
- 52A linked list consists of nodes connected by_____stored inside the nodes.
Hint
Each node records where another node is located.
Answer
pointers
- 53The standard linked-list node described in the lecture contains an integer and a pointer called_____.
Hint
This field identifies the following node.
Answer
next
- 54A pointer declared as node star stores the address of another_____.
Hint
The type name follows the pointer symbol.
Answer
node
- 55The first node of a linked list is commonly tracked by a pointer called_____.
Hint
It provides access to the rest of the list.
Answer
first
- 56The last node in a singly linked list has its next pointer set to_____.
Hint
This marks the end of the chain.
Answer
null
- 57A singly linked list cannot move backward because each node stores only a pointer to the_____node.
Hint
There is no previous pointer in this design.
Answer
next
- 58Inserting a node at the beginning of an unsorted linked list takes constant time, written as_____.
Hint
Only a fixed number of pointers must be updated.
Answer
O(1)
- 59Inserting a node in sorted order may take O(n) time because the list may need to be traversed from the_____.
Hint
The program follows links until it finds the correct position.
Answer
beginning
- 60Maintaining a separate pointer called_____can make insertion at the end of a linked list more efficient.
Hint
It identifies the final node directly.
Answer
last
- 61A linked list can grow dynamically without moving all existing elements because its nodes need not be stored_____in memory.
Hint
The nodes may be scattered and connected by pointers.
Answer
contiguously
- 62A dynamically growing array tracks how many positions are available using its_____.
Hint
This is different from the number of positions currently occupied.
Answer
capacity
- 63The number of positions currently occupied in a dynamic array is its_____.
Hint
It increases when a new value is stored.
Answer
size
- 64When a dynamic array has no free position, its size equals its_____.
Hint
This condition triggers reallocation.
Answer
capacity
- 65The special keyboard signal used in the lecture to indicate end of input was_____.
Hint
It represents end of file on the command line.
Answer
Control-D
- 66Control-C generally terminates a program, whereas Control-D signals the end of the user's_____.
Hint
Control-D is associated with EOF.
Answer
input
- 67Because getInt expects an integer, it cannot directly use a letter such as q as a quit_____.
Hint
A nonnumeric character is not a valid integer.
Answer
signal
- 68If realloc fails, it can return_____to indicate that no valid memory address was obtained.
Hint
The program should check the returned pointer.
Answer
null
- 69A temporary pointer should store realloc's return value so failure can be checked before overwriting the original_____.
Hint
Losing the original pointer could make the allocated block inaccessible.
Answer
pointer
- 70When each linked-list node contains an integer and a pointer to another node, the structure is called a_____.
Hint
The nodes are connected through their next fields.
Answer
linked list
- 71The arrow operator combines dereferencing a pointer with accessing a structure_____.
Hint
It is shorthand for dereferencing and then using dot notation.
Answer
field
- 72For a pointer n to a structure, n arrow number is shorthand for accessing the number field after_____n.
Hint
The longer form uses the star operator and dot notation.
Answer
dereferencing
- 73A loop that traverses a linked list commonly advances by assigning ptr to_____.
Hint
This follows the next breadcrumb in the list.
Answer
ptr arrow next
- 74To append a new node, traversal stops when the current node's next field equals_____.
Hint
That condition identifies the final node.
Answer
null
- 75Before assigning a new node to a node's next field, the new node's own next field should usually be initialized to_____.
Hint
The new node initially becomes the end of the list.
Answer
null
- 76A hash function takes an input such as a name and produces an output typically represented by a_____.
Hint
The output identifies a bucket.
Answer
number
- 77Using the first letter of a name as a hash function creates 26 possible_____for the English alphabet.
Hint
Each letter corresponds to one location from A through Z.
Answer
buckets
- 78A hash table commonly consists of an array whose elements are_____.
Hint
Each array position stores a chain of values.
Answer
linked lists
- 79Hashing improves average lookup by dividing entries among multiple_____instead of one long list.
Hint
Names with similar hash results share one location.
Answer
buckets
- 80With 26 approximately equal buckets, the average chain length is roughly_____.
Hint
Divide the number of entries by the number of buckets.
Answer
n/26
- 81A good hash function aims to distribute entries as_____as possible among its buckets.
Hint
The goal is to avoid very long chains in particular buckets.
Answer
uniformly
- 82A hash function could use a person's last name, ID number, or birth date as its_____.
Hint
These are values supplied to the function.
Answer
input
- 83In asymptotic analysis, a constant factor such as 26 is often ignored even though it can still improve real-world_____time.
Hint
It refers to the actual time measured by a clock.
Answer
running
- 84A binary search tree stores values so that each node is greater than its_____child and less than its right child.
Hint
Values smaller than a node go on one side.
Answer
left
- 85The 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
- 86A binary tree node requires an integer and two_____to represent its left and right children.
Hint
Each child may be located elsewhere in memory.
Answer
pointers
- 87Searching a balanced binary search tree takes O(logn) time because each comparison eliminates approximately_____of the remaining possibilities.
Hint
This is the divide-and-conquer principle.
Answer
half
- 88The height of a balanced binary search tree containing n nodes is proportional to_____.
Hint
It reflects repeated division by two.
Answer
logn
- 89A tree can grow dynamically because its nodes do not need to be stored in one contiguous_____.
Hint
Nodes can be connected with pointers instead.
Answer
array
- 90A trie is a tree in which each node contains an_____.
Hint
This structure uses one position for each possible next character.
Answer
array
- 91The name trie is associated with the word_____because tries are used for retrieval.
Hint
The word begins with the same letters as trie.
Answer
retrieval
- 92In a trie using the English alphabet, each character node may contain an array of_____positions.
Hint
There is one position for each letter from A through Z.
Answer
26
- 93Looking up a word in a trie takes a number of steps proportional to the word's_____rather than the total number of stored words.
Hint
A word such as Billy requires one step for each character.
Answer
length
- 94The main cost of a trie is that it can use a large amount of_____.
Hint
Each node may contain a large array of pointers.
Answer
memory
- 95If a trie stores both Bob and Bobby, it needs a way to mark that a word can_____at Bob while another word continues.
Hint
The shorter word is complete even though a longer word shares its prefix.
Answer
stop
- 96A spell checker can rapidly determine whether a typed word is in its dictionary by looking it up in a data structure stored in_____.
Hint
The dictionary must be available for frequent queries.
Answer
memory
- 97The spell checker described in the lecture receives a large ASCII text file containing more than_____words.
Hint
The lecture described it as 100-plus thousand words.
Answer
100,000

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