SlideShare a Scribd company logo
1 of 62
Download to read offline
演算法
分析與設計
    期末報告
銘傳大學資訊工程所 一年級




周家聖
                E-mail : johnsonchou1129@hotmail.com
指導老師

徐
熊
健
老
師
Prune
and
Search
         刪減搜尋
          法
Literal

字面
Prune
  刪減
搜尋




 Search
Recursive
遞迴
範例
Example
Selection
Problem
      選擇
      問題
Selection
                                   Problem


Input :

  A set elements   S   and   k.
  Output :

     The   k-th smallest
                 element in S.
Step 1.


           Divide
          Elements into


          [n/5]   subsets
Algorithm Final Presentation
Step 2.




          Sort
          each subset
Each 5-element subset is sorted in non-decreasing sequence.
Step 3.
          Find a element

          P
          which is the
          median of the
          medians of
          the   n/5 subsets.
P




    M
Step 4.
    S into
Partition

S1, S2 and S3,
which contain the elements

less than, equal to, and greater than p,
respectively.
Step 5. Case I


If   |S1| > k, then
discard S2 and S3 and
solve the problem that


                         S1
selects the k-th smallest element from

during the next iteration
P



                            M




    At least 1/4 of S known to be greater than
    or equal to P.
Step 5. Case II




if|S1| + |S2| > k
then P is the k-th smallest element of S
P




    M
Step 5. Case III


otherwise,


let   k = k - |S1| - |S2|,
solve the problem that selects the k-th smallest
element from   S3 during the next iteration.
At least 1/4 of S known to be less than or equal to P.




                                                 P




                                                         M
Time complexity: T(n) = O(n)


step   1:   O(n)
step   2:   O(n)
step   3:   T(n/5)
step   4:   O(n)
step   5:   T(3n/4)


       => T(n) = T(3n/4) + T(n/5) + O(n)
Let
T(n) = a0 + a1n + a2n2 + … , a1 != 0

T(3n/4) = a0 + (3/4)a1n + (9/16)a2n2 + …

T(n/5) = a0 + (1/5)a1n + (1/25)a2n2 + …

T(3n/4 + n/5) = T(19n/20) = a0 + (19/20)a1n + (361/400)a2n2 + …


thus,
T(3n/4) + T(n/5) <= a0 + T(19n/20)
T(n) = T(3n/4) + T(n/5) + O(n)
<= cn + T(19n/20)
  = cn + (19/20)cn + T((19/20)2n)
  = cn              +       (19/20)cn   + (19/20)2cn + …
+ (19/20)pcn + T((19/20)p+1n) , (19/20)p+1n <= 1 <= (19/20)pn
          19 p + 1
      1− (   )
          20
  =        19
                   cn + b
        1−
           20
 <= 20cn +b

  = ...
O(n)
Prune and Search




定義
Many Iterations


很多
回合
Prunes away a fraction,
                 each iteration




刪除部分     每回合
so small,
solved directly in constant time c




                量少
        常數時間內
                       解決
所以 ...
 T(n) <= T((1 - f ) n) + cnk for sufficiently large n.
     <= T((1 - f )2n) + cnk + c(1 - f )knk
       ...
     <= c’+ cnk + c(1 - f )knk + c(1 - f )2knk + ... + c(1 - f )pknk
        = c’+ cnk(1 + (1 - f )k + (1 - f )2k + ... + (1 - f ) pk).


  Since 1 - f < 1, as n ,
   T(n) = O(nk)


Thus, the whole time-complexity
is as the same order as the time-complexity
each iteration.
1-Center
  Problem
Given n planar points, find a smallest circle to cover these n points.
Constrained
   1-Center
    Problem
The center is restricted to lying on a straight line.


                                                         Lij
                                            Pi




                                                        Pj




                                                               y=0

                                                 xij
  x*                           xm
Constrained
                                      1-Center
                                          Problem




Input :
n points and a straight line y = y'

     Output :
     The constrained   center on the line y = y'
Step 1: If n is no more than 2, solve this problem by a
brute-force method.

Step 2:         Form  disjoint pairs         of points (p1, p2),
(p3, p4), …,(pn-1, pn). If there are odd number of points, just let
the final pair be   (pn, p1).

Step 3: For each pair of points, (p , p ), find the point
                                          i   i+1

xi,i+1 on the line y = y’ such that
                     d(pi, xi,i+1) = d(pi+1, xi,i+1).

Step 4:       Find the   median of the all x        i,i+1
                                                            ’s.
                                                    Denote it as   x m.
Step 5 :
Calculate the   distance between p and x  i        m
                                                       for all i. Let   pj   be

the point which is farthest from xm. Let      xj   denote the projection
of pj onto y = y'.


If xj is to the left (right) of xm, then the optimal solution,     x* ,
must be to the left (right) of xm.


Step 6:
If x* < xm, for each xi,i+1 > xm, prune the point pi
if pi is closer to xm than pi+1, otherwise prune the point pi+1;

If x* > xm, do similarly.


Step 7: Go to Step 1.
By the constrained 1-center algorithm,
      we can determine the center




(x ,0) on the line y=0.
  *



                              Time complexity : O(n)
Algorithm Final Presentation
We can do more



不只
這樣
Let   (xs, ys)       be the center of the optimum circle.




We can determine whether
                         ys > 0, ys < 0 or ys = 0.


Similarly, we can also determine whether
                        xs > 0, xs < 0 or xs = 0.
Sign of
              The

            Optimal y
Let   I   be the set of points which are farthest from
                         (x*, 0).
Case 1:
I contains   one point P = (x , y ).        p   p




      ys has the same sign as that of yp.
Case 2 :

     I contains   more than one point.

Find the   smallest arc spanning all points in I.

     Let    P1   = (x1, y1) and   P2   = (x2, y2)



 be the two   end points                  of the arc.
If this   arc >= 180                      o
                                              , then ys = 0.


                P1




                           (x*, 0)

                                                    y=0




           P3
                                     P2


                     (a)
y1 + y2
else   ys has the same sign as that of    2 .

             P1
                   P3
                        P4

                             P2




                                  y=0
         (x*, 0)




       (b)
1-Center
  Problem
1-Center
                                                     Problem




Input:

          A set   S = {p , p , …, p } of n points.
                          1   2    n




Output:

         The smallest enclosing   circle for S.
Step 1:
  If S contains no more than16 points,
           solve the problem by a


          brute-force
                  method.
Step 2:
    Form   disjoint pairs of points,
             (p1, p2), (p3, p4), …,(pn-1, pn).

          For each pair of points, (pi, pi+1),
find the perpendicular bisector of line segment p i p i + 1 .

      Denote them as      Li/2, for i = 2, 4, …, n,
               and compute their slopes.


       Let the slope of Lk be denoted as         sk ,
                 for k = 1, 2, 3, …, n/2.
Step 3: Compute the median of s ’s, and    k

        denote it by s .
                      m


  Step 4:           Rotate the coordinate system
          so that the x-axis coincide with
                  y = smx .
Let the set of Lk's with positive (negative) slopes be
       I+ (I-). (Both of them are of size n/4.)
Step 5:           Construct disjoint pairs of lines,


       (Li+, Li-) for i = 1, 2, …, n/4,
                         ¿




            where Li+ in I+ and Li- in I-.

Find the intersection of each pair and denote it by
        (ai, bi), for i = 1, 2, …, n/4.
Step 6: Find the median of b ’s.       i


          Denote it as y*.


 Apply the constrained 1-center subroutine
to S, requiring that the center of circle be located on
                     y=y*.
     Let the solution of this constrained 1-center
            problem be   (x', y*).
Step 7: Determine whether
                  (x', y*)
          is the optimal solution.


                     If it is, exit;

otherwise, record   ys > y* or ys < y*.
Step 8: If y > y*, find the median of a ’s for
                        s                         i


   those (a , b )’s where bi < y*.
                i   i


   If ys < y*, find the median of ai's of those t hose

           (ai, bi)’s where   bi > y*.
             Denote the median as    x* .
Apply the constrained 1-center algorithm to S, requiring
that the center of circle be located on x = x*.

 Let the solution of this contained 1-center problem be


                        (x*, y').
Step 9: Determine whether
                  (x*, y')
           is the optimal solution.


                     If it is, exit;
otherwise, record   xs > x* or xs < x*.
Step 10:
       Case 1:   xs > x*              and   ys > y*             .
          Find all (ai, bi)'s such that ai < x* and bi < y*.

          Let (ai, bi) be the intersection of Li+ and Li-.
              Let Li- be the bisector of pj and pk.

Prune            away pj(pk) if pj(pk) is closer to (x*, y*) than pk(pj).


           Case 2: xs < x* and ys > y*. Do similarly.
           Case 3: xs < x* and ys < y*. Do similarly.
           Case 4: xs > x* and ys > y*. Do similarly.

Step 11: Let S be the set of the remaining points. Go to Step 1.
Time
            complexity


T(n) = T(15n/16)+O(n)

       =   O(n)
Thanks for your
         listening



      感謝
      聆聽
End

More Related Content

What's hot (20)

Number theory lecture (part 1)
Number theory lecture (part 1)Number theory lecture (part 1)
Number theory lecture (part 1)
 
EULER AND FERMAT THEOREM
EULER AND FERMAT THEOREMEULER AND FERMAT THEOREM
EULER AND FERMAT THEOREM
 
Midterm II Review
Midterm II ReviewMidterm II Review
Midterm II Review
 
Report in math 830
Report in math 830Report in math 830
Report in math 830
 
Lesson 1: Functions
Lesson 1: FunctionsLesson 1: Functions
Lesson 1: Functions
 
Differential in several variables
Differential in several variables Differential in several variables
Differential in several variables
 
Sadiq Hussain
Sadiq Hussain Sadiq Hussain
Sadiq Hussain
 
Chap7 2 Ecc Intro
Chap7 2 Ecc IntroChap7 2 Ecc Intro
Chap7 2 Ecc Intro
 
Chapter 2 (maths 3)
Chapter 2 (maths 3)Chapter 2 (maths 3)
Chapter 2 (maths 3)
 
ma112011id535
ma112011id535ma112011id535
ma112011id535
 
Sect2 1
Sect2 1Sect2 1
Sect2 1
 
Partitions
PartitionsPartitions
Partitions
 
Midsem sol 2013
Midsem sol 2013Midsem sol 2013
Midsem sol 2013
 
Maths 12
Maths 12Maths 12
Maths 12
 
Ap gp
Ap gpAp gp
Ap gp
 
Intro probability 3
Intro probability 3Intro probability 3
Intro probability 3
 
Derivatie class 12
Derivatie class 12Derivatie class 12
Derivatie class 12
 
Aman yadav
Aman yadavAman yadav
Aman yadav
 
Engr 371 final exam april 1996
Engr 371 final exam april 1996Engr 371 final exam april 1996
Engr 371 final exam april 1996
 
Intro probability 2
Intro probability 2Intro probability 2
Intro probability 2
 

Viewers also liked

Viewers also liked (20)

Camping og facebook_til_download
Camping og facebook_til_downloadCamping og facebook_til_download
Camping og facebook_til_download
 
Wallander - Becka
Wallander - BeckaWallander - Becka
Wallander - Becka
 
Reading
ReadingReading
Reading
 
пдд азербайджана
пдд азербайджанапдд азербайджана
пдд азербайджана
 
READING 2
READING 2READING 2
READING 2
 
Arro capabilities lean revised 2010
Arro capabilities   lean revised 2010Arro capabilities   lean revised 2010
Arro capabilities lean revised 2010
 
Luat thue thu nhap ca nhan 2007
Luat thue thu nhap ca nhan 2007Luat thue thu nhap ca nhan 2007
Luat thue thu nhap ca nhan 2007
 
Bosh
BoshBosh
Bosh
 
Apu presentation
Apu presentationApu presentation
Apu presentation
 
The perng mha ngan box1
The perng mha ngan box1The perng mha ngan box1
The perng mha ngan box1
 
Gresco catalog
Gresco catalogGresco catalog
Gresco catalog
 
Quotationsanddialogue 2014
Quotationsanddialogue 2014Quotationsanddialogue 2014
Quotationsanddialogue 2014
 
видеокамера сони
видеокамера сонивидеокамера сони
видеокамера сони
 
The perng mha ngan box
The perng mha ngan boxThe perng mha ngan box
The perng mha ngan box
 
Membangun Nasionalisme melalui Upacara Bendera - Universitas Katolik Parahyan...
Membangun Nasionalisme melalui Upacara Bendera - Universitas Katolik Parahyan...Membangun Nasionalisme melalui Upacara Bendera - Universitas Katolik Parahyan...
Membangun Nasionalisme melalui Upacara Bendera - Universitas Katolik Parahyan...
 
General Catalog GFS Indonesia
General Catalog GFS IndonesiaGeneral Catalog GFS Indonesia
General Catalog GFS Indonesia
 
Internet Week Yahoo! Academy: How Direct Can You Be?
Internet Week Yahoo! Academy: How Direct Can You Be?Internet Week Yahoo! Academy: How Direct Can You Be?
Internet Week Yahoo! Academy: How Direct Can You Be?
 
FA Catalog
FA CatalogFA Catalog
FA Catalog
 
Integrate gitolite with mantis
Integrate gitolite with mantisIntegrate gitolite with mantis
Integrate gitolite with mantis
 
The perng mha ngan box
The perng mha ngan boxThe perng mha ngan box
The perng mha ngan box
 

Similar to Algorithm Final Presentation

Similar to Algorithm Final Presentation (20)

6e-ch4.ppt
6e-ch4.ppt6e-ch4.ppt
6e-ch4.ppt
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
 
Interpolation techniques - Background and implementation
Interpolation techniques - Background and implementationInterpolation techniques - Background and implementation
Interpolation techniques - Background and implementation
 
Numerical method
Numerical methodNumerical method
Numerical method
 
Dynamical systems solved ex
Dynamical systems solved exDynamical systems solved ex
Dynamical systems solved ex
 
Multivriada ppt ms
Multivriada   ppt msMultivriada   ppt ms
Multivriada ppt ms
 
Zeros of p(x)
Zeros of p(x)Zeros of p(x)
Zeros of p(x)
 
polynomial
 polynomial  polynomial
polynomial
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
Algebra
AlgebraAlgebra
Algebra
 
A (1 )-Approximation Algorithm For The Generalized Assignment Problem
A (1 )-Approximation Algorithm For The Generalized Assignment ProblemA (1 )-Approximation Algorithm For The Generalized Assignment Problem
A (1 )-Approximation Algorithm For The Generalized Assignment Problem
 
Solution set 3
Solution set 3Solution set 3
Solution set 3
 
Maths9Polynomial.pptx
Maths9Polynomial.pptxMaths9Polynomial.pptx
Maths9Polynomial.pptx
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
An Algorithm to Find the Largest Circle inside a Polygon
An Algorithm to Find the Largest Circle inside a PolygonAn Algorithm to Find the Largest Circle inside a Polygon
An Algorithm to Find the Largest Circle inside a Polygon
 
Daa unit iv - problems
Daa   unit  iv - problemsDaa   unit  iv - problems
Daa unit iv - problems
 
4th semester Civil Engineering (2012-December) Question Papers
4th semester Civil Engineering   (2012-December) Question Papers 4th semester Civil Engineering   (2012-December) Question Papers
4th semester Civil Engineering (2012-December) Question Papers
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functions
 
Factor theorem
Factor theoremFactor theorem
Factor theorem
 
searching.pdf
searching.pdfsearching.pdf
searching.pdf
 

Recently uploaded

UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Introduction to Quantum Computing
Introduction to Quantum ComputingIntroduction to Quantum Computing
Introduction to Quantum ComputingGDSC PJATK
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataSafe Software
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 

Recently uploaded (20)

UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Introduction to Quantum Computing
Introduction to Quantum ComputingIntroduction to Quantum Computing
Introduction to Quantum Computing
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 

Algorithm Final Presentation

  • 2. 銘傳大學資訊工程所 一年級 周家聖 E-mail : johnsonchou1129@hotmail.com
  • 4. Prune and Search 刪減搜尋 法
  • 10. Selection Problem 選擇 問題
  • 11. Selection Problem Input : A set elements S and k. Output : The k-th smallest element in S.
  • 12. Step 1. Divide Elements into [n/5] subsets
  • 14. Step 2. Sort each subset
  • 15. Each 5-element subset is sorted in non-decreasing sequence.
  • 16. Step 3. Find a element P which is the median of the medians of the n/5 subsets.
  • 17. P M
  • 18. Step 4. S into Partition S1, S2 and S3, which contain the elements less than, equal to, and greater than p, respectively.
  • 19. Step 5. Case I If |S1| > k, then discard S2 and S3 and solve the problem that S1 selects the k-th smallest element from during the next iteration
  • 20. P M At least 1/4 of S known to be greater than or equal to P.
  • 21. Step 5. Case II if|S1| + |S2| > k then P is the k-th smallest element of S
  • 22. P M
  • 23. Step 5. Case III otherwise, let k = k - |S1| - |S2|, solve the problem that selects the k-th smallest element from S3 during the next iteration.
  • 24. At least 1/4 of S known to be less than or equal to P. P M
  • 25. Time complexity: T(n) = O(n) step 1: O(n) step 2: O(n) step 3: T(n/5) step 4: O(n) step 5: T(3n/4) => T(n) = T(3n/4) + T(n/5) + O(n)
  • 26. Let T(n) = a0 + a1n + a2n2 + … , a1 != 0 T(3n/4) = a0 + (3/4)a1n + (9/16)a2n2 + … T(n/5) = a0 + (1/5)a1n + (1/25)a2n2 + … T(3n/4 + n/5) = T(19n/20) = a0 + (19/20)a1n + (361/400)a2n2 + … thus, T(3n/4) + T(n/5) <= a0 + T(19n/20)
  • 27. T(n) = T(3n/4) + T(n/5) + O(n) <= cn + T(19n/20) = cn + (19/20)cn + T((19/20)2n) = cn + (19/20)cn + (19/20)2cn + … + (19/20)pcn + T((19/20)p+1n) , (19/20)p+1n <= 1 <= (19/20)pn 19 p + 1 1− ( ) 20 = 19 cn + b 1− 20 <= 20cn +b = ...
  • 28. O(n)
  • 31. Prunes away a fraction, each iteration 刪除部分 每回合
  • 32. so small, solved directly in constant time c 量少 常數時間內 解決
  • 33. 所以 ... T(n) <= T((1 - f ) n) + cnk for sufficiently large n.  <= T((1 - f )2n) + cnk + c(1 - f )knk ...  <= c’+ cnk + c(1 - f )knk + c(1 - f )2knk + ... + c(1 - f )pknk = c’+ cnk(1 + (1 - f )k + (1 - f )2k + ... + (1 - f ) pk). Since 1 - f < 1, as n , T(n) = O(nk) Thus, the whole time-complexity is as the same order as the time-complexity each iteration.
  • 35. Given n planar points, find a smallest circle to cover these n points.
  • 36. Constrained 1-Center Problem
  • 37. The center is restricted to lying on a straight line. Lij Pi Pj y=0 xij x* xm
  • 38. Constrained 1-Center Problem Input : n points and a straight line y = y' Output : The constrained center on the line y = y'
  • 39. Step 1: If n is no more than 2, solve this problem by a brute-force method. Step 2: Form disjoint pairs of points (p1, p2), (p3, p4), …,(pn-1, pn). If there are odd number of points, just let the final pair be (pn, p1). Step 3: For each pair of points, (p , p ), find the point i i+1 xi,i+1 on the line y = y’ such that d(pi, xi,i+1) = d(pi+1, xi,i+1). Step 4: Find the median of the all x i,i+1 ’s. Denote it as x m.
  • 40. Step 5 : Calculate the distance between p and x i m for all i. Let pj be the point which is farthest from xm. Let xj denote the projection of pj onto y = y'. If xj is to the left (right) of xm, then the optimal solution, x* , must be to the left (right) of xm. Step 6: If x* < xm, for each xi,i+1 > xm, prune the point pi if pi is closer to xm than pi+1, otherwise prune the point pi+1; If x* > xm, do similarly. Step 7: Go to Step 1.
  • 41. By the constrained 1-center algorithm, we can determine the center (x ,0) on the line y=0. * Time complexity : O(n)
  • 43. We can do more 不只 這樣
  • 44. Let (xs, ys) be the center of the optimum circle. We can determine whether ys > 0, ys < 0 or ys = 0. Similarly, we can also determine whether xs > 0, xs < 0 or xs = 0.
  • 45. Sign of The Optimal y Let I be the set of points which are farthest from (x*, 0).
  • 46. Case 1: I contains one point P = (x , y ). p p ys has the same sign as that of yp.
  • 47. Case 2 : I contains more than one point. Find the smallest arc spanning all points in I. Let P1 = (x1, y1) and P2 = (x2, y2) be the two end points of the arc.
  • 48. If this arc >= 180 o , then ys = 0. P1 (x*, 0) y=0 P3 P2 (a)
  • 49. y1 + y2 else ys has the same sign as that of 2 . P1 P3 P4 P2 y=0 (x*, 0) (b)
  • 51. 1-Center Problem Input: A set S = {p , p , …, p } of n points. 1 2 n Output: The smallest enclosing circle for S.
  • 52. Step 1: If S contains no more than16 points, solve the problem by a brute-force method.
  • 53. Step 2: Form disjoint pairs of points, (p1, p2), (p3, p4), …,(pn-1, pn). For each pair of points, (pi, pi+1), find the perpendicular bisector of line segment p i p i + 1 . Denote them as Li/2, for i = 2, 4, …, n, and compute their slopes. Let the slope of Lk be denoted as sk , for k = 1, 2, 3, …, n/2.
  • 54. Step 3: Compute the median of s ’s, and k denote it by s . m Step 4: Rotate the coordinate system so that the x-axis coincide with y = smx . Let the set of Lk's with positive (negative) slopes be I+ (I-). (Both of them are of size n/4.)
  • 55. Step 5: Construct disjoint pairs of lines, (Li+, Li-) for i = 1, 2, …, n/4, ¿ where Li+ in I+ and Li- in I-. Find the intersection of each pair and denote it by (ai, bi), for i = 1, 2, …, n/4.
  • 56. Step 6: Find the median of b ’s. i Denote it as y*. Apply the constrained 1-center subroutine to S, requiring that the center of circle be located on y=y*. Let the solution of this constrained 1-center problem be (x', y*).
  • 57. Step 7: Determine whether (x', y*) is the optimal solution. If it is, exit; otherwise, record ys > y* or ys < y*.
  • 58. Step 8: If y > y*, find the median of a ’s for s i those (a , b )’s where bi < y*. i i If ys < y*, find the median of ai's of those t hose (ai, bi)’s where bi > y*. Denote the median as x* . Apply the constrained 1-center algorithm to S, requiring that the center of circle be located on x = x*. Let the solution of this contained 1-center problem be (x*, y').
  • 59. Step 9: Determine whether (x*, y') is the optimal solution. If it is, exit; otherwise, record xs > x* or xs < x*.
  • 60. Step 10: Case 1: xs > x* and ys > y* . Find all (ai, bi)'s such that ai < x* and bi < y*. Let (ai, bi) be the intersection of Li+ and Li-. Let Li- be the bisector of pj and pk. Prune away pj(pk) if pj(pk) is closer to (x*, y*) than pk(pj). Case 2: xs < x* and ys > y*. Do similarly. Case 3: xs < x* and ys < y*. Do similarly. Case 4: xs > x* and ys > y*. Do similarly. Step 11: Let S be the set of the remaining points. Go to Step 1.
  • 61. Time complexity T(n) = T(15n/16)+O(n) = O(n)
  • 62. Thanks for your listening 感謝 聆聽 End