Download Introduction (ADS, who cares?)

Document related concepts
no text concepts found
Transcript
Algorithms and Data Structures
Algorithms and Data Structures
An algorithm does something, solves some problem, in a mechanical way.
It is a bit like a “machine” or a specialised tool
Algorithms and Data Structures
A data structure is some way to represent and store data
so that we can process that data efficiently
Algorithms and Data Structures
Data structures use algorithms
Algorithms use data structures
Algorithms and Data Structures
Data Structures and Algorithms
a
Computer Scientist’s building blocks
Algorithms and Data Structures
Computer Scientist invent and study
algorithms and data structures and problems
Algorithms and Data Structures
Computer Scientists do other things too 
Our website, link from moodle
Lecture
Lectures … Aye, right.
Why don’t I just go away and read
the book myself?
Why come to lectures?
• meet new exciting people
• keep in touch with fashion, trends, …
• be part of the “in” crowd
•
ADS2 Lecture 1
12
Great!
Now and then I will take an attendance register
Lassie, what’s in this ADS2 course ? Will it be interesting?
woof!
Content
• linked lists
• single/doubly-linked,
• insert, delete, find, min, max, …
• stacks
• push/pop/size
• bracket matching, RP calculator
• queues
• enqueue/dequeue/size
• circular queue (in array)
• recursion
• see above
• big O 
Continued
Content
• trees
• n-ary trees: representations & properties
• binary trees
• representations & properties & traversals
• binary search trees
• insert/find/delete/traverse/height …
• AVL trees
• heap
• insert/delete/sort
• splay trees (maybe)
• red-black trees (maybe)
Continued
Content
• skip lists (maybe)
• Sorting
• bubble/insert/sift sort
• merge sort
• quick sort
• bucket sort (pigeon hole sort)
• bead sort (maybe)
• Dictionaries
• maps and hash tables
• open and closed hashing
Content
• 5 pieces of practical work
• 2 of above are assessed (20%)
• exam in May (80%)
• lab every 2nd week
• woof
Continued
Great!
our ADS2 website
under construction
(permanently)
Home
News
The lectures
The lectures
code & api
Lots of code in there
demos
Links to interesting & useful stuff
Links to interesting & useful stuff
exercises
Questions & Answers
… and now for something completely different!!!
Lassie, why are algorithms and data
structures important?
Lassie, will there be anything in the
course that is challenging and exciting?
I just hope I get feedback, continuously
Lassie, will you teach us to “THINK LIKE A COMPUTER SCIENTIST”?
Lassie, honestly, I’m not that experienced as a programmer.
Will you help us with our programming?
Will we use BIG data sets?
woof!
1st lecture … “Who cares?”
algorithms are ancient
Many algorithms predate computers
But first … what is an algorithm?
What is an algorithm?
A finite sequence of instructions, each with a
clear meaning, and can be performed with a
finite amount of effort in a finite length of time
[Aho, Hopcroft, Ullman 1983]
Before some of you were born
Abu Jafar Mohammed ibm Musa Al Khwarizmi
Before I was born
800AD
325BC to 265BC
GCD
Euclid of Alexandria
Data Structures … what’s that then?
Data
structure
Not a Data structure
– ADT (see next
slide)
Data
structure
Data
structure
ways to organise data/information efficiently
where will I (not) see data structures?
abstract data types?
Definitions contd.
• Basically an ADT is an “abstract” entity
• But a data structure has a fixed implementation (as well as
“structural” properties).
ADS2 Lecture 2
55
Who cares?
Machines are getting
bigger, faster, cheaper …
do efficient data
structures and algorithms
really matter?
Bigger, faster, cheaper machines
Bigger data sets, greater expectations
What data structures might we use and what algorithms?
An example …
• You have a file of names of people
• We don’t know how many people
• Read them in to memory and allow
• Find
• Add
• delete
ADS2 Lecture 1
59
What data structures might we use and what algorithms?
A quick look at fBook
We have a file of people members.txt and a file of friends with entries
that are pairs of names of people who are friends. We want to be able
to find people, find out who is friends with whom … basically, a toy facebook
ADS2 Lecture 1
60
What have we learned?
•
•
•
•
What data structures might we use and what algorithms?
Refreshed our knowledge of ArrayList
Consequences of add and remove
How to compile and run on the command line
What args means
ADS2 Lecture 1
61
ADS2 Lecture 1
62
ADS2 Lecture 1
63
Person
ADS2 Lecture 1
64
Person
ADS2 Lecture 1
65
Person
ADS2 Lecture 1
66
I dream of
ArrayLists
So, ArrayList created with space
for 10 objects!
That’s enormous 
And when I add an object into a
given position it shuffle things up.
Is that for free? Does that take
any time?
And what happens when I want to put in
an 11th object into my ArrayList?
Back to Person
ADS2 Lecture 1
78
Person
constructor
ADS2 Lecture 1
79
Person
utilities
ADS2 Lecture 1
80
Person
For printing
ADS2 Lecture 1
81
FBook
ADS2 Lecture 1
82
FBook
ADS2 Lecture 1
83
FBook
ADS2 Lecture 1
84
FBook
Given a name as a String create a
person with that name and make
them a member of FBook
ADS2 Lecture 1
85
FBook
Opening a file, reading it,
creating persons and adding
them as members
ADS2 Lecture 1
86
Find a person with a given name … 1st algorithm
ADS2 Lecture 1
FBook
87
Find a person with a given name … 1st algorithm
FBook
But how did we need to structure the data so that we can use that algorithm
ADS2 Lecture 1
88
Find a person with a given name … 1st algorithm
FBook
But how did we need to structure the data so that we can use that algorithm
How efficient is that algorithm, and what could we have used instead?
ADS2 Lecture 1
89
FBook
ADS2 Lecture 1
90
Test
ADS2 Lecture 1
91
ADS2 Lecture 1
92
Test
What are args[]?
ADS2 Lecture 1
93
Test
HCI Fail?
ADS2 Lecture 1
94
I want to keep it simple
ADS2 Lecture 1
95
So, let’s compile and run it …
ADS2 Lecture 1
97
So, what have we learned …
•
•
•
•
•
•
•
The need for dynamic data structures
Refreshed our knowledge of ArrayList
Consequences of add and remove in ArrayList
Algorithms & data structures go hand in hand
How to compile and run on the command line
What args means
Keeping it simple …
ADS2 Lecture 1
98