Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
The "trick" to writing recursive code
Rating: 4.5 out of 5(1 rating)
255 students

The "trick" to writing recursive code

A short course presenting a trick to quickly and correctly implement recursive functions.
Created byAhmed Hisham
Last updated 2/2026
English
English [Auto],

What you'll learn

  • Learn to quickly and correctly write recursive functions
  • Acquire a simple mental check to test the completeness of recursive solutions/implementions
  • Tackle different classes of problems with the same trick
  • Conceptually understand recursive problem solving

Course content

2 sections16 lectures1h 56m total length
  • Introduction1:05

    Ahmad explains a simple trick to overcome getting stuck implementing recursive solutions and helps students translate recursive ideas into working code.

  • A note before we begin2:52

    Discover a simple trick to quickly implement recursive functions. The lecture emphasizes prerequisites from recursive thinking and the pyramid drawing problem to show why the approach works.

  • Recursive thinking: A Conceptual Walkthrough(Part 1: Intro)8:29

    Learn to solve a left-aligned pyramid of stars using recursion by building a smaller pyramid and adding one row, illustrating problem decomposition into subproblems.

  • Recursive thinking: A Conceptual Walkthrough(Part 2: Problem Breakdown)8:17

    Explore recursive thinking by breaking a four-level pyramid into sub-problems, solving a three-level pyramid, then adding a final row, illustrating dependence on the immediately previous solution.

  • Recursive thinking: A Conceptual Walkthrough(Part 3: Misconceptions)6:32

    Explore recursive thinking by incrementally building a pyramid from a trivial one-level case, solving each sub-problem by adding a row, and avoiding the misconception that recursion stacks multiple separate pyramids.

  • Recursive thinking: A Conceptual Walkthrough(Part 4: The Main Idea)6:47

    Learn to solve pyramid drawing through recursive thinking by deferring computation, establishing a base case, and building the full solution row by row from smaller sub-problems to any height.

  • Recursive thinking: A Conceptual Walkthrough(Part 5: The General Case)11:47

    Explore recursive thinking by drawing a left-aligned star pyramid, using a one-level base case and decrementing by one to build any n-level pyramid.

  • Recursive thinking: A Conceptual Walkthrough(part 6: The Computational View)6:57

    Explore the computational view of recursion, linking problem breakdown to executable steps and showing how the base case draws a star to build a pyramid.

  • The Pyramid Problem: Implementation(contains an important idea to the "trick")9:18

    Define a recursive pyramid function with a base case of one level and a recursive step that draws an extra row of n stars after solving the n-1 level pyramid.

  • The Pyramid Problem: Execution Breakdown(+implementation completeness check)10:38

    Explore a quick trick to write recursive functions by breaking down the pyramid problem’s execution from a one-level base case to an n-level pyramid, with a completeness check.

  • Before we continue(The recursive mindset)0:56

    Understand why tracing the execution of a recursive function doesn't help you write recursive code, and adopt a logical, structure-first mindset for correct implementations.

Requirements

  • Basic familiarity with a programming language(Python will be used)
  • Extremely basic familiarity with the concept of recursion

Description

This course presents a quick and effective trick to ease the implementation of recursive functions. The main objective of the course is to specifically overcome the experience of getting "stuck" while writing recursive function. There are also conceptual lectures discussing general concepts related to recursion. The so-called trick is discussed and applied practically through problems, then justified logically. Recursion is one of the most important topics for a computer scientist or programmer to understand. Recursion is also a vital concept to grasp for the study of data structures and algorithms . Python is used for implementation. This course is not for absolute beginner programmers as assumes a basic familiarity with at least one programming language. Also, the student being introduced to the basic ideas of recusion is preferred.  Python is used for implementation. This course is not for absolute beginner programmers as assumes a basic familiarity with at least one programming language. Also, the student being introduced to the basic ideas of recusion is preferred.  Python is used for implementation. This course is not for absolute beginner programmers as assumes a basic familiarity with at least one programming language. Also, the student being introduced to the basic ideas behind recursion is preferred.

Who this course is for:

  • All programmers who struggle with recursion!