Data Structures and Algorithms Week 1 Lecture
Data Structures and Algorithms Week 1 Lecture
Xianzhi Wang
1/34
What are Data Structures and Algorithms?
2/34
What’s Data Structure?
3/34
What’s Algorithm?
4/34
• Problem := Input + (Expected) Output
• Program := Data Structure + Algorithm
• Evaluation
• Algorithm: validity/correctness, accuracy, efficiency
• Data Structure: usually assessed as a part of algorithm
5/34
But you’ve seen this before!
6/34
Some Adminstrative Matters
7/34
Learning Support Systems
• UTSOnline
• Subject Outline
• Announcements
• My Grades
• Staff Contacts
• Ed
• Lessons: slides, practices
• Discussion: online Q&A
• Sway: quizzes release & submission
• Assessments: assignments release and submission
• Challenges: interesting to try
• Online C++ compiler
8/34
Lecture Recording
9/34
Assessment
• 3 short quizzes
• 10 multiple-choice questions each
• Weeks 3, 6 & 9: Monday (released), Friday (due)
• Weight: 10%
• 2 programming assignments
• Assignment 1: Week 6 (released), Week 8 (due)
• Assignment 2: Week 9 (released), Week 11 (due)
• Weight: 25% + 35%
• 1 open-book exam
• 20 multiple-choice questions
• 4 short-answer questions
• Weight: 30%
10/34
U:PASS
• Get extra help from a student who did well in the subject.
• Places are limited—the people attend, the more slots they
offer.
• Sign up: http://www.tinyurl.com/upass2020
11/34
12/34
Consultation
• Coordinator
• 2:00pm-4:00pm Thursday, starting from Week 2
• FEIT learning precinct (Building 11, Level 5, Room 300)
• Tutors
• See timetable for Cmp1.01 through Cmp.17
• Time and place vary for different activity numbers
• Online
• Ed’s Discussion Board
• I will regularly check questions each week
13/34
Now Some C++
14/34
Why C++ in this Subject
15/34
And now for something complete different.
Today’s topics:
• Strings (briefly)
• Arrays, or “who thought this was a good idea?”
• Pointers
• References vs Pointers
• Dereferencing a pointer
• Classes
• Headers and Source files, or “at least this isn’t as bad as
arrays”
• Lists and Linked Lists! (Yay, an actual data structure)
16/34
Strings in C++
17/34
Strings in C++
18/34
Arrays in C++
19/34
Static and Dynamic Memory Allocation
20/34
C++ vs. C vs. Java
21/34
Arrays in C++
22/34
Pointers!
23/34
Pointers!
24/34
References!
25/34
Back to Arrays
26/34
Classes
Classes in C++ look a lot like Java classes, where all classes
inherit a public parentClass without declaration:
#include <string>
class myClass {
private:
int privateInt;
public:
int getPrivateInt();
void setPrivateInt(int newValue);
string toString();
};
27/34
Classes
28/34
Header Files
29/34
A Data Structure!
30/34
A Data Structure
31/34
The List ADT
32/34
An intList Abstract Class
class intList {
public:
virtual intList(){}; // constructor
virtual ~intList() {}; // destructor
33/34
Now the implementation (of some of it)
34/34