Presentation is loading. Please wait.

Presentation is loading. Please wait.

Algorithms and Data Structures

Similar presentations


Presentation on theme: "Algorithms and Data Structures"— Presentation transcript:

1

2 Algorithms and Data Structures

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 

9

10 Our website, link from moodle

11 Lecture

12 Why don’t I just go away and read the book myself?
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

13 Great! Algorithms & Data Structures Algorithms & Data Structures

14

15 Lassie, what’s in this ADS2 course ? Will it be interesting?
woof!

16 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 

17 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)

18 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

19 Continued Content 5 pieces of practical work 2 of above are assessed (20%) exam in May (80%) lab every week woof

20 Great! Algorithms & Data Structures Algorithms & Data Structures

21

22 our ADS2 website under construction (permanently)

23 Home

24 News

25 The lectures

26 The lectures

27 code & api

28 Lots of code in there

29 demos

30 Links to interesting & useful stuff

31 Links to interesting & useful stuff

32 exercises

33 Questions & Answers

34 … and now for something completely different!!!

35 Lassie, why are algorithms and data structures important?

36 Lassie, will there be anything in the course that is challenging and exciting?

37 I just hope I get feedback, continuously

38 Lassie, will you teach us to “THINK LIKE A COMPUTER SCIENTIST”?

39 Lassie, honestly, I’m not that experienced as a programmer
Lassie, honestly, I’m not that experienced as a programmer. Will you help us with our programming?

40

41 Will we use BIG data sets?

42 woof!

43 1st lecture … “Who cares?”

44 algorithms are ancient
Many algorithms predate computers

45 But first … what is an algorithm?

46 A finite sequence of instructions, each with a
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]

47

48 Before some of you were born

49 Prim’s Algorithm ADS2 Lecture 1

50 Abu Jafar Mohammed ibm Musa Al Khwarizmi
Before I was born 800AD

51 325BC to 265BC GCD Euclid of Alexandria

52

53 Euclid’s algorithm ADS2 Lecture 1

54 Euclid’s algorithm ADS2 Lecture 1

55 Code is not an algorithm … maybe a realisation of an algorithm
Euclid’s algorithm Code is not an algorithm … maybe a realisation of an algorithm ADS2 Lecture 1

56 Algorithms you might know/use
Addition/subtraction Long division/multiplication Tying your shoe laces Changing a tyre on your bike Baking a cake Opening a bottle of beer ADS2 Lecture 1

57 Algorithms you might know/use
Addition/subtraction Long division/multiplication Tying your shoe laces Changing a tyre on your bike Baking a cake Opening a bottle of beer 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] ADS2 Lecture 1

58 Addition/subtraction Long division/multiplication
Tying your shoe laces Changing a tyre on your bike Baking a cake Opening a bottle of beer Algorithms you might know/use 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] It terminates It produces correct result It has a “complexity” (measure of performance) All steps can be performed without “magic” ADS2 Lecture 1

59 Things I do not consider to be algorithms
Algorithmic trading Rules to decide if you get a loan or a job or … ADS2 Lecture 1

60 Things I do not consider to be algorithms
ADS2 Lecture 1

61 Data Structures … what’s that then?
ADS2 Lecture 1

62 Data Structures … what’s that then?

63 ways to organise data/information efficiently
Not a Data structure – ADT (see next slide) Data structure Data structure Data structure ways to organise data/information efficiently where will I (not) see data structures?

64 abstract data types?

65 Definitions contd. Basically an ADT is an “abstract” entity
Set, Queue, Priority Queue, Stack, … But a data structure has a fixed implementation (as well as “structural” properties). ADS2 Lecture 2 65

66 Who cares? Machines are getting bigger, faster, cheaper … do efficient data structures and algorithms really matter?

67

68 Bigger, faster, cheaper machines
Bigger data sets, greater expectations

69 You have a file of names of people We don’t know how many people
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

70 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

71 Refreshed our knowledge of ArrayList Consequences of add and remove
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

72 ADS2 Lecture 1

73 ADS2 Lecture 1

74 Person ADS2 Lecture 1

75 Person ADS2 Lecture 1

76 Person ADS2 Lecture 1

77 I dream of ArrayLists

78

79

80

81

82

83

84

85 So, ArrayList created with space for 10 objects!
That’s enormous 

86 And when I add an object into a given position it shuffle things up
And when I add an object into a given position it shuffle things up. Is that for free? Does that take any time?

87 And what happens when I want to put in an 11th object into my ArrayList?

88 Back to Person ADS2 Lecture 1

89 Person constructor ADS2 Lecture 1

90 Person utilities ADS2 Lecture 1

91 Person For printing ADS2 Lecture 1

92 FBook ADS2 Lecture 1

93 FBook ADS2 Lecture 1

94 FBook ADS2 Lecture 1

95 FBook Given a name as a String create a person with that name and make
them a member of FBook ADS2 Lecture 1

96 FBook Opening a file, reading it, creating persons and adding
them as members ADS2 Lecture 1

97 Find a person with a given name … 1st algorithm FBook
ADS2 Lecture 1

98 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

99 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

100 FBook ADS2 Lecture 1

101 Test ADS2 Lecture 1

102 ADS2 Lecture 1

103 Test What are args[]? ADS2 Lecture 1

104 Test HCI Fail? ADS2 Lecture 1

105 I want to keep it simple ADS2 Lecture 1

106

107 So, let’s compile and run it …
ADS2 Lecture 1

108 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

109


Download ppt "Algorithms and Data Structures"

Similar presentations


Ads by Google