CSC236 recursive runtime 2

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

14 Terms

1
New cards

Bottom heavy recurrence

Where majority of the “steps”, runtime come from the lower levels of recursion 

b^d < a

T(n)∈Θ(n^log_b​ a)

Example: Think of a giant tree orchard, where every small branch sprouts many new branches. Most of the fruit is at the bottom of the tree, so the lower branches do all the work

2
New cards

Balanced recurrence

The work around each level of recursion is roughly the same everything is around equal

b^d = a 

T(n)∈Θ(n^d logn)

Ex: Imagine a factory assembly line — every station contributes equally to the final product. No single station (level) dominates

3
New cards

Top-heavy recurrence

Most work done top of recursion tree, deeper levels do little

a<b^d

T(n)∈Θ(n^d)

Ex: Think of a boss-heavy project — the manager (top) does almost all the work, and the employees (lower levels) just follow instructions

4
New cards

Number of leaves = n^(log_b a)

Each recursive call decreases the size by n / b for k times meaning it splits into “a” smaller sizes

If you keep going till base case you get n^log_b a

Ex:

Imagine a tree where every branch splits into a branches.

If the tree height is log_b n ​, the bottom-most branches (leaves) are n^log_b a

5
New cards
<p>Simplfied time recurrence  </p>

Simplfied time recurrence

n^d work outside recursion

aT(n/b) work done by recursion

Think of solving a big project:

  • n^d → Work at this level (outside recursion):

    • This is the work you do yourself before delegating.

    • Analogy: You’re the project manager making plans, setting up tools, or merging the results at the end. The bigger the project (n), the more time this takes.

  • a → Number of subprojects you delegate:

    • You break the project into a smaller teams.

  • n/b → Size of each subproject:

    • Each team gets a piece that’s 1/b the size of the original.

  • T(n/b) → Work done by each team recursively:

    • Each team does the same process on its smaller task: do their work (n^d for that level) + delegate to smaller sub-teams.

<p>n^d work outside recursion </p><p>aT(n/b) work done by recursion </p><p></p><p>Think of solving a <strong>big project</strong>:</p><ul><li><p><strong>n^d → Work at this level (outside recursion):</strong></p><ul><li><p>This is the work you do yourself <em>before</em> delegating.</p></li><li><p>Analogy: You’re the project manager making plans, setting up tools, or merging the results at the end. The bigger the project (n), the more time this takes.</p></li></ul></li><li><p><strong>a → Number of subprojects you delegate:</strong></p><ul><li><p>You break the project into <strong>a smaller teams</strong>.</p></li></ul></li><li><p><strong>n/b → Size of each subproject:</strong></p><ul><li><p>Each team gets a piece that’s 1/b the size of the original.</p></li></ul></li><li><p><strong>T(n/b) → Work done by each team recursively:</strong></p><ul><li><p>Each team does the same process on its smaller task: do their work (n^d for that level) + delegate to smaller sub-teams.</p></li></ul></li></ul><p></p>
6
New cards

What is the recurrence for normal multiplication?

knowt flashcard image
7
New cards

What is the recurrence for Karatsuba’s algorithm?

knowt flashcard image
8
New cards

Why is it n²? for normal multiplication

it grows by a factor of 2 each level of tree

9
New cards

Why does removing 1 recursive call change the Θ so much?

It’s bottom heavy

Removing just 1 recursive call drops the branching factor from 4 → 3

10
New cards

What does n^(log₂ 3) mean?

just the number of leaves in the recursion tree

11
New cards

How do I know if the recurrence is bottom-heavy, balanced, or top-heavy?

  • a = number of recursive calls

  • b = factor by which the problem size shrinks each level

  • d = exponent of the work done outside recursion

<ul><li><p><span>a</span> = number of recursive calls</p></li><li><p><span>b</span> = factor by which the problem size shrinks each level</p></li><li><p><span>d</span> = exponent of the work done outside recursion</p></li></ul><p></p>
12
New cards

a > b^d

b^d < a = top heavy : The manager at the top does most of the work; the sub-teams don’t contribute muc

13
New cards

a = b^d

b^d = a : balance : Each level of the project (top, middle, bottom) contributes equally, like a factory assembly line

14
New cards

b^d > a 

b^d > a = bottom heavy : Lots of teams are working at the smallest subprojects; most work happens at the bottom