Transcript Not
CSC 1351
Semester Summary
CSC 1351 Summary
A study aid
Not an exclusive set of study materials
Please check:
http://www.cct.lsu.edu/~sbrandt/csc1351/
Please look at quizzes, exams, homework
CSC 1351 Summary
Know the definitions for:
interface
class
abstract class
constructor
polymorphism (override + dynamic lookup)
callback
primitive types
Objects
CSC 1351 Summary
Code:
The "Hello, World" program
The Applet version of "Hello, World"
How to write a sorter
Array manipulation
Examples for definitions
CSC 1351 Summary
String vs. String Buffer
know basic methods and what they do
class Object
String toString()
int hashCode()
boolean equals(Object)
CSC 1351 Summary
Recursion
Understand how to write recursive programs
fibonacci
factorial
double factorial
how to convert a loop to a recursive call
expect a never-before-seen recursive call
Recursion Example:
Greatest Common Denominator
public class GCD {
public static int gcd(int x,int y) {
if(y == 0)
return x;
System.out.println("x="+x+",y="+y);
return gcd(y,x%y);
}
public static void main(String[] args) {
int a0 = Integer.parseInt(args[0]);
int a1 = Integer.parseInt(args[1]);
System.out.println("gcd("+args[0]+","+args[1]+")="+gcd(a0,a1));
}
}
CSC 1351 Summary
Input/Output
Streams vs. Writers
Know what's there
InputStreamReader
Sockets
BufferedWriter
etc.
Know how to make your own Writer, Reader,
InputStream, OutputStream
Example: BufferStream
import java.io.PrintStream;
public class BufferStream extends java.io.OutputStream {
StringBuffer sb = new StringBuffer();
@Override
public void write(int n) throws java.io.IOException {
sb.append((char)n);
}
@Override
public String toString() {
return sb.toString();
}
public static void main(String[] args) {
BufferStream bs = new BufferStream();
PrintStream ps = new PrintStream(bs);
ps.println("Hello,");
ps.println("World");
ps.close();
System.out.println("All done");
System.out.println("buffer="+bs);
}
}
CSC 1351 Summary
Regular Expressions
Literal
Character Class
Group
Non-Capturing Group
Quantifier
Reluctant Quantifier
Expect questions of the form "what pattern
matches this"
Regex Example
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Eqn {
public static void main(String[] args) {
Pattern p = Pattern.compile(
"\\d+([+\\-]\\d+)*=\\d+");
Matcher m = p.matcher(
"3+4=7 100-9+11=102 3+8 9-4+ 1=1");
while(m.find())
System.out.println(m.group());
}
}
CSC 1351 Summary
Know the basic sorters we've discussed
(relevant speeds, concept of how they work)
MergeSort
QuickSort
BubbleSort
SelectionSort
Know the basic search strategies
– Binary
– Linear
Object Oriented Design
Know what a CRC is
Know how to diagram objects
Know how to map diagrams to code
Know what assert() does and how to use it
Know what javadoc comments are
UML Basics
Inherits, is a...
Implements, is a...
Aggregation, has a...
Dependency
Big O Notation
Understand what Big O notation means
The fastest growing term, ignore the coefficients
O(N2) can apply to T(N) = 3*N2+100*N+104
O(N2) can apply to T(N) = 5*N2
Understand basic calculation
T(2*N) = T(N)+1 means O(log(N))
T(2*N) = 2*(N+T(N)) means O(N*log(N))
T(2*N) = 4*T(N) means O(N2)
CSC 1351 Summary
Data structures
Know the List interface
Know ArrayList
Know LinkedList
Know the Map interface
Know HashMap
Know how to implement a hash code
Know TreeMap
CSC 1351 Summary
Know how to implement an ArrayList
Know how to implement a Hashtable
Know what an AVL Tree is
Know how to do right and left rotations