Download presentation
Presentation is loading. Please wait.
Published byRosaline Horn Modified over 9 years ago
2
Algorithms and Data Structures TEACH THAT
3
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
4
Algorithms and Data Structures A data structure is some way to represent and store data so that we can process that data efficiently
5
Algorithms and Data Structures Data structures use algorithms Algorithms use data structures
6
Algorithms and Data Structures Data Structures and Algorithms a Computer Scientist’s building blocks
7
Algorithms and Data Structures Computer Scientist invent and study algorithms and data structures and problems
8
Algorithms and Data Structures Computer Scientists do other things too
10
Our website, link from moodle
13
Lecture
14
14 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 Lectures … Aye, right.
15
Algorithms & Data Structures Algorithms & Data Structures Great!
17
Now and then I will take an attendance register
18
Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
19
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
20
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
21
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 Continued
22
Content Continued 5 pieces of practical work 2 of above are assessed (20%) exam in May (80%) lab every 2 nd week woof
23
Algorithms & Data Structures Algorithms & Data Structures Great!
25
our ADS2 website under construction (permanently)
26
Home
27
News
28
The lectures
30
code & api
31
Lots of code in there
32
demos
33
Links to interesting & useful stuff
35
exercises
38
Questions & Answers
39
… and now for something completely different!!!
40
Lassie, why are algorithms and data structures important?
41
Lassie, will there be anything in the course that is challenging and exciting?
42
I just hope I get feedback, continuously
43
Lassie, will you teach us to “THINK LIKE A COMPUTER SCIENTIST”?
44
Lassie, honestly, I’m not that experienced as a programmer. Will you help us with our programming?
46
Will we use BIG data sets?
47
woof!
48
1 st lecture … “Who cares?”
49
algorithms are ancient Many algorithms predate computers
50
But first … what is an algorithm?
51
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]
53
Before some of you were born
54
Abu Jafar Mohammed ibm Musa Al Khwarizmi 800AD Before I was born
55
Euclid of Alexandria 325BC to 265BC GCD
57
Data Structures … what’s that then?
58
ways to organise data/information efficiently where will I (not) see data structures? Data structure Not a Data structure – ADT (see next slide)
59
abstract data types?
60
Definitions contd. Basically an ADT is an “abstract” entity But a data structure has a fixed implementation (as well as “structural” properties). 60ADS2 Lecture 2
61
Who cares? Machines are getting bigger, faster, cheaper … do efficient data structures and algorithms really matter?
63
Bigger, faster, cheaper machines Bigger data sets, greater expectations
64
An Example: from problem to program Sequencing traffic lights A Formal Model
74
A-left A-right
75
A-left A-right B-right B-left B-straight
76
A-left A-right B-right B-left B-straight C-straight
77
ALAL ARAR BRBR BSBS BL CSCS
78
ALAL ARAR BRBR BSBS CSCS Draw a line (edge) between turns that CANNOT occur at the same time Draw a line (edge) between turns that CANNOT occur at the same time
79
ALAL ARAR BRBR BSBS BL CSCS Draw a line (edge) between turns that CANNOT occur at the same time
80
ALAL ARAR BRBR BSBS BL CSCS Draw a line (edge) between turns that CANNOT occur at the same time Draw a line (edge) between turns that CANNOT occur at the same time
81
ALAL ARAR BRBR BSBS BL CSCS Draw a line (edge) between turns that CANNOT occur at the same time
82
ALAL ARAR BRBR BSBS BL CSCS Draw a line (edge) between turns that CANNOT occur at the same time Draw a line (edge) between turns that CANNOT occur at the same time
83
ALAL ARAR BRBR BSBS BL CSCS Draw a line (edge) between turns that CANNOT occur at the same time Draw a line (edge) between turns that CANNOT occur at the same time
84
ALAL ARAR BRBR BSBS BL CSCS Draw a line (edge) between turns that CANNOT occur at the same time Draw a line (edge) between turns that CANNOT occur at the same time
85
ALAL ARAR BRBR BSBS BL CSCS Draw a line (edge) between turns that CANNOT occur at the same time Draw a line (edge) between turns that CANNOT occur at the same time
86
ALAL ARAR BRBR BSBS BL CSCS Label turns that have an edge between them (adjacent) differently. The minimum number of labels used Is the minimum (maximum) number of concurrent turns disallowed (allowed)
87
ALAL ARAR BRBR BSBS BL CSCS Label turns that have an edge between them (adjacent) differently. The minimum number of labels used Is the minimum (maximum) number of concurrent turns disallowed (allowed) For “label” let’s use “colour”
88
ALAL ARAR BRBR BSBS BL CSCS Label turns that have an edge between them (adjacent) differently. The minimum number of labels used Is the minimum (maximum) number of concurrent turns disallowed (allowed) For “label” let’s use “colour”
89
ALAL ARAR BRBR BSBS BL CSCS Label turns that have an edge between them (adjacent) differently. The minimum number of labels used Is the minimum (maximum) number of concurrent turns disallowed (allowed) For “label” let’s use “colour” Label turns that have an edge between them (adjacent) differently. The minimum number of labels used Is the minimum (maximum) number of concurrent turns disallowed (allowed)
90
ALAL ARAR BRBR BSBS BL CSCS Label turns that have an edge between them (adjacent) differently. The minimum number of labels used Is the minimum (maximum) number of concurrent turns disallowed (allowed) For “label” let’s use “colour”
91
ALAL ARAR BRBR BSBS BL CSCS Label turns that have an edge between them (adjacent) differently. The minimum number of labels used Is the minimum (maximum) number of concurrent turns disallowed (allowed) For “label” let’s use “colour”
92
ALAL ARAR BRBR BSBS BL CSCS Label turns that have an edge between them (adjacent) differently. The minimum number of labels used Is the minimum (maximum) number of concurrent turns disallowed (allowed) For “label” let’s use “colour”
93
ALAL ARAR BRBR BSBS BL CSCS Label turns that have an edge between them (adjacent) differently. The minimum number of labels used Is the minimum (maximum) number of concurrent turns disallowed (allowed) For “label” let’s use “colour”
94
ALAL ARAR BRBR BSBS BL CSCS Therefore we could allow same coloured turns to go at the same time: blue, green, pink and it will be collision-free
95
ALAL ARAR BRBR BSBS BL CSCS We have 3 time steps
96
ALAL ARAR BRBR BSBS BL CSCS Could we do it in less than 3 time steps? Is this solution unique? What is the “underlying” problem? What is its complexity? Are there any algorithms that can be used?
97
ALAL ARAR BRBR BSBS BL CSCS Is Dobie’s Loan actually scheduled optimally?
98
ALAL ARAR BRBR BSBS BL CSCS Might this be an obvious solution?
99
B C A E D Try This One way JoJo’s intersection, Princeton
100
B C A E D AB AC AD BA BC BD DA DB DC EA EB EC ED turns
101
B C A E D JoJo’s intersection, Princeton
102
B C A E D JoJo’s intersection, Princeton, USA (allowed a right turn against the lights)
103
B C A E D JoJo’s intersection, Princeton ED EA BC EC EB DC DA BA AD AC DB AB BD
104
B C A E D JoJo’s intersection, Princeton ED EA BC EC EB DC DA BA AD AC DB AB BD JoJo’s intersection, Princeton, USA (allowed a right turn against the lights)
105
B C A E D JoJo’s intersection, Princeton ED EA BC EC EB DC DA BA AD AC DB AB BD
106
B C A E D JoJo’s intersection, Princeton ED EA BC EC EB DC DA BA AD AC DB AB BD 4 colours 4 steps
107
B C A E D JoJo’s intersection, Princeton ED EA BC EC EB DC DA BA AD AC DB AB BD 4 colours 4 steps 4-clique!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.