Tut-Lab Week 2
Develop familiarity with object-oriented programming concepts
Learn about the representation of objects and inheritance in Java
Gain familiarity with Java development using Eclipse
Practise documenting code using Javadoc
Tut-Lab Week 4
Understand the object-oriented design process
Learn to evaluate different system designs
Gain familiarity with tools for object-oriented design
Review the material on CRC cards and UML class and sequence diagrams
Tut-Lab Week 5
Understand polymorphism and interface type design
Gain practical experience implementing an interface type
Learn to evaluate different class implementations
Use and understand different notions of equality in Java
Tut-Lab Week 3
Understand Programming by Contract
Understand inheritance in object-oriented programming
Understand how class invariants work with inheritance
Learn to use JUnit for unit testing
Review the concepts of encapsulation,
NEW SOUTH WALES
School of Computer Science and Engineering
University of New South Wales
LECTURE 2: RECURRENCES
1 / 19
Big Oh notation: f (n) = O(g(n) is an a
How to determine efficiency?
Measure program execution costs (empirical)
run program on various inputs, measure time .
but depends on compiler, machine, etc, etc.
Analyse execution costs abstractly (theoretical)
identify core operatio
Example D&C algorithm: binary search (recursive)
/ Find index of value v in sorted a[0.n-1]
int search(int v, int a, int n)
return searchR(v, a, 0, n-1);
int searchR(int v, int a, int lo, int hi)
int mid = (lo+hi)/2;
if (lo > hi) return -1;
Analysis of Software
Analysis is a major theme in COMP1927
In COMP1917, the focus was on building software
plus unit testing for "quality control"
Analysis implies that we have properties to examine
But first, what are the objects being measured?
Many people "get stuck" when faced with a new problem
where to start?
how on earth can I solve it?
what approach should I use?
Over time, people have identified
standard approaches/strategies for solving problems
a range of specific algori
Searching in a Sorted Array
Assume int a[n] and v is an integer value.
Problem: find the position of v in array a
if v in array, return i s.t. a[i]=v
if v not in array, return -1
If v occurs several times .
return index of first occurence?
return index of
To solve a problem on a whole data structure .
split the data structure into two parts
solve the problem on each part
combine results for parts
A general problem-solving strategy with wide application.
Typically produces elegant recursi
The previous example is a special case of
a function that traverses a list
applying a function to each item
The same pattern applies, regardless of function
void applyToList(List L, Function F) cfw_
if (!empty(L) cfw_
head(L) = F(head(L)
Unix shells are command interpreters that are
interactive: history, command editing, aliases, .
programmable: variables, control structures, functions, .
Their primary task is to invoke/execute other commands
finds the executable file for named
Recursive Operations on Data Structures
Many data structures can be described recursively, e.g.
a list is comprised of
a head (an item)
a tail (a list)
a binary tree is comprised of
a root (an item)
a left subtree (a tree)
a right subtree (a tre
Example: Point Data Type
Consider a type for points in 2d space
each point has a location in the plane (x,y)
can declare variables of type Point
Point variables can move around
can determine distance between two points
We give two definitions:
DT = non-ab
Cost is primarily interesting for large data
consider growth rate rather than absolute cost
Leads to complexity classes and big-O notation
Definition: for some function g(n) .
g(n) is said to be in the set O(f(n), if
there exists co
THE UNIVERSITY OF NEW SOUTH WALES
JUNE or NOVEMBER
ENGINEERING DESIGN IN COMPUTING
(1) READING TIME 10 MINUTES
(2) TIME ALLOWED 2 HOURS
(3) TOTAL NUMBER OF QUESTIONS 5
(4) ANSWER ALL