1. Home
  2. Explore
  3. Computer Science
  4. Data Structures & Algorithms Basics

Study methods

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

Data Structures & Algorithms Basics

  • 32Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Big O Notation
The primary purpose of Big O notation is to describe the
of an algorithm.

32 questions

  1. 1
    The primary purpose of Big O notation is to describe the
    _____
    of an algorithm.
    Hint

    Consider what aspect of an algorithm we evaluate as input grows.

    Answer

    performance

  2. 2
    An algorithm that prints only the first element of an array has a runtime complexity of
    _____
    .
    Hint

    Think about whether the runtime depends on the array size.

    Answer

    O(1)

  3. 3
    A loop that iterates over all nnn elements of an array runs in
    _____
    time.
    Hint

    Consider how runtime changes as n increases.

    Answer

    O(n)

  4. 4
    When simplifying Big O expressions, we drop constants because we only need an
    _____
    of the cost relative to input size.
    Hint

    Think about what Big O provides—exact or rough estimate?

    Answer

    approximation

  5. 5
    For an algorithm with two separate loops over two different input arrays of sizes nnn and mmm, the runtime complexity is
    _____
    .
    Hint

    Think about how runtime depends on both inputs individually.

    Answer

    O(n + m)

  6. 6
    Nested loops that each iterate over the same array result in
    _____
    runtime complexity.
    Hint

    Consider the number of operations per outer loop iteration.

    Answer

    O(n^2)

  7. 7
    Binary search on a sorted array runs in
    _____
    time.
    Hint

    Think about how the search space shrinks with each step.

    Answer

    O(log n)

  8. 8
    An algorithm with exponential growth is represented as
    _____
    .
    Hint

    Think of the opposite of logarithmic growth—very fast growth.

    Answer

    O(2^n)

  9. 9
    Space complexity that is constant, independent of input size, is denoted as
    _____
    .
    Hint

    Consider if the extra memory needed grows with input.

    Answer

    O(1)

  10. 10
    When analyzing space complexity, we count only the
    _____
    space allocated by the algorithm, not the input itself.
    Hint

    Think of the extra memory beyond the input data.

    Answer

    additional

  11. 11
    In an array, items are stored
    _____
    in memory.
    Hint

    Think about how array elements are arranged in RAM.

    Answer

    sequentially

  12. 12
    Looking up an element in an array by its index has a runtime complexity of
    _____
    .
    Hint

    Consider the memory address calculation.

    Answer

    O(1)

  13. 13
    Arrays in Java have a
    _____
    size that cannot be changed after creation.
    Hint

    Think about whether you can add elements beyond initial capacity.

    Answer

    fixed

  14. 14
    Removing the first element from an array requires shifting all remaining elements, making it an
    _____
    operation.
    Hint

    Consider the number of shifts needed in the worst case.

    Answer

    O(n)

  15. 15
    In Java, the length field of an array returns the
    _____
    of the array.
    Hint

    Think about what number that field holds.

    Answer

    size

  16. 16
    A dynamic array (like our custom Array class) uses a count field to track the number of
    _____
    items.
    Hint

    Distinguish between capacity and number of elements stored.

    Answer

    actual

  17. 17
    When our dynamic array is full and a new item is inserted, we create a new array of
    _____
    the current size.
    Hint

    Think about the growth factor used in the example.

    Answer

    twice

  18. 18
    In the removeAt method of our dynamic array, after shifting elements we decrement the
    _____
    field.
    Hint

    Which field tracks the number of items?

    Answer

    count

  19. 19
    The indexOf method in our dynamic array has a worst-case runtime complexity of
    _____
    .
    Hint

    Consider the case when the item is at the end or not present.

    Answer

    O(n)

  20. 20
    Java's Vector class grows by
    _____
    percent of its size when full.
    Hint

    Think about the growth factor: double? Or 50%?

    Answer

    100

  21. 21
    Java's ArrayList grows by
    _____
    percent of its size when full.
    Hint

    This is the growth factor for ArrayList.

    Answer

    50

  22. 22
    Methods in Java's Vector class are
    _____
    , meaning they can only be accessed by one thread at a time.
    Hint

    Think about thread safety.

    Answer

    synchronized

  23. 23
    A linked list consists of a group of
    _____
    in sequence, each holding a value and a reference to the next node.
    Hint

    What are the building blocks of a linked list?

    Answer

    nodes

  24. 24
    The first node in a linked list is called the
    _____
    .
    Hint

    Think of the starting point of the list.

    Answer

    head

  25. 25
    The last node in a linked list is called the
    _____
    .
    Hint

    Think of the end of the list.

    Answer

    tail

  26. 26
    In a singly linked list, looking up an element by index has a runtime complexity of
    _____
    .
    Hint

    Consider whether you can access by index directly.

    Answer

    O(n)

  27. 27
    Inserting a new node at the beginning of a linked list is an
    _____
    operation.
    Hint

    Think about whether you need to shift elements.

    Answer

    O(1)

  28. 28
    Inserting a node at the end of a linked list is
    _____
    if we maintain a tail reference.
    Hint

    Consider if we need to traverse the list.

    Answer

    O(1)

  29. 29
    Deleting the first node from a linked list is an
    _____
    operation.
    Hint

    Think about which references need updating.

    Answer

    O(1)

  30. 30
    Deleting the last node from a singly linked list is an
    _____
    operation because we need to find the node before the tail.
    Hint

    Consider the need to traverse the list.

    Answer

    O(n)

  31. 31
    In our custom LinkedList class, the isEmpty method returns true if
    _____
    is null.
    Hint

    Which field indicates an empty list?

    Answer

    first

  32. 32
    When removing the only node from a linked list, we set both first and last to
    _____
    .
    Hint

    What should the references be for an empty list?

    Answer

    null

1 of 32
Question 1 of 32

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent