Recursion in real life

7 Oct

This semester, I am teaching a new class: Intro To Programming. I try to find ways to explain stuff so that all of my students (and me) understand it. Recursion is complex, but it reminds me of trying to make lunch plans when several people are involved. And when a function calls itself, it’s like putting a conversation on hold. Recursion

Recursion is when three calls are put on hold before a lunch decision is made.

Asha would like to have lunch with Blake.

They call Blake.

They say: Hi Blake, would you like to go for lunch in the student center?

Blake says to Asha: That’s a cool idea, but I was hoping to meet with Cynthia today.

Let me put you on hold and call them.

They call Cynthia

They say: Hi Cynthia, would you like to go for lunch in the student center?

Cynthia says to Blake: That’s a cool idea, but I was hoping to meet with Danny today.

Let me put you on hold and call them.

They call Danny

They say: Hi Danny, would you like to go for lunch in the student center?

Danny says to Cynthia: That’s a cool idea, but I was hoping to meet with Emilia today.

Let me put you on hold and call them.

They call Emilia

They say: Hi Emilia, would you like to go for lunch in the student center?

Emilia says to Danny: Yes! I’ll meet you at the student center.

Emilia hangs up

Danny says to Cynthia: Yes! I’ll meet you at the student center.

Danny hangs up

Cynthia says to Blake: Yes! I’ll meet you at the student center.

Cynthia hangs up

Blake says to Asha: Yes! I’ll meet you at the student center.

Blake hangs up

Asha is happy. All phone calls are ended and our friends can go to lunch!

 

Advertisements

One Response to “Recursion in real life”

  1. Swarn Gill October 9, 2018 at 6:19 am #

    Great analogy,…thank goodness for group texts. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: