Skip to content

This project just contains some common problems solved recursively. The purpose of this project was to allow me to get more familiar with recursion.

Notifications You must be signed in to change notification settings

KZdesigns/recursion_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

recursion_examples

Recursion is the process of defining a problem (or the solution to a problem) in terms of (a simpler version of) itself. For example, we can define the operation "find your way home" as: If you are at home, stop moving. Take one step toward home. "find your way home". In computer science, recursion is a method of solving a problem where the solution depends on solutions to smaller instances of the same problem. Such problems can generally be solved by iteration, but this needs to identify and index the smaller instances at programming time.

upcase

Created an upcase method using recursion, the gotcha with this method is in the base case. For this praticular problem the we know that string with length of 1 (e.g. "a") should return its upcased version (e.g. "A").

reverse

Created an reverse method using recursion. Similar to the upcase method the one of the tricky parts in the in the base case, and using a string with length of 1. The other tricky thing about this practicular problem is in the the recursive case, you can do reverse(str[1..-1]) + str[0] or str[0] + reverse(str[0..-2])

quick_sort

Quick sort is probably the second most known sorting algorithm. Quick sort is the fastest sorting aglorithm and is implemented in most "sorting" problems. Quick_sort is actually the sorting algorithm #sort uses in Ruby.

About

This project just contains some common problems solved recursively. The purpose of this project was to allow me to get more familiar with recursion.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages