Lec 09 Agenda 1/ Searching and sorting, logs

Slides:



Advertisements
Similar presentations
Transparency No. 1 Java Collection API : Built-in Data Structures for Java.
Advertisements

Chapter 10: Data Structures II
Introduction to Computer Science Theory
CompSci Searching & Sorting. CompSci Searching & Sorting The Plan  Searching  Sorting  Java Context.
© 2004 Goodrich, Tamassia Sorting Lower Bound1. © 2004 Goodrich, Tamassia Sorting Lower Bound2 Comparison-Based Sorting (§ 10.3) Many sorting algorithms.
Review. What to know You are responsible for all material covered in lecture, the readings, or the programming assignments There will also be some questions.
Wednesday, 11/25/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 11/25/02  QUESTIONS??  Today:  More on sorting. Advanced sorting algorithms.  Complexity:
Wednesday, 11/13/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 11/13/02  QUESTIONS??  Today:  More on searching a list; binary search  Sorting a list;
Chapter 19 Java Data Structures
Java Collections. Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms.
CHAPTER 09 Compiled by: Dr. Mohammad Omar Alhawarat Sorting & Searching.
Big Java Chapter 16.
111 © 2002, Cisco Systems, Inc. All rights reserved.
CSS446 Spring 2014 Nan Wang.  Java Collection Framework ◦ Set ◦ Map 2.
CS 46B: Introduction to Data Structures July 9 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
Data structures and algorithms in the collection framework 1.
CSE 12 – Basic Data Structures Cynthia Bailey Lee Some slides and figures adapted from Paul Kube’s CSE 12 CS2 in Java Peer Instruction Materials by Cynthia.
Chapter 12 Binary Search and QuickSort Fundamentals of Java.
CS223 Advanced Data Structures and Algorithms 1 Review for Midterm Neil Tang 03/06/2008.
© 2006 Pearson Education Chapter 10: Non-linear Data Structures Presentation slides for Java Software Solutions for AP* Computer Science A 2nd Edition.
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
Data Structures for Midterm 2. C++ Data Structure Runtimes.
Collections Mrs. C. Furman April 21, Collection Classes ArrayList and LinkedList implements List HashSet implements Set TreeSet implements SortedSet.
ISOM MIS 215 Module 5 – Binary Trees. ISOM Where are we? 2 Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners.
Concurrency (Threads) Threads allow you to do tasks in parallel. In an unthreaded program, you code is executed procedurally from start to finish. In a.
Collections ABCD ABCD Head Node Tail Node array doubly linked list Traditional Arrays and linked list: Below is memory representation of traditional.
Sorting and "Big Oh" ASFA AP Computer Science A SortingBigOh.
Recursion Topic 5.
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
CSE 214 – Computer Science II Maps
Fundamentals of Programming II Overview of Collections
Searching – Linear and Binary Searches
Chapter 19 Java Data Structures
Wednesday Notecards. Wednesday Notecards Wednesday Notecards.
Efficiency of in Binary Trees
University of Central Florida COP 3330 Object Oriented Programming
CS 2511 Fall 2014 Binary Heaps.
Heapsort.
Data Structures and Database Applications Abstract Data Types
Chapter 10: Non-linear Data Structures
Review for Midterm Neil Tang 03/04/2010
CS302 Data Structures Fall 2012.
Road Map CS Concepts Data Structures Java Language Java Collections
Road Map CS Concepts Data Structures Java Language Java Collections
structures and their relationships." - Linus Torvalds
Road Map - Quarter CS Concepts Data Structures Java Language
Building Java Programs
structures and their relationships." - Linus Torvalds
Complexity Present sorting methods. Binary search. Other measures.
searching Concept: Linear search Binary search
8/04/2009 Many thanks to David Sun for some of the included slides!
14.1 The java.util Package.
Sorting.
Welcome to CSE 143! Go to pollev.com/cse143.
Sub-Quadratic Sorting Algorithms
Building Java Programs
CS202 - Fundamental Structures of Computer Science II
CSE 1020: The Collection Framework
Road Map CS Concepts Data Structures Java Language Java Collections
1.4 ทบทวน JAVA OO Programming Concepts Declaring and Creating Objects
Heapsort.
Searching/Sorting/Searching
Trees in java.util A set is an object that stores unique elements
Chapter 12 Heap ADT © 2011 Pearson Addison-Wesley. All rights reserved.
CS 240 – Advanced Programming Concepts
Tables and Priority Queues
structures and their relationships." - Linus Torvalds
Introduction to Java Collection
Presentation transcript:

Lec 09 Agenda 1/ Searching and sorting, logs (2:12) https://www.youtube.com/watch?v=1BIke9mprDw 2/Data structures Build an LinkedList. From this basic strcture, we can build most of the datastuctures we want. Except for binary trees. 3/ Game features. MovableAdapter,

Get source code labJava >git fetch origin lab09g >git checkout -b lab09g origin/lab09g

Arrays versus Collections Holds objects of known type. Fixed size. Collections Generalization of the array concept. Set of interfaces defined in Java for storing Objects. Multiple types of objects. Resizable.

Using Interfaces with Collections Interfaces are used for flexibility reasons Programs that use an interface are not coupled to a specific implementation of a collection. It is easy to change or replace the underlying collection class with another class that implements the same interface. Map map = new HashMap(); Map map = new TreeMap();

Searching Linear search O(n) --slow Binary search O(log2n) --fast Refresher on logs: If 23 = 8 then log28 = 3 Hashed search O(1) –fastest Search driver class (2:12) https://www.youtube.com/watch?v=1BIke9mprDw 5

6

Sorting SelectionSort O(n2) –-slow MergeSort O(n * log2n) –- fast HeapSort O(n * log2n) –- fast QuickSort O(n * log2n) –- fast 7

Applications of logs If you're playing in single-elimination (sudden- death) tournament with 16 players in your draw, how many matches would you need to win in order to win the tournament? Log216 You're searching a sorted set of 64 elements, what is the maximum number of times you would need to search this set? Log264 8

Applications of logs The radioactive half-life of Carbon-14 is 5730 years. You find a fossil whose Carbon-14 signature has a radioactive strength of 1/128 of the original strength. How old is this fossil? 9

Intro to Data Structures in Java Single Lined List Stack Binary Tree others...

http://people. cs. aau. dk/~torp/Teaching/E01/Oop/handouts/collections http://people.cs.aau.dk/~torp/Teaching/E01/Oop/handouts/collections.pdf 11

Iterator http://people.cs.aau.dk/~torp/Teaching/E01/Oop/handouts/collections.pdf 14