Presentation is loading. Please wait.

Presentation is loading. Please wait.

Information and Computer Sciences University of Hawaii, Manoa

Similar presentations


Presentation on theme: "Information and Computer Sciences University of Hawaii, Manoa"— Presentation transcript:

1 Information and Computer Sciences University of Hawaii, Manoa
Course Review ICS 211 Cam Moore Information and Computer Sciences University of Hawaii, Manoa

2 Java Concepts Objects vs. Primitives References Equality Comparison
Generic Types Collections iterators

3 Data Structures Arrays Fixed size
System.arrayCopy(src, srcPos, dest, destPos, length) Constant time access Can have empty space

4 Data Structures Lists Variable size Linked and Array Implementations
Performance /** An ordered collection. The user can access elements by their * integer index, and search for elements in the list. */ public interface List<E> extends Collection<E> { E get(int index); // returns object at given position E set(int index, E element); // sets element, returns old value int indexOf(Object o); // returns index of object in list E remove(int index); // removes object at the given position int size(); // returns number of elements in list boolean add(E element); // add element at the end of the list void add(int index, E element); // add element at given position }

5 Data Structures Stacks Linked vs Array Implementation Performance Uses
/** A Stack represents a Last-In-First-Out (LIFO) stack of objects. */ public interface Stack<E> { boolean empty(); // returns true if the stack is empty E peek(); // looks at the top item of the stack w/o removing it. E pop(); // removes the top item in the stack, returning it. E push(E element); // pushes an item onto the top of the stack. }

6 Pre, In, Post fix Notation
Prefix Notation Operator, Operand1, Operand2 No operator precedence Infix Notation Operand1, Operator, Operand2 Has operator precedence and parentheses Postfix Notation Operand1, Operand2, Operator

7 Data Structures Queues Add to the rear, remove from the front
Array vs Linked implementation Performance Uses /**A collection designed for holding elements prior to processing. */ public interface Queue<E> extends Collection<E> { public boolean add(E e); // Inserts element to end of queue, throws exception public boolean offer(E e); // Inserts element to end of queue public E element(); // Retrieves, but doesn’t remove, the head of the queue public E peek(); // Retrieves, but doesn’t remove, the head or null public E poll(); // Retrieves and removes the head or null if queue is empty public E remove(); // Retrieves and removes the head of the queue public int size(); // Returns the number of elements in the queue. }

8 Data Structures Trees Terminology:
root, child, siblings, parent, height/depth, branch, leaf Binary Trees Full, Perfect, Complete Traversals: pre order, in order, post order Binary Search Trees Huffman Trees

9 Data Structures Heaps Helper data structure
Parents are > or < children Implemented in complete binary tree left child = 2 * p + 1, right child = 2 * p + 2 parent = (c – 1) / 2 Add, reheap Remove root, swap rightmost child, reheap

10 Data Structures Hash tables Goal constant time access to keyed value
Calculate index given key Open Addressing vs chaining

11 Recursion Problem solving technique if can solve problem
else solve simpler problem and combine Data structure definition Linked lists, trees Java Activation Stack

12 Sorting Algorithms Quadratic Implementation using an array Selection
Best O(n2), Ave O(n2), Worst O(n2) Bubble Best O(n), Ave O(n2), Worst O(n2) Insertion

13 Sorting Algorithms n log n Merge Recursive, split then merge
O(n log n), O(n log n), O(n log n) Heap Insert to heap then remove Quick Recursive, Pick pivot then swap O(n log n), O(n log n), O(n2)


Download ppt "Information and Computer Sciences University of Hawaii, Manoa"

Similar presentations


Ads by Google