khan
Uploaded by
7 SLIDES
207 VUES
70LIKES

Mastering Recursion in Java: Tools, Techniques, and Problem-Solving Strategies

DESCRIPTION

This course dives into the fundamental concepts of recursion and its applications in Java programming. Learn about essential data structures like lists and maps, techniques for Big O analysis, and the intricacies of classes and inheritance. You’ll explore the process of breaking down complex problems into simpler components, significantly enhancing your coding skills. Engage with practical exercises, classwork, and quizzes on Sakai. By the end of this course, you will have a strong grasp of recursive functions and their role in solving problems efficiently.

1 / 7

Télécharger la présentation

Mastering Recursion in Java: Tools, Techniques, and Problem-Solving Strategies

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript

Playing audio...

  1. Recursion Snarf the code for today’s class.

  2. Where We Are: Tools and Techniques • Data Structures, like Lists and Maps • Techniques, like Big O analysis • Classes and Inheritance • The essential process of taking a problem and solving it with code All of it happens to be within Java in this course…but these ideas transcend Java

  3. Recursion • When a function calls a “clone” of itself • Also, when a Data structure contains a “clone” of itself (but we will save this one for later)

  4. What to do • Snarf the code for today’s class if you haven’t already • Go to the quiz section of Sakai • There’s classwork for today there • Go through and try to answer the questions (feel free to take you time, think, and ask a friend) • If you get stuck, run the code and see what’s going on • If you finish it all, start on the BONUS section

  5. Two Parts To Every Recursive Function • Base Case if(n == 1) return 1; • Recursive Case return n*recursiveFunction(n-1); The basic idea is to get help solving a problem from coworkers (clones) who work and act like you do. • Ask clone to solve a similar, but smaller/simpler problem • Use the result • Don’t forget step 2!

  6. How you divide the problem is key Say you want to count the number of “a”sin a string. How could you solve that problem recursively? Hint: how many “a”s does a string of length 0 have?

  7. How you divide the problem is key isPalindrome(String s) abaXaba -> true abba -> true abab -> false

More Related