Gunn ProCo Lynbrook 1st, 2nd, 3rd*, 4th. Results! 1st: Johnny, MG, Victor (perfect score) 2nd: Julia, Tony, Jimmy (perfect score) 3rd: Team "Lynbrook.

Slides:



Advertisements
Similar presentations
Merge and Radix Sorts Data Structures Fall, th.
Advertisements

I/O Management and Disk Scheduling
2012 = 2 2 * 503 Might be useful tomorrow. – MG. PotW Solution int dp(int pos, int k) { if (k > lim) return -(1
Garfield AP Computer Science
§3 Shortest Path Algorithms Given a digraph G = ( V, E ), and a cost function c( e ) for e  E( G ). The length of a path P from source to destination.
CSE Lecture 3 – Algorithms I
CS252: Systems Programming Ninghui Li Program Interview Questions.
COL 106 Shweta Agrawal and Amit Kumar
1 Various Methods of Populating Arrays Randomly generated integers.
1 Greedy Algorithms Bioinformatics Algorithms © Jeff Parker, 2009 Why should I care about posterity? What's posterity ever done for me? - Gourcho Marx.
(())()(()) ((())()(())()(()))
Hashing Part One Reaching for the Perfect Search Most of this material stolen from "File Structures" by Folk, Zoellick and Riccardi.
CS113 Introduction to C Instructor: Ioannis A. Vetsikas Lecture 7 : September 8.
Quick Sort, Shell Sort, Counting Sort, Radix Sort AND Bucket Sort
CHAPTER 5 PRIORITY QUEUES (HEAPS) §1 ADT Model Objects: A finite ordered list with zero or more elements. Operations:  PriorityQueue Initialize( int.
Recursion CSC 220: Data Structure Winter Introduction A programming technique in which a function calls itself. One of the most effective techniques.
Updated QuickSort Problem From a given set of n integers, find the missing integer from 0 to n using O(n) queries of type: “what is bit[j]
CMPT 225 Priority Queues and Heaps. Priority Queues Items in a priority queue have a priority The priority is usually numerical value Could be lowest.
Main Index Contents 11 Main Index Contents Tree StructuresTree Structures (3 slides) Tree Structures Tree Node Level and Path Len. Tree Node Level and.
Trees CS-212 Dick Steflik. What is a Tree A tree is a finite set of one or more nodes such that: –There is a specially designated node called the root.
Tirgul 7 Heaps & Priority Queues Reminder Examples Hash Tables Reminder Examples.
Chapter 7Louden, Programming Languages1 Chapter 7 - Control I: Expressions and Statements "Control" is the general study of the semantics of execution.
Optimizing the Placement of Chemical and Biological Agent Sensors Daniel L. Schafer Thomas Jefferson High School for Science and Technology Defense Threat.
§3 Binary Heap 1. Structure Property: 【 Definition 】 A binary tree with n nodes and height h is complete iff its nodes correspond to the nodes numbered.
Simulation II IE 2030 Lecture 18. Outline: Simulation II Advanced simulation demo Review of concepts from Simulation I How to perform a simulation –concepts:
Sorting HKOI Training Team (Advanced)
Analysis of Simulation Results Chapter 25. Overview  Analysis of Simulation Results  Model Verification Techniques  Model Validation Techniques  Transient.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
Lists. Container Classes Many applications in Computer Science require the storage of information for collections of entities e.g. a student registration.
Public void main What do you call something that’s not static?
Comp 335 File Structures Hashing.
ACM today! Nice work to everyone in the qualifiers and evening lab... Today: BS! Next 11/2: guest speaker... On 11/9: final lab session 11/13: regionals.
Curricularizing the ACM... ? Zach Dodds ~ November 13, 2010.
Special Cases of Factoring Chapter 5.5 Perfect Square Trinomials a 2 + 2ab + b 2 (a + b) 2 = a 2 – 2ab + b 2 (a – b) 2 =
COSC2007 Data Structures II Chapter 12 Tables & Priority Queues III.
Break; return; // to school :’(. PotW Solution Problem recap: Write a Befunge program that prints out a Brain**** program that prints out a HQ9+ program.
Stacks and Queues. Announcements USACO Open competition results are out o Congrats to Johnny for scoring 2nd in the US USACO Finalists are also announced.
Java Methods Big-O Analysis of Algorithms Object-Oriented Programming
CS 2133: Data Structures Quicksort. Review: Heaps l A heap is a “complete” binary tree, usually represented as an array:
H ASH TABLES. H ASHING Key indexed arrays had perfect search performance O(1) But required a dense range of index values Otherwise memory is wasted Hashing.
PRIORITY QUEUES AND HEAPS Slides of Ken Birman, Cornell University.
Week 13 - Friday.  What did we talk about last time?  Sorting  Insertion sort  Merge sort  Started quicksort.
Special Cases of Factoring Chapter Check to see if there is a GCF. 2. Write each term as a square. 3. Write those values that are squared as the.
1 Heaps A heap is a binary tree. A heap is best implemented in sequential representation (using an array). Two important uses of heaps are: –(i) efficient.
Chapter 13 Priority Queues. 2 Priority queue A stack is first in, last out A queue is first in, first out A priority queue is least-in-first-out The “smallest”
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part R3. Priority Queues.
HEAPS. Review: what are the requirements of the abstract data type: priority queue? Quick removal of item with highest priority (highest or lowest key.
1D Arrays and Random Numbers Artem A. Lenskiy, PhD May 26, 2014.
Priority Queues, Heaps, and Heapsort CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Introducing Arrays. Too Many Variables?  Remember, a variable is a data structure that can hold a single value at any given time.  What if I want to.
Divide and Conquer Sorting Algorithms COMP s1 Sedgewick Chapters 7 and 8.
Properties: -The value in each node is greater than all values in the node’s subtrees -Complete tree! (fills up from left to right) Max Heap.
Special Cases of Factoring. 1. Check to see if there is a GCF. 2. Write each term as a square. 3. Write those values that are squared as the product of.
Priority Queues, Heaps, and Heapsort CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1 Last modified: 2/22/2016.
Priority Queues, Heaps, and Heapsort CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
CSC317 Selection problem q p r Randomized‐Select(A,p,r,i)
CSE373: Data Structures & Algorithms
Design & Analysis of Algorithm Priority Queue
For each pair of polynomials, find the least common multiple. Example For each pair of polynomials, find the least common multiple.
Priority Queues - Harvey B. Mackay
Compsci 201 Priority Queues & Autocomplete
Programming Abstractions
Priority Queues - Harvey B. Mackay
Chapter 10 1 – Binary Trees Tree Structures (3 slides)
CSE 12 – Basic Data Structures
CSE 373 Data Structures and Algorithms
CSE 373: Data Structures and Algorithms
Priority Queue and Heap
CSE 373: Data Structures and Algorithms
Presentation transcript:

Gunn ProCo Lynbrook 1st, 2nd, 3rd*, 4th

Results! 1st: Johnny, MG, Victor (perfect score) 2nd: Julia, Tony, Jimmy (perfect score) 3rd: Team "Lynbrook High School" (Eugene Chen, Douglas Chen, Andrew He) 4th: Joshua, Dolly, Steven

Lessons learned Making bugs wastes tons of time Pay attention to small details The problem statements might have errors o Life is tough. Deal with it. o No penalty for wrong submissions: just keep trying C++ I/O is annoying Be on Johnny's team

Cow Placement N seats K antisocial cows Each cow picks the largest empty segment to sit in and sits in the middle of the segment o Break ties by choosing the leftmost segment/seat E.g. N = 4 and K = 3 o _ _ _ _ o _ o _ _ o _ o o _ o o o o _ Output is "o o o _"

Cow Placement: Solution Need O(nlogn) time Scanning through the empty segments and selecting the largest one every time is too slow o O(n^2) Instead, use a priority queue that stores empty segments Start by pushing (1, N) into the queue Use a custom comparator to sort by decreasing length, then increasing index

Custom Comparator (Java) public class Seg implements Comparable { int a, b; public int len() { return b - a + 1; } public int compareTo(Seg& oth) { if (len() != oth.len()) return len() > oth.len() ? -1 : 1; if (a != oth.a) return a < oth.a ? -1 : 1; return 0; }

Custom Comparator (C++) typedef pair pii; int len(pii a) { return a.second - a.first + 1; } struct comp { //priority_queue is a max-heap. bool operator()(pii& a, pii& b) { if (len(a) != len(b)) return len(a) > len(b); return a.first < b.first; } };

Disk Placement 5 disks of diameter 100 line segment of length 1000 If the disks are randomly placed along the segment and all intersecting placements are discarded, what positions along the line will have the highest frequency?

Disk Placement: Solution Just because the generated positions are random doesn't mean the frequencies are uniform! Randomize the disks 1,000,000 times and keep track of valid positions o Use a histogram to visualize the densities Or just use logic: o If you fix the leftmost and rightmost disks, then the highest probability of the disks not intersecting is if the leftmost and rightmost disks are at the extremities o Thus, the extremities should have the highest frequencies

Mathematica! Histogram[Reap[Sum[l = RandomInteger[999, 5]; If[Min[Abs[Differences[Sort[l]]]] >= 100, Sow l; 1, 0], {i, 1, }]][[2, 1]], 50, ChartStyle -> {EdgeForm[None]}]

~No PotW~ All problems are available at 1.amazonaws.com/gunn2013/z34pg83ucq/pr XY.pd f Where X = 2, 5, or 9 (point values) and Y = 1, 2, 3, or 4 (problem numbers)