1. Home
  2. Explore
  3. Computer Science
  4. CS50 Debugging Tools

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

CS50 Debugging Tools

  • 97Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Development Tools
The CS50 IDE feature that allows programmers to step through code and inspect variables is the
.

97 questions

  1. 1
    The 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

  2. 2
    The 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

  3. 3
    The tool that checks code formatting and suggests changes to spaces is
    _____
    .
    Hint

    Its purpose is improving readability and coding style.

    Answer

    style50

  4. 4
    When 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

  5. 5
    Programmers can use
    _____
    to print variables or messages while tracing where a bug occurs.
    Hint

    It is a standard C output function.

    Answer

    printf

  6. 6
    In 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

  7. 7
    A 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

  8. 8
    Valgrind is a command-line tool used to detect memory leaks and other errors involving
    _____
    .
    Hint

    It is especially useful after using malloc.

    Answer

    memory

  9. 9
    Rubber duck debugging involves explaining code aloud, line by line, to a
    _____
    .
    Hint

    The listener does not need to respond.

    Answer

    rubber duck

  10. 10
    Debug50 is built on the older command-line debugger known as
    _____
    .
    Hint

    Its name is an acronym for GNU debugger.

    Answer

    GDB

  11. 11
    The C function used to request a block of memory from the heap is
    _____
    .
    Hint

    Its name means memory allocation.

    Answer

    malloc

  12. 12
    Memory allocated with malloc should eventually be returned to the operating system with
    _____
    .
    Hint

    This function releases dynamically allocated memory.

    Answer

    free

  13. 13
    If allocated memory is never released, the program has a memory
    _____
    .
    Hint

    Valgrind reports bytes that are definitely lost.

    Answer

    leak

  14. 14
    On 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

  15. 15
    The 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

  16. 16
    Malloc 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

  17. 17
    A pointer variable stores the
    _____
    of another object in memory.
    Hint

    It acts like a location or breadcrumb.

    Answer

    address

  18. 18
    Accessing 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

  19. 19
    A 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

  20. 20
    Valgrind 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

  21. 21
    Valgrind reports that all heap blocks were freed when dynamically allocated memory has been properly
    _____
    .
    Hint

    The relevant C function is free.

    Answer

    released

  22. 22
    The region of memory from which malloc obtains dynamically allocated memory is the
    _____
    .
    Hint

    It is distinct from the stack.

    Answer

    heap

  23. 23
    Local variables and function call frames are stored in the
    _____
    .
    Hint

    Each function call receives its own region there.

    Answer

    stack

  24. 24
    The machine-code instructions of a running program are loaded into the
    _____
    segment.
    Hint

    This segment contains executable instructions.

    Answer

    text

  25. 25
    Calling malloc obtains memory from the heap, while declaring local variables normally uses the
    _____
    .
    Hint

    Compare dynamic allocation with function-local storage.

    Answer

    stack

  26. 26
    If 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

  27. 27
    When 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

  28. 28
    A C string is implemented underneath as an array of
    _____
    .
    Hint

    The relevant type begins with char.

    Answer

    characters

  29. 29
    In C, string is effectively a synonym for the type
    _____
    .
    Hint

    This type is written using char and the pointer operator.

    Answer

    char star

  30. 30
    The star operator in a declaration indicates a
    _____
    to a value of the specified type.
    Hint

    It means the variable stores an address.

    Answer

    pointer

  31. 31
    Applying 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

  32. 32
    A 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

  33. 33
    A 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

  34. 34
    The value
    _____
    is a special pointer value that indicates no valid address.
    Hint

    It is commonly represented numerically as zero.

    Answer

    null

  35. 35
    The 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

  36. 36
    Passing 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

  37. 37
    A struct allows C programmers to define a custom
    _____
    containing related fields.
    Hint

    It combines multiple values into one entity.

    Answer

    data type

  38. 38
    A header file typically contains code that can be shared across multiple
    _____
    .
    Hint

    Examples include stdio.h and custom header files.

    Answer

    programs

  39. 39
    The typedef declaration can give a structure a shorter custom
    _____
    .
    Hint

    It lets code refer to the structure without repeating the full declaration.

    Answer

    name

  40. 40
    A 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

  41. 41
    The
    _____
    operator accesses a field of a structure value.
    Hint

    It appears between the structure variable and the field name.

    Answer

    dot

  42. 42
    Grouping 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

  43. 43
    A structure represents a real-world entity in code as an
    _____
    .
    Hint

    It is a simplified, useful representation.

    Answer

    abstraction

  44. 44
    Using 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

  45. 45
    A C array normally cannot contain elements of different
    _____
    .
    Hint

    All elements must share one declared element type.

    Answer

    data types

  46. 46
    The size of a standard C array is fixed when the array is
    _____
    .
    Hint

    Adding elements later requires another strategy.

    Answer

    created

  47. 47
    To 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

  48. 48
    Resizing an array from nnn elements to n+1n+1n+1 elements takes O(n)O(n)O(n) time because all existing elements may need to be
    _____
    .
    Hint

    The work grows with the number of existing elements.

    Answer

    copied

  49. 49
    The C function that can change the size of a dynamically allocated memory block is
    _____
    .
    Hint

    Its name means reallocate.

    Answer

    realloc

  50. 50
    If 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

  51. 51
    Calling 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

  52. 52
    A linked list consists of nodes connected by
    _____
    stored inside the nodes.
    Hint

    Each node records where another node is located.

    Answer

    pointers

  53. 53
    The standard linked-list node described in the lecture contains an integer and a pointer called
    _____
    .
    Hint

    This field identifies the following node.

    Answer

    next

  54. 54
    A pointer declared as node star stores the address of another
    _____
    .
    Hint

    The type name follows the pointer symbol.

    Answer

    node

  55. 55
    The 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

  56. 56
    The last node in a singly linked list has its next pointer set to
    _____
    .
    Hint

    This marks the end of the chain.

    Answer

    null

  57. 57
    A 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

  58. 58
    Inserting 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)O(1)O(1)

  59. 59
    Inserting a node in sorted order may take O(n)O(n)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

  60. 60
    Maintaining 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

  61. 61
    A 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

  62. 62
    A dynamically growing array tracks how many positions are available using its
    _____
    .
    Hint

    This is different from the number of positions currently occupied.

    Answer

    capacity

  63. 63
    The number of positions currently occupied in a dynamic array is its
    _____
    .
    Hint

    It increases when a new value is stored.

    Answer

    size

  64. 64
    When a dynamic array has no free position, its size equals its
    _____
    .
    Hint

    This condition triggers reallocation.

    Answer

    capacity

  65. 65
    The 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

  66. 66
    Control-C generally terminates a program, whereas Control-D signals the end of the user's
    _____
    .
    Hint

    Control-D is associated with EOF.

    Answer

    input

  67. 67
    Because 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

  68. 68
    If realloc fails, it can return
    _____
    to indicate that no valid memory address was obtained.
    Hint

    The program should check the returned pointer.

    Answer

    null

  69. 69
    A 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

  70. 70
    When 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

  71. 71
    The arrow operator combines dereferencing a pointer with accessing a structure
    _____
    .
    Hint

    It is shorthand for dereferencing and then using dot notation.

    Answer

    field

  72. 72
    For 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

  73. 73
    A 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

  74. 74
    To append a new node, traversal stops when the current node's next field equals
    _____
    .
    Hint

    That condition identifies the final node.

    Answer

    null

  75. 75
    Before 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

  76. 76
    A 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

  77. 77
    Using 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

  78. 78
    A hash table commonly consists of an array whose elements are
    _____
    .
    Hint

    Each array position stores a chain of values.

    Answer

    linked lists

  79. 79
    Hashing improves average lookup by dividing entries among multiple
    _____
    instead of one long list.
    Hint

    Names with similar hash results share one location.

    Answer

    buckets

  80. 80
    With 26 approximately equal buckets, the average chain length is roughly
    _____
    .
    Hint

    Divide the number of entries by the number of buckets.

    Answer

    n/26n/26n/26

  81. 81
    A 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

  82. 82
    A 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

  83. 83
    In 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

  84. 84
    A 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

  85. 85
    The 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

  86. 86
    A 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

  87. 87
    Searching a balanced binary search tree takes O(log⁡n)O(\log n)O(logn) time because each comparison eliminates approximately
    _____
    of the remaining possibilities.
    Hint

    This is the divide-and-conquer principle.

    Answer

    half

  88. 88
    The height of a balanced binary search tree containing nnn nodes is proportional to
    _____
    .
    Hint

    It reflects repeated division by two.

    Answer

    log⁡n\log nlogn

  89. 89
    A 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

  90. 90
    A trie is a tree in which each node contains an
    _____
    .
    Hint

    This structure uses one position for each possible next character.

    Answer

    array

  91. 91
    The 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

  92. 92
    In 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

  93. 93
    Looking 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

  94. 94
    The 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

  95. 95
    If 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

  96. 96
    A 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

  97. 97
    The 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

1 of 97
Question 1 of 97

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent