1. Home
  2. Explore
  3. Computer Science
  4. C Data Structures and Pointers

Study methods

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

C Data Structures and Pointers

  • 76Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Pointers and Memory
A variable that stores the address of another value in memory is called a
.

76 questions

  1. 1
    A variable that stores the address of another value in memory is called a
    _____
    .
    Hint

    It lets a program refer to a memory location by its address.

    Answer

    pointer

  2. 2
    In C, the operator that follows a pointer to access the value at its address is the
    _____
    operator.
    Hint

    It means going to the address stored in a pointer.

    Answer

    dereference

  3. 3
    The function that requests a chunk of memory dynamically is
    _____
    .
    Hint

    Its name abbreviates memory allocation.

    Answer

    malloc

  4. 4
    The operator that reports how many bytes a type or object requires is
    _____
    .
    Hint

    It can be used to request enough memory for a particular type.

    Answer

    sizeof

  5. 5
    A safe way to request enough memory for a variable of a particular type is to use
    _____
    with that type.
    Hint

    This operator avoids having to assume the type's byte count.

    Answer

    sizeof

  6. 6
    If a pointer has not been assigned a valid address, dereferencing it may cause a
    _____
    .
    Hint

    This error can occur when a program accesses an invalid memory address.

    Answer

    segmentation fault

  7. 7
    The special pointer value used to represent that a pointer points to nothing is
    _____
    .
    Hint

    It is commonly used to mark an empty list or the end of a linked list.

    Answer

    NULL

  8. 8
    The value returned by malloc should be checked against
    _____
    before the allocated memory is used.
    Hint

    This return value can indicate that the allocation failed.

    Answer

    NULL

  9. 9
    The function used to return dynamically allocated memory to the computer is
    _____
    .
    Hint

    It takes the address of the memory that is no longer needed.

    Answer

    free

  10. 10
    Assigning one pointer to another copies the
    _____
    they store, so both pointers can refer to the same memory.
    Hint

    It is the location in memory represented by a pointer.

    Answer

    address

  11. 11
    When two pointers refer to the same pointee, changing that pointee through either pointer changes the same
    _____
    .
    Hint

    The pointers are aliases for one underlying location.

    Answer

    memory

  12. 12
    In a structure, the notation used to access a field through a structure variable is the
    _____
    operator.
    Hint

    It appears between the structure variable's name and a field name.

    Answer

    dot

  13. 13
    A programming construct that groups information in a defined arrangement, such as a number and a pointer, can be created in C with
    _____
    .
    Hint

    It is the C keyword used to define a custom structure.

    Answer

    struct

  14. 14
    When a dynamically allocated block is no longer reachable because its address was overwritten, the program has created a memory
    _____
    .
    Hint

    The allocated memory is lost and cannot be properly freed.

    Answer

    leak

  15. 15
    A fixed-size array requires its size to be specified
    _____
    .
    Hint

    The size must be chosen before the array is used.

    Answer

    upfront

  16. 16
    The values in an array are stored in a
    _____
    chunk of memory.
    Hint

    The values occupy adjacent memory locations.

    Answer

    contiguous

  17. 17
    If a fixed-size array has no room for an additional value, one way to grow it is to allocate a larger chunk and
    _____
    the existing values.
    Hint

    The old elements must be transferred to the new memory.

    Answer

    copy

  18. 18
    Copying all nnn existing elements when growing an array takes
    _____
    time.
    Hint

    The work increases in proportion to the number of elements copied.

    Answer

    O(n)O(n)O(n)

  19. 19
    For a sorted array that supports direct indexing, binary search can find a value in
    _____
    time.
    Hint

    Each comparison eliminates roughly half of the remaining search space.

    Answer

    O(log⁡n)O(\log n)O(logn)

  20. 20
    The C function that resizes an existing dynamically allocated memory block is
    _____
    .
    Hint

    Its name suggests allocating the block again at a new size.

    Answer

    realloc

  21. 21
    A temporary pointer is useful when reallocating because overwriting the original pointer too soon could lose the old block's
    _____
    .
    Hint

    The pointer is needed to keep track of where the original allocation is.

    Answer

    address

  22. 22
    After realloc succeeds, the program should update its pointer to the
    _____
    address returned for the resized block.
    Hint

    The resized allocation may be located somewhere different in memory.

    Answer

    new

  23. 23
    For a pointer to integers, square-bracket indexing advances by the size of an
    _____
    rather than by one byte.
    Hint

    The indexed elements have this C type.

    Answer

    int

  24. 24
    A dynamically allocated block can be used with square-bracket notation because it is a contiguous chunk of
    _____
    .
    Hint

    The block consists of adjacent locations that can be indexed.

    Answer

    memory

  25. 25
    A linked list is made up of nodes connected by
    _____
    .
    Hint

    They store addresses that lead from one node to another.

    Answer

    pointers

  26. 26
    A linked-list node in the example contains an integer field and a pointer field called
    _____
    .
    Hint

    This field indicates where to continue traversing the list.

    Answer

    next

  27. 27
    A pointer to a node can be declared as a
    _____
    .
    Hint

    In C notation, the type combines the node type with an asterisk.

    Answer

    node star

  28. 28
    The address of the first node is enough to begin accessing the rest of a linked list because its nodes link to one another through
    _____
    .
    Hint

    Following these connections lets a program move through the list.

    Answer

    pointers

  29. 29
    The pointer that represents an initially empty linked list should be initialized to
    _____
    .
    Hint

    An empty list has no first node to point to.

    Answer

    NULL

  30. 30
    The final node in a linked list typically has its next pointer set to
    _____
    .
    Hint

    This value marks the end of the chain.

    Answer

    NULL

  31. 31
    The C arrow notation for accessing a field through a pointer is equivalent to dereferencing the pointer and using the
    _____
    operator.
    Hint

    This field-access operator is used directly with a structure variable.

    Answer

    dot

  32. 32
    To add a node dynamically, a program can use malloc with
    _____
    to request enough bytes for the whole node.
    Hint

    This operator calculates the memory required by a type.

    Answer

    sizeof

  33. 33
    Before using fields of a node returned by malloc, a program should check that its pointer is not
    _____
    .
    Hint

    This value can signal that allocating the node failed.

    Answer

    NULL

  34. 34
    When adding a new node at the beginning of a list, first make the new node point to the list's
    _____
    first node.
    Hint

    Preserving this connection prevents the existing nodes from becoming unreachable.

    Answer

    current

  35. 35
    After linking a new first node to the existing list, update the list pointer to point to the
    _____
    node.
    Hint

    This node has just been inserted at the front.

    Answer

    new

  36. 36
    When inserting a node in the middle of a linked list, update the new node's next pointer before redirecting the previous node's pointer; otherwise the remaining nodes could become
    _____
    .
    Hint

    They would no longer be reachable by following the list.

    Answer

    orphaned

  37. 37
    To find a value or insertion point in a linked list, a program generally must follow the nodes one by one, so the operation can take
    _____
    time.
    Hint

    In the worst case, the program may examine every node.

    Answer

    O(n)O(n)O(n)

  38. 38
    Unlike an array, a linked list does not provide
    _____
    access to an arbitrary indexed element.
    Hint

    This kind of access lets an array jump directly to an index.

    Answer

    random

  39. 39
    A major advantage of linked lists over fixed-size arrays is that they can grow dynamically without
    _____
    all existing elements to a new block.
    Hint

    New nodes can be allocated separately and linked in.

    Answer

    moving

  40. 40
    Because linked-list nodes can be located throughout memory, the link between nodes is represented by a stored
    _____
    rather than by their physical adjacency.
    Hint

    It contains the address of the next node.

    Answer

    pointer

  41. 41
    A binary search tree is a tree in which each node has at most
    _____
    children.
    Hint

    The prefix in its name refers to this maximum number.

    Answer

    two

  42. 42
    In a binary search tree, values in a node's left subtree are
    _____
    than the node's value.
    Hint

    This ordering rule tells a search which direction to take for a lower target.

    Answer

    smaller

  43. 43
    In a binary search tree, values in a node's right subtree are
    _____
    than the node's value.
    Hint

    This ordering rule directs a search for a higher target.

    Answer

    greater

  44. 44
    The top node from which the rest of a tree can be reached is called the
    _____
    .
    Hint

    It is the starting point for traversing the tree.

    Answer

    root

  45. 45
    When searching a binary search tree, a target smaller than the current node's value directs the search to the
    _____
    subtree.
    Hint

    The tree's ordering places smaller values on this side.

    Answer

    left

  46. 46
    When searching a binary search tree, a target greater than the current node's value directs the search to the
    _____
    subtree.
    Hint

    The tree's ordering places greater values on this side.

    Answer

    right

  47. 47
    If a search reaches a NULL tree pointer without finding the target, the recursive search should return
    _____
    .
    Hint

    An empty subtree cannot contain the sought value.

    Answer

    false

  48. 48
    If the target is neither smaller nor greater than the current node's value, the search has found an
    _____
    .
    Hint

    The target matches the value stored at the node.

    Answer

    equal value

  49. 49
    Searching a balanced binary search tree takes
    _____
    time.
    Hint

    Each step can rule out a substantial part of the remaining tree.

    Answer

    O(log⁡n)O(\log n)O(logn)

  50. 50
    If values are repeatedly added to only one side of a binary search tree, the tree can become
    _____
    and lose its efficient height.
    Hint

    The tree becomes much taller on one side than the other.

    Answer

    unbalanced

  51. 51
    A hash table combines an array with
    _____
    to store multiple items that map to the same bucket.
    Hint

    These structures can chain together values within a bucket.

    Answer

    linked lists

  52. 52
    A hash function takes an input and produces an output that determines which
    _____
    receives the item.
    Hint

    It is one location in the array used by a hash table.

    Answer

    bucket

  53. 53
    In a simple name-based hash function, the first letter of a name can determine its
    _____
    in the array.
    Hint

    The letter is used to choose a storage location.

    Answer

    bucket

  54. 54
    When two inputs map to the same hash-table bucket, the event is called a
    _____
    .
    Hint

    The bucket already contains an item when another item is mapped there.

    Answer

    collision

  55. 55
    Storing colliding items in a linked list is one method of
    _____
    collisions.
    Hint

    The method provides a way to handle multiple items assigned to one bucket.

    Answer

    resolving

  56. 56
    Using only the first letter of names can create long bucket lists when many names share that
    _____
    .
    Hint

    Names beginning alike are sent to the same location by this simple hash function.

    Answer

    letter

  57. 57
    If many items collide in one bucket, searching a hash table can take
    _____
    time in the worst case.
    Hint

    The bucket may require checking every stored item.

    Answer

    O(n)O(n)O(n)

  58. 58
    Using more characters from each name in a hash function can reduce the probability of
    _____
    .
    Hint

    More detailed inputs are less likely to map to the same bucket.

    Answer

    collisions

  59. 59
    Increasing the number of buckets may reduce collisions, but it also uses more
    _____
    .
    Hint

    The larger array must occupy additional memory.

    Answer

    space

  60. 60
    The tension between using more memory and reducing the time needed for operations is a time-space
    _____
    .
    Hint

    Improving one resource can require spending more of another.

    Answer

    trade-off

  61. 61
    Under favorable distribution, hash-table operations can be much faster on average than the
    _____
    -time worst case.
    Hint

    This describes the worst-case behavior when items pile into one bucket.

    Answer

    linear

  62. 62
    A trie is a tree whose nodes are essentially
    _____
    .
    Hint

    Each node provides an indexed choice for the next character.

    Answer

    arrays

  63. 63
    To look up a name in a trie, the search follows a path determined by
    _____
    in the name.
    Hint

    The path uses the name's full sequence, not just its first few characters.

    Answer

    each letter

  64. 64
    When a trie needs a branch for a letter that has not yet been represented, a new
    _____
    is allocated.
    Hint

    In this trie, the new structure contains an array for further letters.

    Answer

    node

  65. 65
    A trie can share initial branches among names that have the same
    _____
    .
    Hint

    These are the starting letters common to multiple words.

    Answer

    prefix

  66. 66
    A trie needs a marker at the node where a complete word or name
    _____
    .
    Hint

    The marker distinguishes a complete entry from a prefix of a longer one.

    Answer

    ends

  67. 67
    For a fixed upper bound on word length, searching a trie takes time proportional to that length, often described as
    _____
    time.
    Hint

    The number of steps depends on the word's length rather than how many other words are stored.

    Answer

    constant

  68. 68
    A trie can offer fast lookup even as the number of stored words grows, but it pays for this speed with greater
    _____
    use.
    Hint

    Its many array nodes require substantial storage.

    Answer

    memory

  69. 69
    A queue follows the rule
    _____
    in, first out.
    Hint

    The earliest item added is the earliest one removed.

    Answer

    first

  70. 70
    The operation that adds an item to a queue is called
    _____
    .
    Hint

    It corresponds to joining the end of a line.

    Answer

    enqueue

  71. 71
    The operation that removes an item from a queue is called
    _____
    .
    Hint

    It corresponds to leaving the line after being served.

    Answer

    dequeue

  72. 72
    A stack follows the rule
    _____
    in, first out.
    Hint

    The newest item added is removed first.

    Answer

    last

  73. 73
    The operation that adds an item to a stack is called
    _____
    .
    Hint

    It places an item onto the top of the stack.

    Answer

    push

  74. 74
    The operation that removes the top item from a stack is called
    _____
    .
    Hint

    It removes the most recently added item.

    Answer

    pop

  75. 75
    A dictionary is a data structure that associates
    _____
    with values.
    Hint

    A word can serve as one of these labels for retrieving its associated information.

    Answer

    keys

  76. 76
    A programming data structure that provides an interface for a kind of behavior without specifying its low-level implementation is an
    _____
    data structure.
    Hint

    It describes what the structure does rather than its internal plumbing.

    Answer

    abstract

1 of 76
Question 1 of 76

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent