Information and Computer Sciences University of Hawaii, Manoa

Slides:



Advertisements
Similar presentations
Data Structures Through C
Advertisements

Stacks, Queues, and Linked Lists
Exam Review 3 Chapters 10 – 13, 15 CSC212 Section FG CS Dept, CCNY.
CS 206 Introduction to Computer Science II 03 / 04 / 2009 Instructor: Michael Eckmann.
Priority Queues. 2 Priority queue A stack is first in, last out A queue is first in, first out A priority queue is least-first-out The “smallest” element.
Lecture 8 CS203. Implementation of Data Structures 2 In the last couple of weeks, we have covered various data structures that are implemented in the.
CS 171: Introduction to Computer Science II
Trees Chapter 8.
ITEC200 – Week08 Trees. 2 Chapter Objectives Students can: Describe the Tree abstract data type and use tree terminology such as.
Fall 2007CS 2251 Trees Chapter 8. Fall 2007CS 2252 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information.
Introduction to Stacks What is a Stack Stack implementation using arrays. Application of Stack.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Unit 11 1 Unit 11: Data Structures H We explore some simple techniques for organizing and managing information H This unit focuses on: Abstract Data Types.
Binary Trees A binary tree is made up of a finite set of nodes that is either empty or consists of a node called the root together with two binary trees,
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
Introduction to Stacks What is a Stack Stack implementation using array. Stack implementation using linked list. Applications of Stack.
CHAPTER 6 Stacks. 2 A stack is a linear collection whose elements are added and removed from one end The last element to be put on the stack is the first.
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
CSE 373 Data Structures and Algorithms Lecture 13: Priority Queues (Heaps)
The Stack and Queue Types Lecture 10 Hartmut Kaiser
Maps A map is an object that maps keys to values Each key can map to at most one value, and a map cannot contain duplicate keys KeyValue Map Examples Dictionaries:
1 MT258 Computer Programming and Problem Solving Unit 9.
Trees. Tree Terminology Chapter 8: Trees 2 A tree consists of a collection of elements or nodes, with each node linked to its successors The node at the.
Exam 1 –Monday June 25 th –open Book / Open Notes –No Electronic Devices (calculators, laptops, etc) –Room Number: W –Time: 5:30pm to 8:00pm.
Implementing Stacks Ellen Walker CPSC 201 Data Structures Hiram College.
CHAPTER 05 Compiled by: Dr. Mohammad Omar Alhawarat Stacks & Queues.
Review 1 Introduction Representation of Linear Array In Memory Operations on linear Arrays Traverse Insert Delete Example.
ISOM MIS 215 Module 3 – Stacks and Queues. ISOM Where are we? 2 Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners.
Lecture Objectives  To learn how to use a tree to represent a hierarchical organization of information  To learn how to use recursion to process trees.
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Spring 2010CS 2251 Trees Chapter 6. Spring 2010CS 2252 Chapter Objectives Learn to use a tree to represent a hierarchical organization of information.
COSC 1030 Lecture 9 Binary Trees. Topics Basic Concept and Terminology Applications of Binary Tree Complete Tree Representation Traversing Binary Trees.
data ordered along paths from root to leaf
Priority Queues Dr. David Matuszek
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
Starting at Binary Trees
Recursive Data Structures and Grammars  Themes  Recursive Description of Data Structures  Grammars and Parsing  Recursive Definitions of Properties.
Information and Computer Sciences University of Hawaii, Manoa
Priority Queue. Priority Queues Queue (FIFO). Priority queue. Deletion from a priority queue is determined by the element priority. Two kinds of priority.
Chapter 12: Collections by Lewis and Loftus (Updated by Dan Fleck) Coming up: Collections.
Java Methods Big-O Analysis of Algorithms Object-Oriented Programming
Data Structures Chapter 6. Data Structure A data structure is a representation of data and the operations allowed on that data. Examples: 1.Array 2.Record.
CSE205 Review Session SAMUEL & JESSA. Recursion WHAT IS RECURSION?  Recursion is a tool a programmer can use to invoke a function call on itself. 
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
Lecture Objectives  To understand how Java implements a stack  To learn how to implement a stack using an underlying array or linked list  Implement.
HEAPS. Review: what are the requirements of the abstract data type: priority queue? Quick removal of item with highest priority (highest or lowest key.
CISC220 Fall 2009 James Atlas Dec 07: Final Exam Review.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
April 27, 2017 COSC Data Structures I Review & Final Exam
Trees Ellen Walker CPSC 201 Data Structures Hiram College.
Course: Programming II - Abstract Data Types HeapsSlide Number 1 The ADT Heap So far we have seen the following sorting types : 1) Linked List sort by.
Click to edit Master text styles Stacks Data Structure.
Final Exam Review COP4530.
Computing with C# and the .NET Framework
Data Structure By Amee Trivedi.
Heaps And Priority Queues
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Stacks.
Week 15 – Monday CS221.
COMPUTER 2430 Object Oriented Programming and Data Structures I
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
CS212: Data Structures and Algorithms
Stacks Chapter 5 Adapted from Pearson Education, Inc.
Final Exam Review COP4530.
Stacks and Queues 1.
Stacks.
Presentation transcript:

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

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

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

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 }

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. }

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

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. }

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

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

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

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

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

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)