Algorithms and Data Structures Algorithms and Data Structures
- Slides: 109
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 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 • ADS 2 Lecture 1 12
Great! Algorit hms & tructur es Data S D ithms Algor & ures truct S a t a
Lassie, what’s in this ADS 2 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 week • woof Continued
Great! Algorit hms & tructur es Data S D ithms Algor & ures truct S a t a
our ADS 2 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!
1 st 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
Prim’s Algorithm ADS 2 Lecture 1 49
Abu Jafar Mohammed ibm Musa Al Khwarizmi Before I was born 800 AD
325 BC to 265 BC GCD Euclid of Alexandria
Euclid’s algorithm ADS 2 Lecture 1 53
Euclid’s algorithm ADS 2 Lecture 1 54
Euclid’s algorithm n o i t ot n s it r lgo hm … ma a e yb a s i al e r o g l na m h t ri a f o a n a Co i e d ADS 2 Lecture 1 55
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 … ADS 2 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 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] ADS 2 Lecture 1 57
• • • 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” ADS 2 Lecture 1 58
Things I do not consider to be algorithms • Algorithmic trading • Rules to decide if you get a loan or a job or … ADS 2 Lecture 1 59
Things I do not consider to be algorithms http: //www. bbc. co. uk/programmes/b 085 wj 18#play ADS 2 Lecture 1 60
Data Structures … what’s that then? ADS 2 Lecture 1 61
Data Structures … what’s that then?
Data structure Not a Data structure – ADT (see next slide) 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 – Set, Queue, Priority Queue, Stack, … • But a data structure has a fixed implementation (as well as “structural” properties). ADS 2 Lecture 2 65
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 ADS 2 Lecture 1 69
What data structures might we use and what algorithms? A quick look at f. Book 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 ADS 2 Lecture 1 70
What have we learned? • • What data structures might we use and what algorithms? Refreshed our knowledge of Array. List Consequences of add and remove How to compile and run on the command line What args means ADS 2 Lecture 1 71
ADS 2 Lecture 1 72
ADS 2 Lecture 1 73
Person ADS 2 Lecture 1 74
Person ADS 2 Lecture 1 75
Person ADS 2 Lecture 1 76
I dream of Array. Lists
So, Array. List 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 11 th object into my Array. List?
Back to Person ADS 2 Lecture 1 88
Person constructor ADS 2 Lecture 1 89
Person utilities ADS 2 Lecture 1 90
Person For printing ADS 2 Lecture 1 91
FBook ADS 2 Lecture 1 92
FBook ADS 2 Lecture 1 93
FBook ADS 2 Lecture 1 94
FBook Given a name as a String create a person with that name and make them a member of FBook ADS 2 Lecture 1 95
FBook Opening a file, reading it, creating persons and adding them as members ADS 2 Lecture 1 96
Find a person with a given name … 1 st algorithm ADS 2 Lecture 1 FBook 97
Find a person with a given name … 1 st algorithm FBook But how did we need to structure the data so that we can use that algorithm ADS 2 Lecture 1 98
Find a person with a given name … 1 st 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? ADS 2 Lecture 1 99
FBook ADS 2 Lecture 1 100
Test ADS 2 Lecture 1 101
ADS 2 Lecture 1 102
Test What are args[]? ADS 2 Lecture 1 103
Test HCI Fail? ADS 2 Lecture 1 104
I want to keep it simple ADS 2 Lecture 1 105
So, let’s compile and run it … ADS 2 Lecture 1 107
So, what have we learned … • • The need for dynamic data structures Refreshed our knowledge of Array. List Consequences of add and remove in Array. List Algorithms & data structures go hand in hand How to compile and run on the command line What args means Keeping it simple … ADS 2 Lecture 1 108
- Ajit diwan iit bombay
- Cos 423
- Data structures and algorithms tutorial
- Information retrieval data structures and algorithms
- Data structures and algorithms bits pilani
- Ajit diwan iit bombay
- Data structures and algorithms
- Data structures and algorithms
- Ian munro waterloo
- Signature file structure in information retrieval system
- Data structures and algorithms
- Algorithms + data structures = programs
- Homologous structure
- Stream data model
- Explain conditional macro expansion with example
- Assembler algorithm and data structures
- Data structures and abstractions with java
- Adts, data structures, and problem solving with c++
- Data structures and algorithm
- Ephemeral data structure
- Computational thinking algorithms and programming
- 1001 design
- Association analysis: basic concepts and algorithms
- Computer arithmetic: algorithms and hardware designs
- Algorithms for select and join operations
- Algorithms and flowcharts
- Undecidable problems and unreasonable time algorithms.
- Cluster analysis: basic concepts and algorithms
- Randomized algorithms and probabilistic analysis
- Design and analysis of algorithms introduction
- Algorithms for query processing and optimization
- Synchronization algorithms and concurrent programming
- Parallel and distributed algorithms
- Lerp
- Cluster analysis basic concepts and algorithms
- Cluster analysis basic concepts and algorithms
- Aries in dbms
- Digital signal processor architecture
- Boris epshtein
- Cluster analysis basic concepts and algorithms
- Binary search in design and analysis of algorithms
- Introduction to the design and analysis of algorithms
- Undecidable problems and unreasonable time algorithms
- Design and analysis of algorithms
- Design and analysis of algorithms
- Cluster analysis basic concepts and algorithms
- Comp 482
- Btechsmartclass.com
- Data structures in r
- Oblivious data structures
- Linux kernel data structures
- Introduction to data structures
- Introduction to data structures
- Esoteric data structures
- Geometric data structures
- Hadoop i/o
- Advanced data structures in java
- Classic data structures by debasis samanta ppt
- Persistent vs ephemeral data structures
- Php data structures
- Gis data structure types
- Dynamic data structure in java
- Recurrence data structures
- Structures in c ppt
- Data structures for parallel computing
- Data structures for language processing
- Cos 423
- Smart union algorithm in data structure
- Stacks in data structures
- Fundamentals of data structures in c
- Data structures in prolog
- Data structure primitive and non primitive
- Polynomial representation using linked list in c
- Dynamic data structures
- Hybrid data structures
- Graphical user interface in data structures
- Singly linked list in data structure
- Data structures chapter 1
- Graphics data structures
- Infinite data structures
- Data structures in java
- Data structures in java
- Data structures using java
- Data structures using java
- Advanced data structures in python
- Relational data structure
- Explain classification of data structure with proper figure
- Fundamentals of python data structures
- Elementary data structures
- Perl scalar
- Stack is a static data structure
- Data structures
- Data structures revision
- Elementary data structures
- Data structures
- Types of algorithm
- Common recursive algorithms
- Handling patients
- Recursive algorithms
- Types of randomized algorithms
- Process mining algorithms
- Evolutionary algorithms ppt
- Nature-inspired learning algorithms
- Tabu search tsp
- Making good encryption algorithms
- An introduction to the analysis of algorithms
- Statistical algorithms
- Disadvantages of greedy algorithm
- N/a greedy
- Global state in distributed system