CIT 594 28-Nov-18.

Slides:



Advertisements
Similar presentations
Linked Lists Linear collections.
Advertisements

Collections Chapter Java Collection Frameworks The Java collection framework is a set of utility classes and interfaces. Designed for working with.
12-Apr-15 Analysis of Algorithms. 2 Time and space To analyze an algorithm means: developing a formula for predicting how fast an algorithm is, based.
Introduction to Algorithms Greedy Algorithms
BackTracking Algorithms
Types of Algorithms.
15-May-15 Dynamic Programming. 2 Algorithm types Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
16-May-15 Dynamic Programming. 2 Algorithm types Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Java Collections Framework COMP53 Oct 24, Collections Framework A unified architecture for representing and manipulating collections Allows collections.
1 Greedy Algorithms. 2 2 A short list of categories Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
Analysis of Algorithms. Time and space To analyze an algorithm means: –developing a formula for predicting how fast an algorithm is, based on the size.
Quicksort.
24-Jun-15 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
Collections A First Glimpse. Collections A collection is a structured group of objects –An array is a kind of collection –A Vector is a kind of collection.
12-Jul-15 Lists in Java Part of the Collections Framework.
Searching Chapter Chapter Contents The Problem Searching an Unsorted Array Iterative Sequential Search Recursive Sequential Search Efficiency of.
Backtracking.
The Collections Framework A Brief Introduction. Collections A collection is a structured group of objects –An array is a kind of collection –A Vector.
19-Aug-15 Simple Recursive Algorithms. 2 A short list of categories Algorithm types we will consider include: Simple recursive algorithms Backtracking.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Jan 12, 2012 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
Fundamentals of Algorithms MCS - 2 Lecture # 7
Dr. Naveed Ahmad Assistant Professor Department of Computer Science University of Peshawar.
Hash Tables1   © 2010 Goodrich, Tamassia.
Chapter 18 Java Collections Framework
30 May Stacks (5.1) CSE 2011 Winter Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An.
Types of Algorithms. 2 Algorithm classification Algorithms that use a similar problem-solving approach can be grouped together We’ll talk about a classification.
27-Jan-16 Analysis of Algorithms. 2 Time and space To analyze an algorithm means: developing a formula for predicting how fast an algorithm is, based.
Collections Dwight Deugo Nesa Matic
Why do we study algorithms?. 2 First results are about bats and dolphins.
CSE 1342 Programming Concepts
Greedy Algorithms.
Dynamic Programming 26-Apr-18.
12 Collections Software Solutions Lewis & Loftus java 5TH EDITION
Chapter 5: Control Structures II
Analysis of Algorithms
Efficiency of in Binary Trees
Department of Computer Science
Algorithm Analysis CSE 2011 Winter September 2018.
Types of Algorithms.
Introduction to Collections
Introduction to Collections
DYNAMIC PROGRAMMING.
Introduction to Collections
Introduction to Collections
Collections A First Glimpse.
Types of Algorithms.
ArraySet Methods and ArrayIterator
Advanced Analysis of Algorithms
Graph Searching.
Introduction to Collections
Collections Framework
Dynamic Programming 23-Feb-19.
Analysis of Algorithms
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
Quicksort.
Introduction to Collections
Programming II (CS300) Chapter 02: Using Objects Java ArrayList Class
Data Structures Unsorted Arrays
Types of Algorithms.
Collections A First Glimpse 16-Apr-19.
Introduction to Programming
Hashing in java.util
Analysis of Algorithms
Part of the Collections Framework
Analysis of Algorithms
Quicksort.
CS2005 Week 8 Lectures Maps & Binary Trees.
Presentation transcript:

CIT 594 28-Nov-18

Basic content CIT 594 is a continuation of CIT 591 Java will be used throughout However, CIT 594 is not primarily a course about Java Topics: Data Structures Supplied by Java How to create your own Algorithms A sampling of some better-known algorithms Analysis of algorithms Simple algebra is required

Types of Collection A collection is a structured group of objects Java supplies several types of Collection: Set: cannot contain duplicate elements, order is not important SortedSet: like a Set, but order is important List: may contain duplicate elements, order is important Java also supplies some “collection-like” things: Map: a “dictionary” that associates keys with values, order is not important SortedMap: like a Map, but order is important

The Collections hierarchy

Uniformity through interfaces Much of the elegance of the Collections Framework arises from the intelligent use of interfaces For example, the Collection interface specifies (among many other operations): boolean add(Object o) boolean isEmpty() boolean remove() int size() Object[] toArray() Iterator iterator()

Creating lists in Java 44 97 23 17 myList: class Cell { int value; Cell next; Cell (int v, Cell n) { // constructor value = v; next = n; } } Cell temp = new Cell(17, null); temp = new Cell(23, temp); temp = new Cell(97, temp); Cell myList = new Cell(44, temp);

A short list of categories Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide and conquer algorithms Dynamic programming algorithms Greedy algorithms Branch and bound algorithms Brute force algorithms Randomized algorithms

Example recursive algorithms To count the number of elements in a list: If the list is empty, return zero; otherwise, Step past the first element, and count the remaining elements in the list Add one to the result To test if a value occurs in a list: If the list is empty, return false; otherwise, If the first thing in the list is the given value, return true; otherwise Step past the first element, and test whether the value occurs in the remainder of the list

Example backtracking algorithm To color a map with no more than four colors: color(Country n): If all countries have been colored (n > number of countries) return success; otherwise, For each color c of four colors, If country n is not adjacent to a country that has been colored c Color country n with color c recursively color country n+1 If successful, return success If loop exits, return failure

Example greedy algorithm Suppose you want to count out a certain amount of money, using the fewest possible bills and coins A greedy algorithm would do this would be: At each step, take the largest possible bill or coin that does not overshoot Example: To make $6.39, you can choose: a $5 bill a $1 bill, to make $6 a 25¢ coin, to make $6.25 A 10¢ coin, to make $6.35 four 1¢ coins, to make $6.39 For US money, the greedy algorithm always gives the optimum solution 3

Time and space To analyze an algorithm means: developing a formula for predicting how fast an algorithm is, based on the size of the input (time complexity), and/or developing a formula for predicting how much memory an algorithm requires, based on the size of the input (space complexity) Usually time is our biggest concern Most algorithms require a fixed amount of space

y = x2 + 3x + 5, for x=1..20

The End