Tut-Lab Week 2
Aims:
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
Preparati
Tut-Lab Week 4
Aims:
Understand the object-oriented design process
Learn to evaluate different system designs
Gain familiarity with tools for object-oriented design
Preparation:
Review the material on CRC cards and UML class and sequence diagrams
Rev
Tut-Lab Week 5
Aims:
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
Preparation:
Re
Tut-Lab Week 3
Aims:
Understand Programming by Contract
Understand inheritance in object-oriented programming
Understand how class invariants work with inheritance
Learn to use JUnit for unit testing
Preparation:
Review the concepts of encapsulation,
NEW SOUTH WALES
Algorithms:
COMP3121/3821/9101/9801
Aleks Ignjatovic
School of Computer Science and Engineering
University of New South Wales
LECTURE 2: RECURRENCES
COMP3121/3821/9101/9801
1 / 19
Asymptotic notation
Big Oh notation: f (n) = O(g(n) is an a
Algorithm Efficiency
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)
cfw_
return searchR(v, a, 0, n-1);
int searchR(int v, int a[], int lo, int hi)
cfw_
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?
Program
Problem-solving
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
Divide-and-conquer
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
Function Pointers
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 Shell
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
o
o
a head (an item)
a tail (a list)
a binary tree is comprised of
o
a root (an item)
o
a left subtree (a tree)
o
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
Algorithmic Complexity
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
FAMILY NAME
OTHER NAMES
STUDENT ID
SIGNATURE
THE UNIVERSITY OF NEW SOUTH WALES
Sample Examination
JUNE or NOVEMBER
COMP2911
ENGINEERING DESIGN IN COMPUTING
(1) READING TIME 10 MINUTES
(2) TIME ALLOWED 2 HOURS
(3) TOTAL NUMBER OF QUESTIONS 5
(4) ANSWER ALL