0% found this document useful (0 votes)
43 views

Intro

1. Procedural programming uses functions/procedures that are ordered and called sequentially. 2. Functions communicate by passing parameters and returning values. 3. The main() function forms the top-level sequence that calls other functions.

Uploaded by

Minh Toàn Lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Intro

1. Procedural programming uses functions/procedures that are ordered and called sequentially. 2. Functions communicate by passing parameters and returning values. 3. The main() function forms the top-level sequence that calls other functions.

Uploaded by

Minh Toàn Lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 19

COMP2012H

Object-Oriented Programming and


Data Structures

Fall 2017
Slide 2

Lectures
 Instructor: Long QUAN
 Lectures:
 Tuesday & Thursday 11h30am – 1h20pm , room 2404
 Web site:
 (https://course.cse.ust.hk/comp2012h)
 http://www.cse.ust.hk/~quan/comp2012h/index.html
 Lecture notes
 Assignments, test cases and solutions
 Download course material before class
 Labs
Slide 3

Textbook
 Main book:
 ADTs, Data Structures, and Problem Solving with
C++, Prentice Hall, Larry Nyhoff
 My reference book:
 The C++ Porgramming language, Addison Wesley,
Stroustrup --- creator of C++
Slide 4

Grading Scheme
 Grading is based on
 3 Programming Assignments (8+9+8%=25%)
 11 Lab exercises (10%), 1% each, and the best 10
 Midterm Examination (25%)
 Final Examination (40%)
The final has to be consistent with the overall score
If you perform well in the final, you may not fail the
course
If you perform poorly in the final, you may not get an A
Slide 5

Plagiarism Policy
 1st Time: both get 0
 2nd Time: both get 0 + one full downgrade
 3rd Time: FAIL
 Midterm or Final: an automatic FAIL

You are encouraged to collaborate in study groups.


But, you cannot copy or slightly change other students’
solutions or codes.

The detection of plagiarism is computerized!


Slide 6

Course Overview
 A fundamental computer science course
- Essential for programming
- Essential for advanced courses
 A challenging course, which needs
- Mathematical and logic thinking
- Programming
Slide 7

Course Prerequisite
 COMP104
 Need to know C and C++
 PC programming environment
 Good programming skills
 Translate pseudo-codes into codes
 Speedy review in the 1st week
 Basic mathematical skills
 Solving recursive equations, manipulation of symbols, etc.
 Computer architecture
 Pointers, storage, memory access, etc.
Slide 8

Course Outline
 C++ review (1 week)
 Recursions and algo analysis (1 week)
 Sorting (1 week)
 Lists (1 week)
 OOP1: concept and classes (2 weeks)
 Data structures: stacks, and queues (1 weeks)

Midterm

 Generic programming and STL (1 weeks)


 OOP2: inheritance, polymorphism and virtual functions (2 weeks)
 Data structure 2: binary trees (2 weeks)
 Hashing (1 week)

8
Slide 9

Overall Goal of the Course


 From programmer to architect
 Learn to solve problems
 Algorithms and Programming go hand in hand
 Learn to analyze your solutions
Slide 10

Lecture Format
 Lectures:
 Slides are available before class
 Print
in ‘graylevel’ as ‘handouts’!!!
 Constantly updated, only minorly!!!
 It is important to attend the lectures (because not all material and
concepts are covered in slides)
 If you miss any lectures, learn from your friends
 Labs
 Compulsary!
 Weekly programming practice

 Programming assignments
 More rigorous problems to consolidate your knowledge
 Manipulation of polynomials
 Linked list data structure
 Class-based implementation
 STL and advanced functions
 Bonus? Anything beyond the three assignments
Slide 11

Assignments
 Programming assignments
 Due by time specified
 Run on PC
 Submit it using CASS
 Re-grade policy will be announced
 Late policy : allows only one day late for at most
one assignment, 2 days late is not accepted
Slide 12

Midterm and Final Examinations


 (Check the schedule with all students!)
 Midterm: TBA
 Final: TBA
 Closed-book, closed-notes
 No make-ups will be given
 Unless under very unusual circumstances, with
letters of proof
 Instructor informed beforehand
Slide 13

Programming and languages


 Visual Basic
 not much structured

 C, Fortran, Pascal,

 Lisp, scheme, …
 Python
 interpreted, high-level, efficiency
 structural, object-oriented
 functional in Lisp tradition, dynamic typing and binding, garbage collection

 (JavaScript)
 Interpreted, high-level, dynamic, weakly typed, object-based, multi-paradigm

 Java
 C++
 …
Slide 14

Where are we, and where to go?


1004 2012
Procedural programming,
(152)
Or structured programming,
OOP (104, 151) (171)
Or imperative programming (104), modularity

Simple types of variables Static objects Data structure:


(member) variables Linear: list, stack, queue
(variables=objects) Array, struct Dynamic objects class objects Nonlinear: tree, graph
pointer

operation
3 program structures Functions on objects (member) functions Algorithms
(assignment,
conditional,
iteration)
C, Pascal C++, Java

Data, variable, object Algorithms+Data Structures = Programs


Operation, function, procedure, subprogram, module, method Niklaus Wirth
Slide 15

Programming paradigms
 Procedural programming

 Functional programming

 Object-oriented programming
Slide 16

Procedural programming
 An (ordered) sequence of ‘procedures’ or
‘functions’ or meta-instructions

 Three instructions
 Assignment
 Conditional
 iteration
Slide 17
procedural programming:

main(), is the first function, and is composed of a sequence of ‘procedures’


(or ‘functions’ in C++).
Functions communicate by passing parameters.
int main()
{
A a;
int main() B b;
{ C c;
int x,y,z;
int a,b,c; a.f1();
b.f2();
c.f3();

a=f1(x); }
b=f2(y);
c=f3(z); Class A
… {
Int x;
Int f1();
}
}

int f1() Class B


{ {
} Int y;
Int f2()
int f2() }
{
Class C
} {
Int z;
int f3() Int f3();
{ }
}

Object oriented programming: a sequence of ‘objects’!


Objects communicate by sending messages.
Slide 18

Math and CS
 From ‘calculus’, get ‘programming fundamentals’
 Sequence, dynamic procedure
 Euclid  a process or an algorithm  iteration
 Approximation of a real  iteratively
 ‘bracket’ the solution of a polynomial  iteration
 Recurrent sequence u_{n+1} = f(u_n)  ‘recursion’
 Recurrent sequentce is ‘more expressive’, but no ‘close-form’ solution
 ‘convergence’ for math  ‘termination’ of a recursive procedure or a loop
 Fixed-point theorem  important for ‘recursion’ to finish
 Invariance  proof of correctness of a ‘loop’
 From ‘algebra’, get ‘object-oriented programming’
 ‘algebra’ comes later than ‘calculus’
 About ‘categorization’
 Look for ‘general rules’ for the same objects
 Group, ring, and fields: set of elements and operators
 element sets  class
 operators  operators
Slide 19

Key concepts in procedural


programming
 Parameters passing
 Scope of variables
 Recursions

 Algorithm analysis
 Sorting algorithms

You might also like