Week 01


COMP2521 17s2 ... Computing 21/36

LiC:   Ashesh Mahidadia,  

ashesh@cse.unsw.edu.au

Web:   http://webcms3.cse.unsw.edu.au/COMP2521/17s2/


Course Goals2/36

COMP1511 ...

COMP2521 ...


COMP1511 vs COMP25213/36

COMP1511 ...

[Diagram:Pics/misc/jumping-small.jpg]


... COMP1511 vs COMP25214/36

COMP2521 ...
 

[Diagram:Pics/misc/military-small.jpg]


Thinking like a Scientist5/36

[Diagram:Pics/misc/mad-sci1-small.png]

observe → hypothesize → experiment → analyse → repeat


Course Context6/36


Pre-conditions7/36

At the start of this course you should be able to:


Post-conditions8/36

At the end of this course you should be able to:


Data Structure Viewpoint9/36

COMP1511 considered ...

[Diagram:Pics/intro/structures0-small.png]


... Data Structure Viewpoint10/36

COMP2521 also considers ...

[Diagram:Pics/intro/structures-small.png]


COMP2521 Themes11/36

Major themes ...

  1. Analysis: correctness, performance, usability
  2. ADTs: sets, lists, trees, graphs, dictionaries
  3. Operations: building, sorting, searching, traversing
For data types: alternative implementation of operations

For algorithms: complexity analysis, performance analysis


COMP2521 on the Web12/36

Primary entry point is WebCMS

   http://webcms3.cse.unsw.edu.au/COMP2521/17s2/


... COMP2521 on the Web13/36

Most material on WebCMS is publically readable.

Login to WebCMS is via zID/zPass, and is needed for


Submit work via give   (either in WebCMS or on cmd line)

Check marks via sturec   (either in WebCMS or on cmd line)


Credits for Material14/36

Always give credit if you use someone else's work.

COMP2521 material is prepared by John Shepherd, and ideas are drawn from


Textbook15/36

Textbook is a "double-header"

       

Good books, useful beyond COMP2521, but code style .....


Lectures16/36

Three scheduled hours: Tuesday 10-11am, Wednesday 10-12noon

Lectures will contain ...

Late penalties apply if you miss the deadline.

Good time management avoids late penalties!


Plagiarism21/36

[Diagram:Pics/misc/noose1-small.jpg]

Just Don't Do it


Final Exam22/36

3-hour on-line torture exam during the exam period.

Held in CSE labs   (must know lab environment)

On-line documentation available in exam:

Format:

How to pass?   Practice, practice, practice, ...


Supplementary Exams23/36

Supplementary Exams are only available to students who

We may also offer Supplementary Prac Exams to students who


Course Assessment24/36

labs                = mark for lab exercises         (out of  5)
ass1                = mark for assignment 1          (out of  9)
ass2                = mark for assignment 2          (out of 14)
practicalLabExams   = mark for practicalLabExams     (out of 12)
finalExam           = finalPracExam (36) + finalTheoryExam (24)          (out of 60)

mark      = labs + assignmentMarks + practicalLabExams + finalExam
grade     = HD|DN|CR|PS  if mark >= 50 && okALL
          = FL           if mark <  50 
          = UF           if mark >= 50 && !okALL


okALL is calculated as below: okPracticalLabExams = (practicalLabExams >= 8/12) okFinalPracExam = (finalPracExam > 18/36 ) okALL = okPracticalLabExams && okFinalPracExam
assignmentMarks is calculated as below: assignmentMarks = ass1 + ass2 assPerc = assignmentMarks in percentages (out of 100) pracExamPerc = finalPracExam in percentages (out of 100) if( assPerc > pracExamPerc ) { // harmonic mean of assPerc and pracExamPerc adjusted_assPerc = (2 * assPerc * pracExamPerc) / (assPerc + pracExamPerc) assignmentMarks = 23 * (adjusted_assPerc / 100) }

In other words, if you don't learn how to program by doing the prac work yourself, you'll score poorly in the finalPracExam, resulting in reduced assignment marks and making it very difficult for you to pass the course.

For more clarification on adjusted_assPerc (or why you should do the prac work yourself!), see the following table:

.


Summary25/36

The goal is for you to become a better programmer


C vs COMP1511 vs COMP2521


COMP1511 Style27/36

Required use of a restricted subset of C:

But ... this style used in no texts or real code.


COMP2521 Style28/36

Extends the range of allowed constructs:

But wait! There's more ...


... COMP2521 Style29/36

More allowed C constructs ...


... COMP2521 Style30/36

Good: gives you more freedom and power

Bad: gives you more freedom and power

So, you must still use some discipline.


Switch-statements31/36

switch encapsulates a common selection:

if (v == C1) {
   S1;
} else if (v == C2) {
   S2;
}
...
else if (v == Cn) {
   Sn;
}
else {
   Sn+1;
}


... Switch-statements32/36

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.


Exercise 1: Displaying Months33/36

Write a function monthName(int) that

Suggest an alternative approach using an array.


For-loops34/36

for encapsulates a common loop pattern:

init;
while (cont) {
   do something;
   incr;
}

as

for (init; cont; incr)
   do something;


... For-loops35/36

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;


Exercise 2: Sequence program, using for36/36

Write a program that prints integer sequences (one per line):

Package the core part as a function:

void seq(int start, int step, int finish) {...}

main checks errors and sets up args for seq()


Produced: 24 Jul 2017