cs paper 1... Flashcards
tree
-form of graph
-connected
-undirected
-has no cycles (no path that returns to start node without traversing an edge twice)
rooted trees
-root node (at the top)
-root connects to 0/1/more child nodes
-nodes at the bottom are leaf nodes
-nodes connected via edges
applications of rooted tree
-storing/ managing file and folder structures
-implementations of A* pathfinding algorithm
Binary tree
- rooted tree with 2 children max.
- binary search tree = can be searched quickly and easily for an item,new items easily added and whole tree can be printed out in sequence
applications of binary tree
-wireless networking/ router tables
-operating system scheduling processes
-cryptography
operations on tree
Hash tables
-immediately find an item in a list without need to compare other item
-programming laguages use it to implement a dictionary
-hashing function used to calculate position of an item in a hash table
-needs to be big enough to store all data items, but made bigger to minimise chance of collisions
properties of a good hashing function
-be calculated quickly
-result in as few collisions as possible
-use as little memory as possible
solving collisions from hashing functions
- OPEN ADDRESSING = repeatedly check next available space in hash table until empty position is found and store there
- to find item, hashing function delivers start position and then linear search finds items
- disadvantage is that it prevents other items from being stored at their correct location in hash table
- disadvantage results in clustering, several positions being filled around common collision values
hashing algorithm trade-off
-efficiency of algoritm and size of hash table
resolving collisions
-use a two-dimensional hash table
-possible for more than 1 item to be placed in same position
-use 2nd table for collisions, can be searched sequentially
-use a linked list, can be searched sequentially
applications of hash tables
operations of hash tables
breadth first
-node-based method of finding shortest path through a graph
-makes use of queue data strcuture- FIFO
-one node selected at a time, visited and maked, then adjacent nodes are visited and stored in a queue