Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Data Structure Bestiary

Similar presentations


Presentation on theme: "A Data Structure Bestiary"— Presentation transcript:

1 A Data Structure Bestiary
Views from around the web

2 Arrays

3 Strings

4 Tuples

5 Singly-linked lists

6 Simple list implementation
Sample methods: Test if list is empty Look at the value in a node Go to the next node (if any) Add a new node to the beginning Remove a node from the beginning class Node<V> { V value; Node next; // constructor… // methods… } class List { Node<V> head = null; // methods… }

7 Node class Node<V> { private V value; private Node<V> next; Node(V value, Node next) { this.value = value; this.next = next; } V value() { return value; } boolean hasNext() { return next != null; } Node next() { return next; } }

8 List public class List<V> { private Node<V> head = null; boolean isEmpty() { return head == null; } Node<V> first() { return head; } void add(V val) { head = new Node<V>(val, head); } void remove() throws NullPointerException { head = head.next; } } Not the best implementation. Instead of exposing Node, Node could be an inner class, and List could implement Iterable.

9 Doubly-linked lists

10 Stacks

11 Queues

12 Priority queues

13 Deques

14 Maps

15 Sets

16 Hash tables (buckets)

17 Hash maps (buckets)

18 Hash maps (open addressing)

19 Binary trees

20 Search trees, a.k.a. sorted binary trees

21 Heaps

22 The other kind of heap next = 0 size = 2 size = 6 ////////////
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 free

23 Trees

24 Parse trees

25 Tries

26 Diected graphs (Digraphs)

27 Undirected graphs

28 Data structures as tools
A more complete toolset Arrays (or lists) alone

29 The End


Download ppt "A Data Structure Bestiary"

Similar presentations


Ads by Google