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

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

75 questions

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

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

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

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

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

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

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

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

  9. 9
    Rubber 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

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

  11. 11
    The function that requests a block of dynamically allocated memory is
    _____
    .
    Hint

    Its name abbreviates memory allocation.

    Answer

    malloc

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

    This function releases a previously allocated block.

    Answer

    free

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

  14. 14
    When 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)

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

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

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

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

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

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

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

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

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

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

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

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

  27. 27
    A C string is implemented underneath the hood as an array of
    _____
    .
    Hint

    Each element stores one symbol of the text.

    Answer

    characters

  28. 28
    The C type that is functionally equivalent to a string is
    _____
    .
    Hint

    It represents a pointer to a character.

    Answer

    char star

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

    It does not necessarily store the object's value directly.

    Answer

    address

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

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

  32. 32
    The unary star operator can be used to
    _____
    a pointer.
    Hint

    This operation follows the stored address to access the value there.

    Answer

    dereference

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

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

    It is commonly represented by the address zero.

    Answer

    NULL

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

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

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

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

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

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

  41. 41
    An 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

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

  43. 43
    Resizing an array from size nnn to size n+1n+1n+1 by copying its elements takes O(n)O(n)O(n) time, which is a
    _____
    process.
    Hint

    The number of copied elements grows proportionally with the array size.

    Answer

    linear

  44. 44
    The C function that can resize a dynamically allocated block of memory is
    _____
    .
    Hint

    Its name combines reallocation with the memory-allocation function.

    Answer

    realloc

  45. 45
    The functions malloc, realloc, and free all operate on memory in the
    _____
    .
    Hint

    This is the region used for dynamic allocation.

    Answer

    heap

  46. 46
    A dynamically growing array can be represented by a pointer initially set to
    _____
    .
    Hint

    At the beginning, the array has no allocated memory.

    Answer

    NULL

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

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

  49. 49
    If realloc fails, it returns
    _____
    .
    Hint

    This special value indicates an invalid or unavailable pointer.

    Answer

    NULL

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

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

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

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

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

  55. 55
    The pointer value marking the end of a linked list is
    _____
    .
    Hint

    It indicates that there is no next node.

    Answer

    NULL

  56. 56
    Unlike 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

  57. 57
    Searching for a value in a linked list generally takes O(n)O(n)O(n) time because traversal begins at the
    _____
    .
    Hint

    A singly linked list only provides access to the first node initially.

    Answer

    beginning

  58. 58
    Inserting a node at the beginning of an unsorted linked list takes constant time, written as O(1)O(1)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

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

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

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

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

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

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

  65. 65
    In the worst case, a hash table can still require O(n)O(n)O(n) time if all inputs are assigned to the same
    _____
    .
    Hint

    Then the hash table effectively contains one long linked list.

    Answer

    bucket

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

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

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

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

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

    Each position represents a possible next character.

    Answer

    array

  71. 71
    The word trie is short for
    _____
    .
    Hint

    The name refers to quickly retrieving words.

    Answer

    retrieval

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

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

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

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

1 of 75
Question 1 of 75

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent