Skip to content

Lectures

These files cover fundamental Java concepts and classic data structure implementations used throughout the course.


Java Review

Lecture 1: Basics

  • HelloWorld.java - Classic first program, prints "Hello, World"

Lecture 2: Operators & Control Flow

  • IntOps.java - Demonstrates basic integer operations (addition, multiplication, division, modulo)
  • LeapYear.java - Boolean logic example: determines if a year is a leap year using conditional operators
  • Quadratic.java - Math operations: calculates roots of quadratic equations using the quadratic formula
  • RandomInt.java - Generates random integers within a specified range using Math.random()
  • Ruler.java - String concatenation example: recursively builds ruler measurement patterns
  • RandomNumber.java - Explores different ways to generate random numbers using Math.random() and Random class

Lecture 3: Conditionals & Loops

  • Discriminant.java - Determines if a quadratic equation has real roots by calculating the discriminant
  • Flip.java - Simple coin flip simulation: randomly outputs "Heads" or "Tails"
  • Gambler.java - Gambler's ruin simulation: estimates probability of reaching a goal before losing all money
  • PowersOfTwo.java - Prints powers of 2 up to 2^N using a while loop
  • PowersOfTwoFor.java - Same as PowersOfTwo but using a for loop instead
  • RulerN.java - Generates ruler subdivisions using string concatenation in a loop
  • Sqrt.java - Computes square roots using Newton-Raphson method with iterative refinement

Lecture 4: Arrays

  • RandomCard.java - Picks and displays a random playing card from a deck
  • Deck.java - Creates and displays all 52 playing cards using nested loops and arrays
  • Deck2.java - Creates a deck and shuffles it using the Fisher-Yates shuffle algorithm
  • Shuffle.java - Simple random card selection (similar to RandomCard)
  • Shuffling.java - Full deck shuffle implementation using random swaps
  • CouponCollector.java - Simulates the coupon collector problem: how many random draws needed to collect all N distinct items

Data Structures

  • WeightedQuickUnionUF.java - Union-Find data structure with path compression for efficient set operations
  • Vector.java - Demonstrates immutability in Java with defensive copying of mutable data
  • UnorderedMaxPQ.java - Priority queue implementation using an unordered array
  • MaxPQ.java - Binary heap implementation of a max priority queue with swim/sink operations
  • TestArrays.java - Multi-dimensional array examples and boolean array manipulation