Functional Graphs

What if every node has exactly one outgoing edge? These functional graphs have special structure.

47 lessons
140 min

Lessons

1. Intro

(The special constraint)

3m

2. Function Notation

(Successor as a function)

3m

3. The Rho Shape

(Why cycles always appear)

3m

4. Example Graph

(Visualizing the structure)

3m

5. Why This Matters

(The power of predictability)

3m

6. Floyd's Algorithm

(Tortoise and hare)

3m

7. Floyd's Implementation

(The detection phase)

3m

8. Finding Cycle Start

(The meeting point trick)

3m

9. Why Floyd Works

(The distance proof)

3m

10. Cycle Length

(Measuring the loop)

3m

11. Problem - Linked List Cycle II

(LeetCode 142)

3m1 problems

12. Core Idea - Two-Phase Approach

(Detection then location)

3m

13. Core Idea - Null Pointer Check

(Handling no cycle case)

3m

14. Linked List Cycle II - Implementation

(Floyd's algorithm in code)

3m1 problems

15. Linked List Cycle II - Walkthrough

(Example execution)

3m

16. Linked List Cycle II - Lessons

(summary)

3m

17. Binary Lifting for Successors

(Jumping in powers of 2)

3m

18. Preprocessing Table

(Computing jump pointers)

3m

19. Query Processing

(Decomposing k into powers)

3m

20. Problem - Planets Queries I

(CSES 1750)

3m1 problems

21. Core Idea - Preprocessing Once

(Amortizing the cost)

3m

22. Core Idea - Binary Representation

(Why powers of 2 work)

3m

23. Planets Queries I - Implementation

(Binary lifting in code)

3m1 problems

24. Planets Queries I - Walkthrough

(Example execution)

3m

25. Planets Queries I - Lessons

(summary)

3m

26. Quiz: Functional Graph Distances

Knowledge check

2m1 problems

27. Tail vs Cycle Position

(Two regions)

3m

28. Precomputing Cycle Info

(One-pass detection)

3m

29. Distance Query Cases

(Four scenarios)

3m

30. Problem - Planets Queries II

(CSES 1160)

3m1 problems

31. Core Idea - Cycle Membership

(Marking the loop)

3m1 problems

32. Core Idea - Distance to Cycle

(Tail length computation)

3m

33. Core Idea - Cycle Position Index

(Tracking location in loop)

3m

34. Planets Queries II - Walkthrough

(Example execution)

3m

35. Planets Queries II - Lessons

(summary)

3m1 problems

36. Problem - Planet Cycles

(CSES 1751)

3m1 problems

37. Core Idea - DFS with Memoization

Computing all distances at ...

3m

38. Core Idea - Color-Based Detection

(Tracking DFS state)

3m1 problems

39. Planet Cycles - Walkthrough

(Example execution)

3m

40. Planet Cycles - Lessons

(summary)

3m

41. Permutation Cycles

(Application to permutations)

3m1 problems

42. Cycle Decomposition

(Breaking into components)

3m

43. Application - Sorting with Swaps

(Minimum swaps to sort)

3m

44. Application - Josephus Problem

(Elimination sequences)

3m

45. Space Improvement

(Reducing memory usage)

3m

46. Common Mistakes

(What goes wrong)

3m

47. Section Recap

(What you learned)

3m

Practice Problems

1.
Linked List Cycle IILeetCodemedium
3.
5.
Mouse HuntCodeforcesmedium
6.
Round DanceCodeforcesmedium

Ready to start learning?

Access all 47 lessons with interactive content and progress tracking.