CSE 116 Lecture Notes - Lecture 24: Junit, Linked List, Transfer Function
Document Summary
Large problems hard and scary to even start find working on small, easy problems much nicer. Divide large problems into smaller ones: before start coding, write junit test cases, split long methods to combine smaller method results. Clicker question: which structure(s) recursive: arraymultiset, list, arraylist, linked lists, stack, queue, none of the above answer: d. linked list -> node definition includes recursive reference to node. Starts with check for base case(s) these cases must return blatantly obvious answer. 1+ recursive calls found within recursive step(s: should write code assuming method works take 1 step advancing toward base case. No different than usual coding had been doing: at some point, recursive method calls itself, parameters & locals in frame & so specific to each call, once complete, execution returns to calling frame. Sample problem public static int findsum(int[] a, int j){ What if we later do not want recursion: 2nd param becomes pointless and very java-like to keep.