CS Y1 - 4 - Algorithmics Links (Point to where you are going)
Singly Linked
- 'head' is just a place in memory, that points to starting element (a copy of reference to the 1st node) - 'tail' can point to the back of queue
Linked Lists
- Consists of element, and next object - Built from Nodes - Easier to resize, and add nodes onto - Not so useful on their own (used in skip lists & hash tables)
Arrays disadvantages
- Fixed Length: o The only way to enlarge is double the size of the array (variable - length array!) o inefficient and not exact? - Insert/delete from middle has a theta(n) on average run time
Linked List - when?
- For efficient insert and delete - Line editors Store each line as a seperate string Easy to insert and delete new lines - lists - variable length arrays are usually better - queues - linked list ok, but circular arrays are probably better - sorted lists - binary trees much better
Variable-length Array
- Most 'add(elem)' operations are theta(1) time - Adding to a full array is slow but amortised by subsequent quick adds (i.e. on average) o when we are at full capacity we have to copy all elements - ArrayList is an example
Non-contiguous data structures
- Non-contiguous (or Linked) data structures are composed as distinct chunks of memory linked together by pointers (references) - Some of the data strucutres are lists, tress, and graph adjacency lists - Uses data units that points to other data units such as: Binary trees Graphs LinkedLists
Arrays advantages
- access time of theta(1) - Efficient use of memory - Usually best performance
Singly Linked interface
- get_head() - get() - remove()
Skip Lists
- hierarchies of linked lists to support binary search - less elements at higher level - provide Θ(log (n)) search compared with Θ(n) for LinkedList - also efficient concurrent access
Single slabs of memory
Contiguous data structures
Singly Linked - when?
For use with stacks - Remove by linking past it - Add into anywhere by changing nexts
Arrays, matrices, heaps and hash tables
types of contiguous data structures