Data Structures Flashcards
(7 cards)
Linked List
consists of nodes where each node contains a data field and a link to the next node in the list
LinkedList list = new LinkedList();
Stack
linear data structure following LIFO order (last in, first out)
Stack stack = new Stack();
Queue
linear data structure following FIFO order (first in, first out)
Queue q = new LinkedList<>();
Priority Queue
every item has priority associated to it
item with greatest priority is dequeued first
PriorityQueue pQueue = new PriorityQueue();
Comparator (Priority Queue)
can change order of priority:
Comparator stringLengthComparator = new Comparator() { @Override public int compare(String s1, String s2) { return s1.length() - s2.length(); } };
pass into priority queue
2D Array
arrays of arrays
int[row][column] x = new int[10][10]
int row = x.length
int column = x[0].length
Hash Map
stores values in key/value pairs
HashMap map = new HashMap<>();