Giter Site home page Giter Site logo

recursion's Introduction

Recursion

  • Why do we care?
    • useful for working with recursive data structures (trees, like the DOM in html, linked lists, graphs)
    • useful for exploring all options when there are a LOT of options (e.g. generating all permutations of a string, finding a path through a maze)
    • useful for interviews
      • good tool for problem solving/algorithmic thinking
  • What is recursion?
    • simple idea: functions that call themselves (or two or more functions that call each other back and forth)
    • useful way to think of recursive problems:
      • what's the smaller equivalent problem?
        • if you had a magical oracle that could give you a solution to that smaller problem, how would you use the solution to get to a solution for the problem at hand?
      • what's the smallest problem of this type? (base case)
        • what's the solution in that case?
  • tail recursion
    • This typically means that the recursive function just calls itself once, at the end
    • sample problem: reverse a string
    • draw stack frame diagrams
  • branching recursion
    • multiple potential recursive calls each time through
    • sample problem: towers of hanoi
    • more stack frames
    • discuss efficiency
  • practice problems
    • permutations of characters
    • merge sort
    • in order, post order, pre order traversal of trees

recursion's People

Contributors

sdspikes avatar

Watchers

James Cloos avatar Hunter Chapman avatar Jessica Durbin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.