Գագաթի որոնում (Peak Finder)

Slides:



Advertisements
Similar presentations
Parallel Fast Fourier Transform Ryan Liu. Introduction The Discrete Fourier Transform could be applied in science and engineering. Examples: ◦ Voice recognition.
Advertisements

CS223 Advanced Data Structures and Algorithms 1 Divide and Conquer Neil Tang 4/15/2010.
Divide and Conquer Chapter 6. Divide and Conquer Paradigm Divide the problem into sub-problems of smaller sizes Conquer by recursively doing the same.
7.Quicksort Hsu, Lih-Hsing. Computer Theory Lab. Chapter 7P Description of quicksort Divide Conquer Combine.
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 10/23/2009.
Lecture 32 CSE 331 Nov 18, HW 8 solutions Friday.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 580 Artificial Intelligence Problem Spaces and Search Fall 2008 Jingsong.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Association Also called “knows a”. A relationship of knowing (e.g. Dog-Collar as opposed to Dog-Tail)
1 A Linear Space Algorithm for Computing Maximal Common Subsequences Author: D.S. Hirschberg Publisher: Communications of the ACM 1975 Presenter: Han-Chen.
Computer Science CS 330: Algorithms Quick Sort Gene Itkis.
CS 117 Section 2 + KNET Computer accounts – ed to KNET students –Change password Homework 1 Lab Tutors –In lab for next 2 weeks –Will help you with.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 5 Instructor: Paul Beame TA: Gidon Shavit.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2005 Design Patterns for Optimization Problems Dynamic Programming.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Composition details Recall, composition involves 3 things: –Declaration of instance variable of.
Computer Math AP Computer Science Computer Programming.
10 Algorithms in 20th Century Science, Vol. 287, No. 5454, p. 799, February 2000 Computing in Science & Engineering, January/February : The Metropolis.
CS 160 Introduction to Computer Science Andrew Scholer
Computer Science and Engineering Parallel and Distributed Processing CSE 8380 February 8, 2005 Session 8.
© What do bioinformaticians do?
MA/CSSE 473 Day 17 Divide-and-conquer Convex Hull Strassen's Algorithm: Matrix Multiplication.
1 Lecture 16: Lists and vectors Binary search, Sorting.
computer
Introduction to algorithm design and recursion CS125 Spring 2007 Arthur Kantor.
Introduction to Algorithms By Mr. Venkatadri. M. Two Phases of Programming A typical programming task can be divided into two phases: Problem solving.
Solving Exponential Equations. Example1. Solve. 3 2x+1 = x+1 = 3 4 2x + 1 = 4 2x = 3 x = 3/2.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Selection Sort Sorts an array by repeatedly finding the smallest.
Lecture 7. Solution by Substitution Method T(n) = 2 T(n/2) + n Substitute n/2 into the main equation 2T(n/2) = 2(2(T(n/4)) + n/2) = 4T(n/4) + n And T(n)
CS 46B: Introduction to Data Structures July 2 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
ICS4U – Introduction Teacher: Mr. Ho Course URL:
Computer Science for Young Minds By: Paul Im. Abstract Limited efforts to educate younger students Goal: to implement computer programming to educate.
Introduction to Complexity Analysis. Computer Science, Silpakorn University 2 Complexity of Algorithm algorithm คือ ขั้นตอนการคำนวณ ที่ถูกนิยามไว้อย่างชัดเจนโดยจะ.
Cluster Analysis Data Mining Experiment Department of Computer Science Shenzhen Graduate School Harbin Institute of Technology.
Merge Sort Presentation By: Justin Corpron. In the Beginning… John von Neumann ( ) Stored program Developed merge sort for EDVAC in 1945.
1Computer Sciences Department. 2 QUICKSORT QUICKSORT TUTORIAL 5.
Introduction to Algorithm Complexity Bit Sum Problem.
S5.40. Module Structure 30% practical tests / 70% written exam 3h lectures / week (except reading week) 3 x 2h of computer labs (solving problems practicing.
Merge Sort.
Recitation 2: Merge and Quick Sort Işıl Karabey
Introduction to Algorithms: Divide-n-Conquer Algorithms
Divide-and-Conquer 6/30/2018 9:16 AM
Divide-and-Conquer Design
Computer Science 101 A Survey of Computer Science
Divide-and-Conquer The most-well known algorithm design strategy:
Chapter 4 Divide-and-Conquer
Chapter 2: Getting Started
Computing Disciplines Florida Gulf Coast University
Chapter 4: Divide and Conquer
Student Feedback on Robotics in CS1 The Fleet!
CS 160 Introduction to Computer Science
Lecture 33 CSE 331 Nov 19, 2012.
Presentation By: Justin Corpron
Richard Anderson Lecture 12 Recurrences and Divide and Conquer
Examples of Basic Blocks
CSE 373 Data Structures and Algorithms
Department of Computer Science & Engineering, HITEC University, Taxila
Divide-and-Conquer The most-well known algorithm design strategy:
Бази от данни и СУБД Основни понятия инж. Ангел Ст. Ангелов.
Algorithm Design and Analysis
Ալգորիթմներ Stack, Queue, Tree.
A New String Matching Algorithm Based on Logical Indexing
Divide and Conquer Neil Tang 4/24/2008
CPS120: Introduction to Computer Science
Seating “chart” Front Back 4 rows 5 rows 5 rows 2 rows 4 rows 2 rows
CPS120: Introduction to Computer Science
CSC 380: Design and Analysis of Algorithms
Lecture 31 CSE 331 Nov 11, 2011.
Basics Prof. Hsin-Mu (Michael) Tsai (蔡欣穆)
Divide-and-Conquer 7 2  9 4   2   4   7
Կարգավորում Insertion Sort, Merge Sort
Divide 9 × by 3 ×
Presentation transcript:

Գագաթի որոնում (Peak Finder) Ալգորիթմներ Գագաթի որոնում (Peak Finder)

Գագաթի որոնում: 1-չափանի դեպք։ a-i թվեր են 2-րդ էլեմենտը կանվանենք գագաթ այն և միայն այն դեպքում երբ, a ≤ b և b ≥ c: 1-ին էլեմենտը կանվանենք գագաթ է եթե a ≥ b 9-րդ տեղը կանվանենք գագաթ է եթե i ≥ h

Օրինակ

Խնդրի դրվածք։ Գտնել որևէ 1D-գագաթ, եթե այն գոյություն ունի Ապացուցել, որ սկզբում տրված սահմանումից հետևում է գագաթի գոյությունը

Հերթով դիտարկել բոլոր էլեմենտները։ Լուծման ալգորիթմ 1։ Հերթով դիտարկել բոլոր էլեմենտները։

Բարդություն։ T(n) = Θ(n) Վատագույն դեպք T(n) = Θ(n)

Լուծման ալգորիթմ 2։ Բաժանիր, որ տիրես (divide and conquer) Եթե a[n/2] < a[n/2-1] ապա գագաթ ման գալ 1-ից n/2-1 հատվածում Հակառակ դեպքում Եթե a[n/2] < a[n/2+1] ապա գագաթ ման գալ 1-ից n/2+1 հատվածում a[n/2] գագաթ է։

Բարդություն։ T(n) = Θ(log 2 𝑛 ) T(n) = T(n/2) + Θ(1) T(n/2) = T(n/4) + Θ(1) ⋯ T(2) = T(1) + Θ(1) T(1) = Θ(1) Θ(log 2 𝑛 ) T(n) = Θ(1) + ⋯ +Θ(1)

Θ(n) vs Θ(log 2 𝑛 )

Implementation of algorithms in java Lab Implementation of algorithms in java

Գագաթի որոնում: 2-չափանի դեպք։ a էլեմենտը կանվանենք գագաթ այն և միայն այն դեպքում, երբ a ≥ e, a ≥ b, a ≥ c, a ≥ d

Խնդրի դրվածք։ Գտնել որևէ 2D-գագաթ, եթե այն գոյություն ունի Ապացուցել, որ սկզբում տրված սահմանումից հետևում է գագաթի գոյությունը

Լուծման ալգորիթմ 1։ Վերցնել կամայական էլեմենտ, շարժվել ձախ-ներքև-աջ եթե համապատասխան էլեմենտը ավելի մեծ է։ Օրինակ՝ n=m=3

Բարդություն։ T(n,m) = Θ(n*m)

Լուծման ալգորիթմ 2։ Ֆիքսենք կամայական սյուն (օրինակ ՝ i-րդ) և գտնենք 1D-գագաթ։ Ենթադրենք այդ գագաթը գտնվում է j-րդ տողում։ Գտնենք այդ j-րդ տողի 1D-գագաթը որը և կհանդիսանա 2D- գագաթ։

Հակաօրինակ

Լուծման ալգորիթմ 3։ Վերցնենք մեջտեղի սյունակը` j = m/2 և գնտենք այդ սյունակի գլոբալ մաքսիմումը։ Ենթադրենք դա i-րդ տողում է։ Եթե (i,j-1) > (i,j) ապա դիտարկել ձախ սյունակներև ՝ (i,1) –ից (i,j-1) Հակառակ դեպքում, եթե (i,j+1) > (i,j) ապա դիտարկել աջ սյունակները ՝ (i,յ+1) –ից (i,m) Հակառակ դեպքում (արդեն կունենանք որ (i,j) ≥ (i,j-1) և (i,j) ≥ (i,j+1)) (i,j) կհանդիսանա 2D-գագաթ

Բարդություն։ T(n,m) = Θ(n∗log 2 𝑚 ) Կիսվեց մաքսիմում T(n,m) = T(n,m/2) + Θ(n) T(n,m/2) = T(n,m/4) + Θ(n) ⋯ T(n,2) = T(n,1) + Θ(n) T(n,1) = Θ(n) Ունենք T(n,1) = Θ(n) T(n,m) = Θ(n)+ ⋯ + Θ(n) Θ(log 2 𝑚 )

Θ(n*m) vs Θ(n∗log 2 𝑚 ) Մասնավորապես, երբ m=n

Շնորհակալություն https://www.youtube.com/watch?v=HtSuA80QTyo&list=PLUl4u3cNGP61Oq3tWYp6V_F- 5jb5L2iHb&index=1 https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction- to-algorithms-fall-2011/ https://ipc.am