Algorithms Basics: Topic – Recursion

Recursive functions are well known in the domain on algorithms. They are widely used due to their simplicity of code. Here we describe the topic of recursion.

Recursive functions:

Any function that calls itself is called a recursive function!

Yep! It’s just that simple. Let me explain with an example. Below is the code for fibonacci series. Note how fib() takes an input of (n) and returns the n-th term of the series. This function calls itself when n>2. This is a typical example of recursive functions.

def fib(n):
			return 0
			return 1
			return fib(n-1) + fib(n-2)

Fork the code yourself here!

Properties of recursive functions:

  • Recursive functions have two cases:
    • A base case: where the function terminates.
    • A recursive case: where the function calls itself.
  • Every recursive function must terminate at base case. If not defined, the function goes into infinite loop and hence result in stack overflow.
  • Recursive functions store the function information in stack memory.
  • Every algorithm modeled using recursive function can also be modeled using iterative functions by using stack data structures.
  • Iterative solutions are more efficient than recursive functions due to the overhead of extra function calls and stack memory usage.
  • Recursive functions are used since it is easy to visualize the algorithm using recursive approach.
  • For some problems there are no obvious iterative approach algorithms, and hence recursive functions are preferred.

Examples of recursive algorithms:

  1. Fibonacci Series. Try yourself here!
  2. Factorial of a number. Try yourself here!
  3. Merge Sort.
  4. Quick Sort.

Amazing Grace

I just came across this wonderful experience of watching Rear Admiral Grace M. Hopper  on David Letterman Show! And trust me, I am just talking to my self since then , Where on earth you were Ankita till now! Why you haven’t seen this video till now! I think everyone on this planet who believes in science must try and know more about Amazing Grace! Thank you Mam (Rear Admiral Grace M. Hopper) for making the first compiler! If you wouldn’t have done that, this post or my identity couldn’t have been possible!

To all readers:

  • Please read more about her:
  • Enjoy the below video

Requirement Analysis explained in a Screen Play!!

What is better than learning from a movie!! I know theory subjects can get boring sometimes… But We are here with a video to explain the concepts of Requirement Analysis Phase of Software engineering!!  This video was created as a part of our project in college. Back then we were kids with great enthusiasm, which we have always kept alive! This is an initiative to let the ideas explore! The video also features an in-depth presentation of how a software is created from scratch! Let us know your feed back!!


Innovate hub is in a constant endeavour to provide its readers the best it can. Although a niche, we believe in starting from the roots itself. Put your comments, messages below or hit Like! Subscribe to our YouTube Channel for interesting videos! Don’t forget to hit the “I am Innovator” Button to follow this blog! Thanks a Ton!

Solution to Route To Mumbai Problem! #PGEE #trickyquestion #twodoorsriddle

Lets have a look at the constraints of the problem…

1) One of the two roads go to Mumbai – the traveler’s destination.

2) One of the two brothers speak truth and other is a liar.

If the traveler asks the direct question to one of the brothers- “Which road goes to Mumbai?” to any one of the brothers, there could be one of the two cases:

  • The traveler asked this question to the brother who speaks truth. And he is pointing to the right road.
  • The traveler asked this question to the brother who speaks lie. And he is pointing to the wrong road.

In any of the case, the traveler is in 50% probability of getting the right road. Since there is no way traveler can tell with this question who is the truth telling brother. Clearly direct question is no way to our solution.

But if we think little logically and ask the traveler this question to one of the brothers – “What do you think if I asked your brother(means the other brother) on which road goes to Mumbai, what will be his reply?”

Now lets look at the possible answers to this question. Any one of the two cases are possible –

  • Traveler asked this question from  the Truth telling brother. Now the truth telling brother always speaks truth. And he know that his brother is a liar. So he must reply the road his brother will point to, on asking the route to Mumbai. Since his brother is a liar, He will point to the Road that leads to Delhi. Truth speaking brother will thus point to road to Delhi as his reply to the intelligent question asked.
  • Traveler asked this question from the liar brother. Now he knows that his brother is truth speaking person. And his brother will point to Route to Mumbai on the question – Which road goes to Mumbai. But here comes the Twist! This brother is a liar. He always speak false. So he will point to route to Delhi as opposed to his brother’s reply. 

Notice the situation carefully. In both cases the traveler is getting pointed towards the Route to Delhi. Now this traveler is smart. And he had already analyzed the responses before asking his intelligent question. So he will now know which road is wrong. Clearly the other one is his Route to Mumbai!

Happy travelling Sir!

Innovate-Hub is constantly in the endeavor to provide its readers the best they need. To help us grow and analyze our readers wants, help us by answering the below survey.

Link to the Survey

what is cloud computing?

Cloud computing is the delivery of computing as a service rather than a product, whereby shared resources, software, and information are provided to computers and other devices as a utility (like the electricity grid) over a network (typically the Internet).

The concept of cloud computing fills a perpetual need of IT:

  • a way to increase capacity or add capabilities on the fly without investing in new infrastructure,
  • training new personnel, or licensing new software.

Cloud computing encompasses any subscription-based or pay-per-use service that, in real time over the Internet, extends IT’s existing capabilities.

The term “cloud” is used as a metaphor for the Internet, based on the cloud drawing used in the past to represent the telephone network, and later to depict the Internet in computer network diagrams as an abstraction of the underlying infrastructure it represents.


Public cloud

Public cloud describes cloud computing in the traditional mainstream sense, whereby resources are dynamically provisioned to the general public on a fine-grained, self-service basis over the Internet, via web applications/web services, from an off-site third-party provider who bills on a fine-grained utility computing basis.

Community cloud

Community cloud shares infrastructure between several organizations from a specific community with common concerns (security, compliance, jurisdiction, etc.), whether managed internally or by a third-party and hosted internally or externally. The costs are spread over fewer users than a public cloud (but more than a private cloud), so only some of the benefits of cloud computing are realised.

Hybrid cloud

Hybrid cloud is a composition of two or more clouds (private, community, or public) that remain unique entities but are bound together, offering the benefits of multiple deployment models.

Private cloud

Private cloud is infrastructure operated solely for a single organization, whether managed internally or by a third-party and hosted internally or externally.

They have attracted criticism because users “still have to buy, build, and manage them” and thus do not benefit from lower up-front capital costs and less hands-on management, essentially “[lacking] the economic model that makes cloud computing such an intriguing concept”

Source :