Difference between revisions of "DataStructures"
Jump to navigation
Jump to search
(→Stacks) |
|||
Line 46: | Line 46: | ||
./simple-hash.exe | ./simple-hash.exe | ||
</pre> | </pre> | ||
+ | |||
+ | * Content addressable storage. | ||
+ | * Must manage potential collisions. | ||
[[Image:450pxHashTable.png|300px|thumbnail|none|A hash table mapping names to phone numbers.]] | [[Image:450pxHashTable.png|300px|thumbnail|none|A hash table mapping names to phone numbers.]] |
Revision as of 19:18, 13 April 2010
'Data Structures: starting to designing your program'
Introduction
If your data structures effectively represent your area of modelling interest, the logic and control flow of your code will be naturally constrained and hence simpler and more robust to bugs.
svn co http://soutce.ggy.bris.ac.uk/subversion-open/data-structures/trunk ./data-structures
Stacks
cd examples/example1 make ./simple-stack.exe
- The deliberately constrained nature of the stack gives elements a natural order.
- Elements added early remain in the stack the longest.
Linked Lists
cd ../example2 make ./simple-LL.exe
- Can grow with more data
- Can insert items in the middle of the list (e.g. can store items in order which arrive out of order)
Hash Tables
cd examples/example1 make ./simple-hash.exe
- Content addressable storage.
- Must manage potential collisions.
Trees
Searchtrees
Quadtrees
http://en.wikipedia.org/wiki/Quadtree
A quadtree could be used to store:
- A sparse matrix (Can think of an image this way)
- Variable resolution data (parent's value is the average of its children's values)