Abstract Data Types
Documentation
Gunnar Gotshalks
13-1
Documentation
Users are only interested in the properties of the ADT
Programmers and designers require all the information
which a user needs AND all information pertaining to the
design and imple

Inheritance
and
Design by Contract & Genericity
Gunnar Gotshalks
22-1
Parents Invariant Rule
The invariants of all the parents of a class apply to
the class itself
The parents invariants are ANDed together, along
with the invariants of this class
If n

Case Study
Command DoUndo
Interaction
Gunnar Gotshalks
25-1
The Domain
Interactive systems usually have an undo operation
to be able to back up one or more steps
To preserve symmetry need to have a corresponding
redo operation
One keystroke gives undo

CSE 3101 Design and Analysis of Algorithms
Assignment for Unit 0
Unmarked (A subset of the questions in the book)
Jeff Edmonds
Read the book. Learn the steps. Go to class. Ask lots of question. Study the slides. Work hard on solving
these questions on you

Designing Classes
Part 1
Gunnar Gotshalks
26-1
Basis
Look at slides on Abstract Data Types
They give much of the underlying basis
Types of features
Properties of features
Documentation
Here we give some additional guidelines
Gunnar Gotshalks
26-2

Inheritance
What is it all about?
Gunnar Gotshalks
19-1
On Objects
An Object is a collection of data and methods to
operate on that data
Method is a procedure, function, operation
For a motor
turnOn
turnOff
setSpeed ( someSpeed )
Data
Methods
Gunnar

CSE 3101 Design and Analysis of Algorithms
Solutions for Review Test for Unit 1
(Required, checked for completion, but not read or marked.)
Jeff Edmonds
Dont cheat by looking at these answers prematurely.
1. Loop Invariants and Iterative Algorithms (Exerc

Inheritance
&
Adaptation
Gunnar Gotshalks
20-1
Open-Closed Principle
Open Available for extension add new features
Closed Available for client use stable in spite of
extensions
In real projects
A module needs to be both open and closed!
Gunnar Gotshal

BON
Case Study
Conference Management
Largely based on slides
by Prof. Paige
Gunnar Gotshalks
18-1
Conference Management
System to be used for managing a technical
conference
Should help organizers follow up a series of events
taking place during prepara

Designing Classes
Part 2
Gunnar Gotshalks
26-1
How Not to Use Inheritance
Class CAR, class PERSON put together to define a
new class CAR_OWNER
Every CAR_OWNER is both a PERSON
and a CAR ?
PERSON
CAR
CAR_OWNER
Gunnar Gotshalks
26-2
How Not to Use Inher

Singleton Pattern Creational
Intent
Ensure a class has only one instance
Provide a global point of access
Motivation
Some classes must only have one instance
file system, window manager
Applicability
Must have only one instance of a class
Must be a

Design
Context and Principles
Gunnar Gotshalks
02-1
Waterfall Model Software Life Cycle
Apply recursively at all levels from system level to subprogram.
Spiral model and evolutionary development are variations
Needs analysis requirements
Specification in

Case Study
Multi-Panel Interactive System
Gunnar Gotshalks
24-1
The Problem Domain
Build a general type of interactive system
Users interact with a set of panels
> Web applications are an example
Each session goes through a number of states
> Finite s

CSE 3101 Design and Analysis of Algorithms
Solutions for Assignment for Unit 4
Unmarked (A subset of the questions in the book)
Jeff Edmonds
Dont cheat by looking at these answers prematurely.
Chapter 16: Greedy Algorithms
1. Consider the counter example

State Pattern Behavioural
Intent
Alter behaviour of an object when its internal state
changes
Object appears to change its class
Alternate names
Objects for states
Gunnar Gotshalks
State-1
State Motivation
An object may be in one of many states. It

Builder Pattern Creational
Intent
Separate the construction of a complex object from
its representation so that the same construction
process can create different representations
Motivation
Reader for RTF (Rich Text Format) should be able
to convert to

Abstract Factory Pattern Creational
Intent
Provide an interface for creating families of related
or dependent objects without specifying their
concrete classes
Motivation
Building a user interface toolkit that supports
multiple look and feel standards

Global Objects
Gunnar Gotshalks
23-1
Manifest Constants
More commonly known as literals
Objects with their name being their value
> Numbers
0, -1, 5, 5.123, -4.3^-6, .
> Strings
"abcd", "I am a string", .
> Characters 'a', '0', .
Symbolic Constant Prin

Adapter Pattern Structural
Intent
Convert the interface of a class into another
interface that the client expects.
Lets classes work together that couldn't otherwise
Gunnar Gotshalks
Adapter-1
Class Adapter !Motivation
EDITOR expects a SHAPE
TEXT_VI

CSE 3101 Design and Analysis of Algorithms
Assignment for Unit 2
Unmarked (A subset of the questions in the book)
Jeff Edmonds
Read the book. Learn the steps. Go to class. Ask lots of question. Study the slides. Work hard on solving
these questions on you

Master-Slave Pattern Behavioural
Intent applies to objects
Handles computation of replicated services in a
system to achieve fault tolerance and robustness
Independent components providing the same
services (slaves) are separated from the
component (ma

Classes
The Static Structure
Abstract data types equipped with
a possibly partial implementation
Gunnar Gotshalks
04-1
Style Rules
Read page 180
Pick a style and stick to it
Recommend that you use Eiffel style or close
approximation
Gunnar Gotshalks

CSE 3101 Design and Analysis of Algorithms
Solutions for Assignment for Unit 1
Unmarked (A subset of the questions in the book)
Jeff Edmonds
Dont cheat by looking at these answers prematurely.
Chapters 1,2,4,5,&6: Loop Invariants and Iterative Algorithms

EECS 3101
Prof. Andy Mirzaian
Welcome
to the beautiful and wonderful
world of algorithms!
2
STUDY MATERIAL:
Course URL: www.cse.yorku.ca/~andy/courses/3101
[CLRS]
chapter 1
Lecture Note 1
NOTE:
Material covered in lecture slides are as self contained

York University
CSE 3101
March 14, 2012
Test 2
First Name:
Last Name:
Student Number:
This test lasts 75 minutes.
Aids allowed: handwritten notes on both sides of one 8.5 11 inch page.
Make sure your test has 6 pages, including this cover page.
Answer

York University
EECS 3101
September 10, 2015
Homework Assignment #1
Due: September 17, 2015 at 4:00 p.m.
1. Let n 1. Suppose we have a collection of N = 2n computers. They are connected into a
hypercube network as follows. Each computer is labelled by a b

York University
EECS 3101
September 17, 2015
Homework Assignment #2
Due: September 24, 2015 at 4:00 p.m.
1. In this question we will consider functions f : IR IR. A value x IR is called a fixed
point of f if f (x) = x. A function f is called strictly decr

York University
EECS 3101
September 24, 2015
Homework Assignment #3
Due: October 1, 2015 at 4:00 p.m.
1. Bob Fnord is the mayor of a large city that is building a subway, which will be n metres
long. One day, he was looking at the subway plans in his offi

York University
EECS 3101
September 30, 2015
Homework Assignment #4
Due: October 8, 2015 at 4:00 p.m.
1. Is
log n O(log
n)? Prove your answer is correct.
2. Is n! O(2n )? Prove your answer is correct.
3. Willemina has devised a recursive algorithm. Let T

York University
EECS 3101
October 8, 2015
Solution to Homework Assignment #4
1. Yes. Consider any n e. Then,
functions. So,
log n log e = 1 (since log and are both increasing
p
p
p
log n
log n log n
= log n
1
= 2 log n
2
= 2 log n.
(In the definition of

Agents & Tuples
Gunnar Gotshalks
09-1
What is an Agent
An agent is a function that is passed as a parameter
Agents implement a sub-set of functional programming
Functional programming is dealt with in the course
COSC 3401
Gunnar Gotshalks
09-2
Why ha

Design by Contract
Building Reliable Software
Gunnar Gotshalks
15-1
Assertions & Correct Programs
How to write correct programs and know it
Harlan Mills
Specify clearly, precisely and succinctly
What is expected and guaranteed by each
component class,

CSE 3101 Design and Analysis of Algorithms
Assignment for Unit 1
Unmarked (A subset of the questions in the book)
Jeff Edmonds
Read the book. Learn the steps. Go to class. Ask lots of question. Study the slides. Work hard on solving
these questions on you

Facade Pattern Structural
Intent
Provide common interface to a set of interfaces
within system
Define a higher level interface that makes the
system easier to use for most common tasks
Motivation
Design goal is to minimize communication between
clien

CSE 3101 Design and Analysis of Algorithms
Solutions for Assignment for Unit 2
Unmarked (A subset of the questions in the book)
Jeff Edmonds
Dont cheat by looking at these answers prematurely.
Chapters 8-12: Recursion
1. Exercise 8.5.2:
(a) One might comp