Dueling Algorithm. Data Structures List of potential candidates R = rightmost element of that list N = new element RN.

Slides:



Advertisements
Similar presentations
4.4 Page replacement algorithms
Advertisements

Advanced Sorting Methods: Shellsort Shellsort is an extension of insertion sort, which gains speed by allowing exchanges of elements that are far apart.
Suzuki Kasami Example. Consider 5 Sites S1 S2 S4 S3 S5 n=1 n=2 n=5 n=4 n=
COMPILERS Register Allocation hussein suleman uct csc305w 2004.
Algorithm & Flow Charts Decision Making and Looping Presented By Manesh T Course:1090 CS.
What else can we do with heaps? Use the heap for sorting. Heapsort!
Bucket Sort and Radix Sort CS /02/05 BucketSort Slide 2 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights.
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
DICTIONARIES. The Compound Sequence Data Types All of the compound data types we have studies in detail so far – strings – lists – Tuples They are sequence.
Heapsort.
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
CSI 101 Elements of Computing Spring 2009 Lecture # 8 Looping and Recursion Wednesday, February 25 th, 2009.
Pipelined Computations Divide a problem into a series of tasks A processor completes a task sequentially and pipes the results to the next processor Pipelining.
CHAPTER 2 ANALYSIS OF ALGORITHMS Part 2. 2 Running time of Basic operations Basic operations do not depend on the size of input, their running time is.
Graphs & Recursion Chapter 2 Highlights. Graphs Used to model relationships Includes –Set of vertices (nodes) –Set of edges that connect the nodes Example.
Dave Risch. Project Specifications There is a “knapsack” that you want to fill with the most valuable items that are available to you. Each item has a.
1 Algorithm…. 2 Algorithm: Is a planned set of steps to solve certain problem Ex.: Assume for instance that the gross pay of an employee is to be calculated.
PLANNING Partial order regression planning Temporal representation 1 Deductive planning in Logic Temporal representation 2.
Heapsort Based off slides by: David Matuszek
Data Structures - CSCI 102 Binary Tree In binary trees, each Node can point to two other Nodes and looks something like this: template class BTNode { public:
BSTImp: Insert, Delete. Inserting an Element into a BST Search for the position in the tree where the element would be found Insert the element in the.
Iteration: WHILE Loop Damian Gordon. WHILE Loop Consider the problem of searching for an entry in a phone book with only SELECTION:
1 Array / Array Operations. 2 Single variables Read the rainfall for the 12 month in a year: Read n 1 Read n 2 … Read n 12 n1n1 n2n2 n 12.
Standard Algorithms –search for an item in an array –count items in an array –find the largest (or smallest) item in an array.
Programming Training Main Points: - Problems with repetitions. - Discuss some important algorithms.
Binary Search Trees Binary Search Trees (BST)  the tree from the previous slide is a special kind of binary tree called a binary.
CS-2852 Data Structures Week 10, Class 1 Lab 8 notes Big-O revisited CS-2852 Dr. Josiah Yoder Slide style: Dr. Hornick 1.
Bucket Sort and Radix Sort
Foundations of Data Structures Practical Session #8 Heaps.
Final Code Generation and Code Optimization.
Lists of Dictionaries Combining Data Storage Types.
Concepts of Algorithms CSC-244 Unit 19 & 20 Binary Search Tree (BST) Shahid Iqbal Lone Computer College Qassim University K.S.A.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 11.
pictures_slideshow/article.htm.
Blocks World Problem. The CS Terminal Specifies the block at the top of the stack. Example CS evaluates to E Note: Evaluates to nil if the stack is empty.
Stacks. What is a Stack? A stack is a type of data structure (a way of organizing and sorting data so that it can be used efficiently). To be specific,
EE459 I ntroduction to Artificial I ntelligence Genetic Algorithms Practical Issues: Representations.
Program Program is a collection of instructions that will perform some task.
Algorithm & Flow Charts Decision Making and Looping
Chapter 6 (Lafore’s Book) Recursion Hwajung Lee.  Definition: An algorithmic technique. To solve a problem on an instance of size n, the instance is:
Exam practice. Exam 1  Describe how a Boolean expression can control the operation of a loop  Describe the difference between a while loop and for loop.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Objectives Upon completion you will be able to: Explain the design, use, and operation of a linear.
Презентацию подготовила Хайруллина Ч.А. Муслюмовская гимназия Подготовка к части С ЕГЭ.
Flood fill algorithm Also called seed fill, is an algorithm that determines the area connected to a given node in a multi-dimensional array, When applied.
Aaron Bloomfield CS 202 Rosen, section 7.4
Arrays.
The time complexity for e-closure(T).
Review: NFA Definition NFA is non-deterministic in what sense?
LinkedIntList(int n) Write a constructor for LinkedIntList that accepts an int n parameter and makes a list of the number from 0 to n new LinkedIntList(3)
Control Structure Senior Lecturer
Advanced Sorting Methods: Shellsort
Flooding © 2018.
ArrayLists.
Five Sections Usage idea: Change colors and font to fit the style you want for your presentation. Section Three Section One Section Five Section Four.
Programming Training Main Points: - Problems with repetitions.
EMIS 8374 Shortest Path Problems: Introduction Updated 9 February 2008
2-Dimensional Pattern Matching
Some Common Issues: Iteration
Bubble Sort Key Revision Points.
A Hash Table with Chaining
Final Code Generation and Code Optimization
Binary Search Trees Chapter 9 2/24/2019 B.Ramamurthy.
LinkedIntList(int n) Write a constructor for LinkedIntList that accepts an int n parameter and makes a list of the number from 0 to n new LinkedIntList(3)
Graphs and Vertex Coloring
Compiler Construction
Bingo Example: Design (Random Distinct Numbers Algorithm)
Problem solving.
Closures of Relations Epp, section 10.1,10.2 CS 202.
Advanced Sorting Methods: Shellsort
What about −(−6) ? What quantity is in the box?.
Presentation transcript:

Dueling Algorithm

Data Structures List of potential candidates R = rightmost element of that list N = new element RN

Initialization Add 1 to list R  1 N  2 RN

Main Loop While n-N ≥ m-1 (new candidate fits) do: If N-R ≥ m (candidates are far) then: add N to list R  N N  N+1 goto endWhile

Candidates are far RN

Main Loop (Candidates are within mutual range) Duel R and N Cases: N dies R dies * (both live) endWhile

Case 1: N dies If N dies then: N  N+1 goto endWhile

Case 1: N dies RN X N

Case 2: R dies If R dies then: Remove R from list. If list empty then: R  N N  N+1 Goto endWhile else: R points to previous element in list Goto endWhile

Case 2: R dies RN X

Case 3: * (no one dies) If * then: add N to list R  N N  N+1 Goto endWhile

Case 3: * (no one dies) RN

At end of Algorithm: All elements in list are potential candidates. All elements in list agree with each other.