1. Home
  2. Explore
  3. Computer Science
  4. 6.006 Problem Session

Study methods

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

6.006 Problem Session

  • 26Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Master Theorem Basics
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What does 'a' represent in the Master Theorem recurrence relation T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n)T(n)=aT(n/b)+f(n)?

Tap to flipClick to flipspace

The branching factor, which is the number of recursive calls made.

Or swipe the card

26 cards

  1. What does 'a' represent in the Master Theorem recurrence relation T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n)T(n)=aT(n/b)+f(n)?

    The branching factor, which is the number of recursive calls made.

  2. What does 'b' represent in the Master Theorem recurrence relation T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n)T(n)=aT(n/b)+f(n)?

    The factor by which the problem size is reduced for each recursive call.

  3. What does 'f(n)' represent in the Master Theorem recurrence relation T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n)T(n)=aT(n/b)+f(n)?

    The amount of work done at each node (outside of recursive calls) in the recursion tree.

  4. What is the key quantity derived from 'a' and 'b' that is central to the Master Theorem's three cases?

    nlog⁡ban^{\log_b a}nlogb​a

  5. What are the three cases of the Master Theorem based on?

    The relationship between f(n)f(n)f(n) and nlog⁡ban^{\log_b a}nlogb​a.

  6. Identify the parameters 'a', 'b', and 'f(n)' for the recurrence T(n)=2T(n/2)+O(n)T(n) = 2T(n/2) + O(\sqrt{n})T(n)=2T(n/2)+O(n​).

    a=2a=2a=2, b=2b=2b=2, and f(n)=O(n)f(n) = O(\sqrt{n})f(n)=O(n​).

  7. What is nlog⁡ban^{\log_b a}nlogb​a for the recurrence T(n)=2T(n/2)+O(n)T(n) = 2T(n/2) + O(\sqrt{n})T(n)=2T(n/2)+O(n​)?

    nlog⁡22=n1=nn^{\log_2 2} = n^1 = nnlog2​2=n1=n.

  8. Which Master Theorem case applies to T(n)=2T(n/2)+O(n)T(n) = 2T(n/2) + O(\sqrt{n})T(n)=2T(n/2)+O(n​)?

    Case 1.

  9. What is the asymptotic bound for T(n)=2T(n/2)+O(n)T(n) = 2T(n/2) + O(\sqrt{n})T(n)=2T(n/2)+O(n​) using the Master Theorem?

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

  10. Identify the parameters 'a', 'b', and 'f(n)' for the recurrence T(n)=8T(n/4)+O(n3/2)T(n) = 8T(n/4) + O(n^{3/2})T(n)=8T(n/4)+O(n3/2).

    a=8a=8a=8, b=4b=4b=4, and f(n)=O(n3/2)f(n) = O(n^{3/2})f(n)=O(n3/2).

  11. What is nlog⁡ban^{\log_b a}nlogb​a for the recurrence T(n)=8T(n/4)+O(n3/2)T(n) = 8T(n/4) + O(n^{3/2})T(n)=8T(n/4)+O(n3/2)?

    nlog⁡48=n3/2n^{\log_4 8} = n^{3/2}nlog4​8=n3/2.

  12. Which Master Theorem case applies to T(n)=8T(n/4)+O(n3/2)T(n) = 8T(n/4) + O(n^{3/2})T(n)=8T(n/4)+O(n3/2)?

    Case 2.

  13. What is the asymptotic bound for T(n)=8T(n/4)+O(n3/2)T(n) = 8T(n/4) + O(n^{3/2})T(n)=8T(n/4)+O(n3/2) using the Master Theorem?

    O(n3/2log⁡n)O(n^{3/2} \log n)O(n3/2logn).

  14. How many levels are in the recursion tree for T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n)T(n)=aT(n/b)+f(n)?

    log⁡bn\log_b nlogb​n levels (when problem size is reduced to 1).

  15. For T(n)=2T(n/2)+O(n)T(n) = 2T(n/2) + O(\sqrt{n})T(n)=2T(n/2)+O(n​), what is the work done at level lll of the recursion tree?

    2l⋅O(n/2l)=O(2l⋅n/2l)=O(n⋅2l)=O(n⋅2l/2)2^l \cdot O(\sqrt{n/2^l}) = O(2^l \cdot \sqrt{n} / \sqrt{2^l}) = O(\sqrt{n} \cdot \sqrt{2^l}) = O(\sqrt{n} \cdot 2^{l/2})2l⋅O(n/2l​)=O(2l⋅n​/2l​)=O(n​⋅2l​)=O(n​⋅2l/2).

  16. What is the purpose of using powers of 2 (e.g., 2m2^m2m) when searching an unbounded range (like Infinity Stones)?

    To establish an upper bound for binary search in logarithmic time.

  17. Describe the two-step strategy to find a target 'k' in an unbounded range using an oracle that says if 'k' is higher or lower than the current position.

    1. Exponential search to find a bound: Check planets 20,21,22,…2^0, 2^1, 2^2, \dots20,21,22,… until a planet 2m2^m2m is found such that k≤2mk \le 2^mk≤2m. This establishes a range [2m−1,2m][2^{m-1}, 2^m][2m−1,2m].
    2. Binary search: Perform a standard binary search within the bounded range [2m−1,2m][2^{m-1}, 2^m][2m−1,2m].
  18. What data structure combination is proposed to handle image document operations with specified time complexities (Import: O(N)O(N)O(N), Display: O(N)O(N)O(N), Move Below: O(log⁡N)O(\log N)O(logN))?

    A sorted array of image IDs, where each ID points to its corresponding node in a doubly-linked list representing the display order.

  19. How does storing pointers from a sorted array to nodes in a doubly-linked list help achieve O(log⁡N)O(\log N)O(logN) 'Move Below' operations?

    The sorted array allows O(log⁡N)O(\log N)O(logN) lookup of any image ID, retrieving its corresponding linked list node. Once the nodes are found, reordering in a doubly-linked list takes O(1)O(1)O(1) time.

  20. Explain the 'Import' operation for the image document data structure, including its time complexity.

    Add the new image ID to the sorted array (which takes O(N)O(N)O(N) for a dynamic sorted array) and prepend its node to the doubly-linked list (O(1)O(1)O(1)). Total time: O(N)O(N)O(N).

  21. Explain the 'Display' operation for the image document data structure, including its time complexity.

    Iterate through the doubly-linked list from beginning to end, outputting each image ID in order. This takes O(N)O(N)O(N) time.

  22. In the 'brick blowing' problem, what is the meaning of a wolf blowing on a house with 'X' bricks?

    House 'X' falls, along with all houses to its east that have fewer than 'X' bricks.

  23. How can the 'damage' (number of houses blown down) from blowing on a specific house be calculated?

    Count 1 for the target house itself, plus the number of houses to its east with fewer bricks.

  24. What defines a 'special' house in Porkland?

    A house is special if it has no easterly neighbor, or its adjacent easterly neighbor has at least as many bricks.

  25. If all but one house in Porkland is special, what does this imply about the structure of the house brick counts?

    The sequence of brick counts is non-decreasing up to a certain point, then drops once, and then is non-decreasing again. It forms a 'peak' or 'valley' structure if you consider the non-special house as the point of deviation.

  26. Given that all but one house is special, how can the total damage for each house be calculated in O(N)O(N)O(N) time?

    Find the non-special house (dividing the array into two non-decreasing parts). For houses in the second part, damage is 1. For houses in the first part, use a two-pointer approach to efficiently count houses to the right with fewer bricks.

Card 1 of 26
Card 1 of 26

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent