Ds Introduction
Ds Introduction
Ds Introduction
Introduction
Digital Data
•
Music Photos
Movies
Protein
Shapes
DNA
•gatcttttta tttaaacgat ctctttatta gatctcttat taggatcatg atcctctgtg
gataagtgat tattcacatg gcagatcata taattaagga ggatcgtttg ttgtgagtga
ccggtgatcg tattgcgtat aagctgggat ctaaatggca tgttatgcac agtcactcgg Maps
cagaatcaag gttgttatgt ggatatctac tggttttacc ctgcttttaa gcatagttat
acacattcgt tcgcgcgatc tttgagctaa ttagagtaaa ttaatccaat ctttgaccca
•0010101001010101010100100100101010000010010010100....
ASCII table:
agreement for
RAM = Symbols + Pointers the meaning
of bits
(for our purposes)
•16-bit words
0 0100101001111011
2 01101110 10 100000
4 00 10000 100 1000 11
Arranged
- Stored in an orderly way in memory / disk
Processed
Algorithms: shortest path, minimum cut, FFT, ...
Data Structures -> Data Structuring
How do we organize information so that we can find, update, add, and
delete portions of it efficiently?
Data Structure Example Applications
Political revolution?
•- Insert, delete, rename cities
•Data Organizing Principles
Ordering :
Put keys into some order so that we know something about where each key
•is are relative to the other keys.
Phone books are easier to search because they are alphabetized.
Linking :
Add pointers to each record so that we can find related records quickly.
E.g. The index in the back of book provides links from words to the pages
•on which they appear.
Partitioning :
Divide the records into 2 or more groups, each group sharing a particular
•property.
E.g. Multi-volume encyclopedias (Aa-Be, W-Z)
E.g. Folders on your hard drive
Ordering
Pheasant, 10 Albatross, 0
Grouse, 89 Bluejay, 24
Quail, 55 Cardinal, 102
Pelican, 3 Chicken, 7
Partridge, 32 Duck, 18 Search for
Duck, 18 Eagle, 43
Woodpecker, 50 Egret, 88 “Goose”
Robin, 89 Finch, 38
Cardinal, 102 Binary Search
Goose, 67
Eagle, 43 Grouse, 89 O(log n)
Chicken, 7 Heron, 70 (1)
Pigeon, 201 Loon, 213
Swan, 57 Partridge, 32
Loon, 213 Pelican, 3
Turkey, 99 Every step discards
Pheasant, 10
Albatross, 0 Pigeon, 201 half the remaining
Ptarmigan, 22 Ptarmigan, 22 entries:
Finch, 38 Quail, 55
Bluejay, 24 Robin, 89 n/2k = 1
Heron, 70 Swan, 57
Egret, 88 2k = n
Turkey, 99
Goose, 67 Woodpecker, 50 •k = log n
Linking
97
43
2 24
78
Insertion & deletion easy if you have a pointer to the middle of the list
Find 18
31
19 58
16 35 98
9 18