/* An object of this class has (almost) no methods */
public class C extends javax.swing.JFrame cfw_
/* return the area of the window. */
public int area() cfw_
return getWidth() * getHeight();
/* set the width of the window to its height. */
public void
Asymtotic complexity
Find first occurrence of string r in string s: O(nr*(ns-nr+1) (worst case)
ns-nr +1 comparisons, nr comparisons for each time
nr =1: O(ns);
nr=ns: O(ns);
nr=ns/2 O(ns*ns);
Deal with nested loop
int c =0;
for (int i=0;i<n, i+)cfw_ /n
public class recursiveExercisecfw_
public recursiveExercise()cfw_
public static String commafy(long n)cfw_
if (n<1000)
return " + n;
/n>=1000
return commafy(n/1000)+ "," +(n%1000);
/*Return a copy of s will all characters after the first vowel deleted
*
k
6 9 8 1 4 7 5 3 2 [b]
change b into the next higher permutation
k is the largest number such that b[k] <b[k+1]
j is the largest number such that b[j] > b[k]
b[k+1]. is decreasing
swap b[k], b[j]
=> to get the next smallest permutation
reverse b[K+1].
60 - 87 lines
A3: Use loop rather than recursion
body of loop does only one thing: move butterfly by 1 tile
use already written method.
Dont use throw unless it's really useful
there should not be too many throw.
Have to use try - catch
Prelim:
Be familia
public class TreeNodecfw_
public int value;
public TreeNode left;
public TreeNode right;
public int size()cfw_
return 1+(left = null? 0: left.size()+ (right = null? 0: right.size();
public static int size(TreeNode r)cfw_
return 0;