Coding Competition Day

Coding Competition

Data Structures & Algorithms

CSCI 4513

Week 6, Lecture 11

Today's Learning Objectives

What is Recursion?

Recursion is when a function calls itself to solve smaller versions of the same problem.

Classic Example: Factorial

function factorial(n) {
  // Base case
  if (n === 1) return 1;

  // Recursive case
  return n * factorial(n - 1);
}

factorial(5); // 120

Key Components:

  • Base Case: When to stop
  • Recursive Case: Call itself with simpler input
  • Progress: Each call moves toward base case

Why Learn Recursion?

πŸ’‘ Fun Fact: Many problems that seem complex iteratively become elegant when solved recursively!

Today's Format: Choose Your Path

πŸ† Option A: Competition

  • Solve recursion exercises
  • Compete for prizes!
  • Test your skills
  • Learn from challenges

πŸ”§ Option B: Lab Time

  • Catch up on homework
  • Get help with projects
  • Ask questions
  • No pressure!

Both options are equally valid! Choose what serves your learning best right now.

The Recursion Exercises

Today's challenges come from The Odin Project's Computer Science section:

Five Challenges:

  1. Fibonacci: Generate Fibonacci sequence
  2. Merge Sort: Sort array using divide-and-conquer
  3. Linked List: Recursive list operations
  4. Binary Search Tree: Build and traverse BST
  5. Knight Travails: Find shortest path for chess knight

Competition Rules

How It Works:

  • πŸ”— Clone the repository from GitHub
  • ⏱️ Work on the exercises during class
  • βœ… Pass the automated tests
  • πŸ† Prizes for top performers!

Important Guidelines:

  • You can use any resources (documentation, notes, etc.)
  • Work individuallyβ€”this tests YOUR skills
  • Ask me for help if you're stuck
  • Focus on learning, not just winning!

Tips for Success

Let's Get Started!

Competition Track:

  1. Clone the repository
  2. Navigate to the recursion folder
  3. Read the README for each exercise
  4. Start coding!
  5. Run tests: npm test

Lab Track:

Work on any incomplete homework assignments. Ask questions. Use this time to catch up and solidify your understanding!

A Note About The Odin Project Curriculum

We are largely skipping this section of The Odin Project:

A Bit of Computer Science

Why Skip It?

πŸ’‘ But Don't Ignore It Completely!

When you have time, work through these exercises on your own. They make excellent portfolio items and great practice for technical interviews. The data structures and algorithms here are fundamental CS knowledge!

Today's Takeaways

What You Accomplished:

πŸ“… Next Class: Intermediate Git

πŸ† Competition Winners: TBDβ€”great job everyone!