COMP2521 ♢ Week 01a ♢ Course Introduction ♢ (20T3)
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [0/34]
♢
Lecturer-in-charge: Dr Ashesh Mahidadia ♦ Email: ashesh@cse.unsw.edu.au
♢
Course Admin Email: cs2521@unsw.edu.au
♢ Primary entry point is WebCMS,
Course Website is:
https://webcms3.cse.unsw.edu.au/COMP2521/20T1/
♢
Login to WebCMS using your zID and your zPass, and is needed for
- course material (lecture slides, tutorials, labs, assignments, etc.)
- polls
- comments/forums
- forming groups
- etc. ...
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [1/34]
COMP1511 ...
- gets you thinking like a programmer
- solving problems by developing programs
- expressing your ideas in the C language
COMP2521 ...
- gets you thinking like a computer scientist
- knowing fundamental techniques/structures
- able to reason about applicability/effectiveness
- able to analyse behaviour/correctness of programs
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [2/34]
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [3/34]
❖ ... COMP1511 vs COMP2521 | |
COMP2521 ...
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [4/34]
❖ Thinking like a Scientist | |
observe → hypothesize → experiment → analyse → repeat
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [5/34]
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [6/34]
♢ At the start of this course you should be able to:
- produce a correct C program from a specification
- understand the state-based model of computation
(variables, assignment, addresses, parameters, scope)
- use fundamental C data structures
(char
, int
, float
, arrays, structs, pointers, linked lists)
- use fundamental control structures (
if
, while
)
- implement abstraction via function declarations, ADTs
- fix simple bugs in incorrect programs
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [7/34]
❖ Revision (material from COMP1511) | |
♢
Important: Make sure you can properly understand and effectively use the following topics (covered in COMP1511):
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [8/34]
♢ At the end of this course you should be able to:
- analyse performance characteristics of algorithms
- measure performance behaviour of programs
- choose/develop effective data structures (DS)
- choose/develop algorithms (A) on these DS
- package a set of DS+A as an abstract data type
- develop and maintain 9999-line C programs
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [9/34]
❖ Data Structure Viewpoint | |
COMP1511 considered ...
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [10/34]
❖ ... Data Structure Viewpoint | |
COMP2521 also considers ...
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [11/34]
♢ Major themes ...
- Analysis: correctness, performance, usability
- ADTs: sets, lists, trees, graphs, dictionaries
- Operations: building, sorting, searching, traversing
♢ For data types: alternative implementation of operations
♢
For algorithms: complexity analysis, performance analysis
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [12/34]
♢ Always give credit if you use someone else's work.
♢
COMP2521 material is prepared by John Shepherd, and ideas are drawn from
- notes by Aleks Ignjatovic (COMP2011 2005)
- slides by Manuel Chakravarty (COMP1927 08s1)
- lectures by Richard Buckland (COMP1927 09s2)
- slides by Gabrielle Keller (COMP1927 12s2)
- slides by Michael Thielscher (COMP9024 17s2)
- slides and books by Robert Sedgewick
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [13/34]
♢ Textbook is a "double-header"
- Algorithms in C, Parts 1-4, Robert Sedgewick
- Algorithms in C, Part 5, Robert Sedgewick
Good books, useful beyond COMP2521, but code style .....
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [14/34]
♢ Four scheduled hours of lectures.
♢ Lectures will contain ...
- summary of content (read textbook and lecture notes in advance),
- problem-solving exercises, hopefully, with lots of input from you.
♢ But without any "background noise" :-)
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [15/34]
♢ Tutorials ...
- as in COMP1511
- analysis/design practice; clarify lecture material
♢ Labs ...
- small(ish) implementation tasks, done in pairs
- give skills practice (leading on to assignments/exam)
♢ Tutes/labs will run from week 01 to 10.
♢ Exercises for Week X available in Week X-1
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [16/34]
♢ Lab exercises contribute 11% to overall mark.
♢ The lab exercises for Week X must be
- submitted before Sunday at end of week X
- demonstrated to tutor during Week X lab
OR, demonstrated at the start of Week X+1 lab
♢
Total mark for all the labs is greater than 11 (and they are scaled to 11).
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [17/34]
♢ Two assignments ...
- Ass1: 15% towards final mark, (available in week-03, due Mon week-07)
- Ass2: 20% towards final mark, (available in week-07, due in week-10)
♢ Two assignments contribute 35% towards final mark.
♢
Late penalties apply if you miss the deadline.
♢
Good time management avoids late penalties!
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [18/34]
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [19/34]
♢ 3-hour on-line exam during the exam period.
♢
How to pass? Practice, practice, practice, ...
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [20/34]
♢
The document "Essential Advice for CSE Students"
states the supplementary assessment policy for the School of CSE.
Please take the time to read it carefully.
♢
If you are granted a Supplementary examination,
then it will be centrally timetabled.
If you think that you may be eligible for a supplementary exam,
then make sure you are available on that day.
It is your responsibility to check at
the Student Office for details of Supplementary examinations.
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [21/34]
quizzes = mark for quizzes (out of 14)
labs = mark for lab exercises (out of 11)
ass1 = mark for assignment 1 (out of 15)
ass2 = mark for assignment 2 (out of 20)
finalExam = mark for final exam (out of 40)
okHurdle = finalExam > 20 (that is, > 50% in the final exam)
mark = quizzes + labs + ass1 + ass2 + finalExam
grade = HD|DN|CR|PS if mark >= 50 && okHurdle
= FL if mark < 50
= UF if mark >= 50 && !okHurdle
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [22/34]
♢ The goal is for you to become a better programmer
- more confident in your own ability
- with an expanded set of tools to draw on
- able to analyse/justify your choices
- producing a better end-product
- ultimately, enjoying the programming process
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [23/34]
❖ C vs COMP1511 vs COMP2521 | |
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [24/34]
♢ Required use of a restricted subset of C:
- layout, use of brackets (always)
- use only
if
and while
- no side-effects in expressions
- no conditional expressions
- all functions have one return statement
♢ But ... this style used in no texts or real code.
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [25/34]
♢ Extends the range of allowed constructs:
- layout: consistent indentation still required
- use of brackets:
- can omit if control structure owns a single statement
- put function start bracket on line after function header
- can use all C control structures
-
if
, switch
, while
, for
, break
, continue
- put function start bracket on line after function header
♢ But wait! There's more ...
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [26/34]
♢ More allowed C constructs ...
- can use assignment statements in expressions
- but you should continue to avoid other kinds of side-effects
- can use conditional expressions
- but use
x = c ? e1 : e2
with care
- functions may have multiple
return
statements
- use very sparingly, primarily for error handling
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [27/34]
♢
Good: gives you more freedom and power
- more choice in how you express programs
- can write code which is more concise (simpler)
♢
Bad: gives you more freedom and power
- can write code which is more cryptic
- can lead to incomprehensible, unmaintainable code
♢ So, you must still use some discipline.
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [28/34]
♢ switch
encapsulates a common selection:
if (v == C1) {
S1;
} else if (v == C2) {
S2;
}
...
else if (v == Cn) {
Sn;
}
else {
Sn+1;
}
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [29/34]
♢ Multi-way if
becomes:
switch (v) {
case C1:
S1; break;
case C2:
S2; break;
...
case Cn:
Sn; break;
default:
Sn+1;
}
♢ Note: break
is critical; if not present, falls through to next case.
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [30/34]
❖ Exercise : Displaying Months | |
♢ Write a function monthName(int)
that
- accepts a month number 1=Jan ... 12=Dec
- returns a string containing the month name
- assume that the string will be read-only
- use a
switch
to decide on the month
♢ Suggest an alternative approach using an array.
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [31/34]
♢ for
encapsulates a common loop pattern:
init;
while (cont) {
do something;
incr;
}
as
for (init; cont; incr)
do something;
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [32/34]
♢ COMP1511 (while
) version
sum = 0;
i = 1;
while (i < 10) {
sum = sum + i;
i++;
}
♢ COMP2521 (for
) version
sum = 0;
for (i = 0; i < 10; i++)
sum += i;
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [33/34]
❖ Exercise : Sequence program, using for | |
Write a program that prints integer sequences (one per line):
-
seqq 10
prints 1 2 3 4 5 6 7 8 9 10
-
seqq 5 10
prints 5 6 7 8 9 10
-
seqq 10 1
prints 10 9 8 7 6 5 4 3 2 1
-
seqq 1 3 10
prints 1 4 7 10
-
seqq 1 3 11
prints 1 4 7 10
-
seqq -3
prints 1 0 -1 -2 -3
-
seqq 1 -3 10
gives an error
♢ Package the core part as a function:
void seq(int start, int step, int finish) {...}
main
checks errors and sets up args for seq()
COMP2521 (20T3) ♢ Week 01a ♢ Course Intro ♢ [34/34]
Produced: 13 Sep 2020