Centroids part 2 Getting rid of outliers and sorting.

Slides:



Advertisements
Similar presentations
Algorithms Analysis Lecture 6 Quicksort. Quick Sort Divide and Conquer.
Advertisements

Practice Quiz Question
Sorting CMSC 201. Sorting In computer science, there is often more than one way to do something. Sorting is a good example of this!
Sorting Algorithms Bryce Boe 2012/08/13 CS32, Summer 2012 B.
Quick Sort, Shell Sort, Counting Sort, Radix Sort AND Bucket Sort
CPS120: Introduction to Computer Science Searching and Sorting.
CS 206 Introduction to Computer Science II 04 / 28 / 2009 Instructor: Michael Eckmann.
Data Structures Data Structures Topic #13. Today’s Agenda Sorting Algorithms: Recursive –mergesort –quicksort As we learn about each sorting algorithm,
1 Sorting Problem: Given a sequence of elements, find a permutation such that the resulting sequence is sorted in some order. We have already seen: –Insertion.
Sorting Chapter 9.
Sorting Algorithms What is it: An algorithm that puts the elements of a list in a certain order.
SORTING. Selection Sort (Basic) 1. Find the smallest element 2. Move to the front of the array (swap with front) 3. Repeat Steps 1&2, but ignore the sorted.
Algorithm An algorithm is a step-by-step set of operations to be performed. Real-life example: a recipe Computer science example: determining the mode.
CS 206 Introduction to Computer Science II 12 / 09 / 2009 Instructor: Michael Eckmann.
Algorithmic Complexity Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
1 Merge and Quick Sort Quick Sort Reading p
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 10/23/2009.
CHAPTER 11 Sorting.
CS 280 Data Structures Professor John Peterson. Project Questions? /CIS280/f07/project5http://wiki.western.edu/mcis/index.php.
CS 206 Introduction to Computer Science II 12 / 08 / 2008 Instructor: Michael Eckmann.
© 2006 Pearson Addison-Wesley. All rights reserved10 A-1 Chapter 10 Algorithm Efficiency and Sorting.
Recursion, Complexity, and Searching and Sorting By Andrew Zeng.
Recursion, Complexity, and Sorting By Andrew Zeng.
Searching and Sorting Gary Wong.
Computer Science Searching & Sorting.
Merge Sort. What Is Sorting? To arrange a collection of items in some specified order. Numerical order Lexicographical order Input: sequence of numbers.
Chapter 10 B Algorithm Efficiency and Sorting. © 2004 Pearson Addison-Wesley. All rights reserved 9 A-2 Sorting Algorithms and Their Efficiency Sorting.
CS 61B Data Structures and Programming Methodology July 28, 2008 David Sun.
© 2006 Pearson Addison-Wesley. All rights reserved10 A-1 Chapter 10 Algorithm Efficiency and Sorting.
© 2006 Pearson Addison-Wesley. All rights reserved10 B-1 Chapter 10 (continued) Algorithm Efficiency and Sorting.
New Mexico Computer Science For All Sorting Algorithms Maureen Psaila-Dombrowski.
Sorting and Searching. Selection Sort  “Search-and-Swap” algorithm 1) Find the smallest element in the array and exchange it with a[0], the first element.
Review 1 Selection Sort Selection Sort Algorithm Time Complexity Best case Average case Worst case Examples.
Chapter 9 Sorting 1. The efficiency of data handling can often be increased if the data are sorted according to some criteria of order. The first step.
Chapter 9 Sorting. The efficiency of data handling can often be increased if the data are sorted according to some criteria of order. The first step is.
Data Structures - CSCI 102 Selection Sort Keep the list separated into sorted and unsorted sections Start by finding the minimum & put it at the front.
ArrayList is a class that implements the List interface. The List interface is a blueprint for its “implementor” classes. There is another implementor.
CSE 326: Data Structures Lecture 23 Spring Quarter 2001 Sorting, Part 1 David Kaplan
Computer Science 1620 Sorting. cases exist where we would like our data to be in ascending (descending order) binary searching printing purposes selection.
Chapter 4, Part II Sorting Algorithms. 2 Heap Details A heap is a tree structure where for each subtree the value stored at the root is larger than all.
Can you put these children’s TV shows in date order - earliest to latest?
CPS120: Introduction to Computer Science Sorting.
Sorting Lower Bounds n Beating Them. Recap Divide and Conquer –Know how to break a problem into smaller problems, such that –Given a solution to the smaller.
Sorting Algorithms Written by J.J. Shepherd. Sorting Review For each one of these sorting problems we are assuming ascending order so smallest to largest.
CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Design and Analysis of Algorithms.
Data Structures and Algorithms Instructor: Tesfaye Guta [M.Sc.] Haramaya University.
Sorting – Lecture 3 More about Merge Sort, Quick Sort.
CMPT 238 Data Structures More on Sorting: Merge Sort and Quicksort.
Sorting and Runtime Complexity CS255. Sorting Different ways to sort: –Bubble –Exchange –Insertion –Merge –Quick –more…
1 CSE 326: Data Structures Sorting by Comparison Zasha Weinberg in lieu of Steve Wolfman Winter Quarter 2000.
Sort Algorithm.
Sorting.
Searching and Sorting Algorithms
a graphical presentation of the five-number summary of data
CMSC201 Computer Science I for Majors Lecture 23 – Sorting
Algorithm Efficiency and Sorting
Warmup What is an abstract class?
Department of Computer Science
Intro to Computer Science CS1510 Dr. Sarah Diesburg
CSC215 Lecture Algorithms.
IT 4043 Data Structures and Algorithms
Sub-Quadratic Sorting Algorithms
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Algorithm Efficiency and Sorting
Sorting.
Core Assessments Core #1: This Friday (5/4) Core #2: Tuesday, 5/8.
Algorithm Efficiency and Sorting
Algorithm Efficiency and Sorting
Presentation transcript:

Centroids part 2 Getting rid of outliers and sorting

Last time… Bounding Box Centroids Algorithms Big O notation

Are centroids foolproof? What if we have ridiculously large outliers? Consider the following thresholded points in a 400 by 300 image: (0,0),(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1), (2,2),(200,200) Which point doesn’t belong?

Outliers Pieces of data that lie outside the usual distribution of data are considered outliers. What is considered “outside?” Somewhat subjective question. Statisticians often use a 1.5*IQR test – Anything 1.5 * the inter-quartile range below the first or above the third counts.

Outliers in thresholding The outliers in a thresholded image can be thought of as “noise” There are several different ways to get rid of noise, but we will start with the most basic We will modify the centroid algorithm to be more robust

Robust centroid The correction is simple: Instead of calculating the centroid with all of the data points, we will disregard the bottom 5% and the top 5%. How do we go about doing this? The answer lies in sorting

Sorting Sorting algorithms are a basic part of computer science We will focus on comparison sorts: Sorting algorithms that work solely upon comparing two items together and determining whether one is greater to, equal to, or less than the other.

Some examples! Dumb sort Bubble sort Selection sort Merge sort Quick sort

Running time considerations Sorting algorithms are often used to demonstrate the uses of big O notation and running time considerations We will go into a few examples!

Dumb sort! The idea: Create a random permutation of the list of numbers, and check to see if it’s sorted. Repeat until it is!

Bubble sort The idea: Go through the list of numbers, and compare each element to the one above it: If it’s greater, then swap the two. Repeat until sorted!

Selection sort The idea: Go through the list and find the smallest element, then swap it with the first element. Continue with the second smallest, third smallest, etc.

Merge sort The idea: Recursively divide the list into 2 roughly equally sized smaller lists When you get to the bottom, merge the 2 lists together recursively until you get a sorted list

A pretty mergesort picture

Quick sort The idea: Pick a pivot element: Divide the list into elements that are smaller than the pivot, equal to the pivot, and greater than the pivot Recursively sort the smaller and greater lists

A prettier quicksort picture

Back to the robust centroid Once we have a sorted list of x values and y values, we can do one of two things: 1.) Take off the lowest and highest points 2.) Take off the lowest and highest x and y values What’s the difference?