1. Home
  2. Explore
  3. Computer Science
  4. CS50 Data Structures Overview

Study methods

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

CS50 Data Structures Overview

  • 20Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Abstract Data Types
An abstract data type like a queue or stack offers certain properties and characteristics, but the underlying
details are left to the programmer.

20 questions

  1. 1
    An abstract data type like a queue or stack offers certain properties and characteristics, but the underlying
    _____
    details are left to the programmer.
    Hint

    Think about the difference between what a data structure does and how it actually works inside the computer.

    Answer

    implementation

  2. 2
    Queues adhere to the
    _____
    (first in, first out) property, meaning the first element added is the first one removed.
    Hint

    Think of a line at a store; the first person in line is the first to be served.

    Answer

    FIFO

  3. 3
    In a stack, the
    _____
    (last in, first out) property means the most recently added element is removed first.
    Hint

    Think of a stack of plates; the last plate placed on top is the first to be taken off.

    Answer

    LIFO

  4. 4
    The two primary operations on a queue are
    _____
    and dequeue.
    Hint

    Think of adding a person to the end of a line and removing them from the front.

    Answer

    enqueue

  5. 5
    The two primary operations on a stack are
    _____
    and pop.
    Hint

    Think of placing a plate onto a stack and removing the top plate.

    Answer

    push

  6. 6
    A key characteristic of an array is that it stores data
    _____
    in memory.
    Hint

    Think about memory addresses of consecutive elements in an array.

    Answer

    contiguously

  7. 7
    When a fixed-size array is full and a new element is needed, the array must be copied to a new, larger chunk of memory, which takes
    _____
    steps.
    Hint

    Consider the number of elements that need to be moved when resizing.

    Answer

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

  8. 8
    A linked list node contains two values: the actual data (e.g., an integer) and a
    _____
    to the next node in the list.
    Hint

    This is the mechanism that links nodes together, allowing them to be scattered in memory.

    Answer

    pointer

  9. 9
    When inserting a new node at the beginning of a linked list (prepending), the running time is
    _____
    regardless of the list size.
    Hint

    Think about how many operations are needed regardless of how many nodes are already in the list.

    Answer

    O(1)O(1)O(1)

  10. 10
    Searching for an element in a singly linked list requires
    _____
    time in the worst case.
    Hint

    Think about how many nodes you might have to visit to find the target.

    Answer

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

  11. 11
    In a binary search tree, each node has at most two children, and for any node, all values in its left subtree are
    _____
    than the node's value.
    Hint

    Think about the ordering property that enables efficient searching.

    Answer

    smaller

  12. 12
    The recursive search function for a binary search tree checks if the number is less than the root, then searches the
    _____
    subtree.
    Hint

    Remember the property: smaller values go to the left.

    Answer

    left

  13. 13
    A binary search tree can degrade to a linked list if values are inserted in
    _____
    order (e.g., 1, 2, 3).
    Hint

    Think about what happens when each new value is larger than the previous one.

    Answer

    sorted

  14. 14
    A hash table combines an array with
    _____
    to handle collisions.
    Hint

    When two keys hash to the same index, they are stored in a chain starting at that index.

    Answer

    linked lists

  15. 15
    A hash function takes an input (e.g., a name) and returns a
    _____
    value that determines where the key-value pair is stored in the hash table.
    Hint

    Think of the output as a number that maps to an array index.

    Answer

    hash

  16. 16
    In the worst case, a hash table's search time is
    _____
    because all keys could collide into the same bucket.
    Hint

    Consider what happens if every key maps to the same index, forming a long linked list.

    Answer

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

  17. 17
    A dictionary is an abstract data type that stores
    _____
    pairs.
    Hint

    Think of a real dictionary: words (keys) and definitions (values).

    Answer

    key-value

  18. 18
    A trie (short for retrieval) is a tree of arrays where each node represents a
    _____
    of the key.
    Hint

    Think about how words share common beginnings.

    Answer

    prefix

  19. 19
    Searching for a key in a trie takes
    _____
    time, because the number of steps is bounded by the key's length, which is constant.
    Hint

    Think about the maximum number of steps compared to the number of keys stored.

    Answer

    O(1)O(1)O(1)

  20. 20
    The main disadvantage of a trie compared to a hash table is its
    _____
    usage, as many pointers in each node are null.
    Hint

    Think about all the empty slots in each array of a trie node.

    Answer

    memory

1 of 20
Question 1 of 20

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent