This document provides an overview of the Design and Analysis of Algorithms course. It discusses the closest pair of points problem and provides a divide and conquer algorithm to solve it in O(n log^2 n) time. The algorithm works by recursively dividing the problem into subproblems on left and right halves, computing the closest pairs for each, and then combining results while searching a sorted array to handle point pairs across divisions. Homework includes improving the closest pair algorithm to O(n log n) time and considering a data structure for orthogonal range searching.
We consider the problem of finding anomalies in high-dimensional data using popular PCA based anomaly scores. The naive algorithms for computing these scores explicitly compute the PCA of the covariance matrix which uses space quadratic in the dimensionality of the data. We give the first streaming algorithms
that use space that is linear or sublinear in the dimension. We prove general results showing that any sketch of a matrix that satisfies a certain operator norm guarantee can be used to approximate these scores. We instantiate these results with powerful matrix sketching techniques such as Frequent Directions and random projections to derive efficient and practical algorithms for these problems, which we validate over real-world data sets. Our main technical contribution is to prove matrix perturbation
inequalities for operators arising in the computation of these measures.
-Proceedings: https://arxiv.org/abs/1804.03065
-Origin: https://arxiv.org/abs/1804.03065
I am Marianna P. I am a Computer Science Exam Expert at programmingexamhelp.com. I hold a Bachelor of Information Technology from, California Institute of Technology, United States. I have been helping students with their exams for the past 12 years. You can hire me to take your exam in Computer Science.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Computer Science Exam.
We consider the problem of finding anomalies in high-dimensional data using popular PCA based anomaly scores. The naive algorithms for computing these scores explicitly compute the PCA of the covariance matrix which uses space quadratic in the dimensionality of the data. We give the first streaming algorithms
that use space that is linear or sublinear in the dimension. We prove general results showing that any sketch of a matrix that satisfies a certain operator norm guarantee can be used to approximate these scores. We instantiate these results with powerful matrix sketching techniques such as Frequent Directions and random projections to derive efficient and practical algorithms for these problems, which we validate over real-world data sets. Our main technical contribution is to prove matrix perturbation
inequalities for operators arising in the computation of these measures.
-Proceedings: https://arxiv.org/abs/1804.03065
-Origin: https://arxiv.org/abs/1804.03065
I am Marianna P. I am a Computer Science Exam Expert at programmingexamhelp.com. I hold a Bachelor of Information Technology from, California Institute of Technology, United States. I have been helping students with their exams for the past 12 years. You can hire me to take your exam in Computer Science.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Computer Science Exam.
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...Naoki Shibata
Naoki Shibata : Efficient Evaluation Methods of Elementary Functions Suitable for SIMD Computation, Journal of Computer Science on Research and Development, Proceedings of the International Supercomputing Conference ISC10., Volume 25, Numbers 1-2, pp. 25-32, 2010, DOI: 10.1007/s00450-010-0108-2 (May. 2010).
http://www.springerlink.com/content/340228x165742104/
http://freshmeat.net/projects/sleef
Data-parallel architectures like SIMD (Single Instruction Multiple Data) or SIMT (Single Instruction Multiple Thread) have been adopted in many recent CPU and GPU architectures. Although some SIMD and SIMT instruction sets include double-precision arithmetic and bitwise operations, there are no instructions dedicated to evaluating elementary functions like trigonometric functions in double precision. Thus, these functions have to be evaluated one by one using an FPU or using a software library. However, traditional algorithms for evaluating these elementary functions involve heavy use of conditional branches and/or table look-ups, which are not suitable for SIMD computation. In this paper, efficient methods are proposed for evaluating the sine, cosine, arc tangent, exponential and logarithmic functions in double precision without table look-ups, scattering from, or gathering into SIMD registers, or conditional branches. We implemented these methods using the Intel SSE2 instruction set to evaluate their accuracy and speed. The results showed that the average error was less than 0.67 ulp, and the maximum error was 6 ulps. The computation speed was faster than the FPUs on Intel Core 2 and Core i7 processors.
Algorithm Analysis
Computational Complexity
Introduction to Basic Data
Structures
Graph Theory
Graph Algorithms
Greedy Algorithms
Divide and Conquer
Dynamic Programming
Introduction to Linear Programming
Flow Network
Paper Study: Melding the data decision pipelineChenYiHuang5
Melding the data decision pipeline: Decision-Focused Learning for Combinatorial Optimization from AAAI2019.
Derive the math equation from myself and match the same result as two mentioned CMU papers [Donti et. al. 2017, Amos et. al. 2017] while applying the same derivation procedure.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
More Related Content
Similar to CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...Naoki Shibata
Naoki Shibata : Efficient Evaluation Methods of Elementary Functions Suitable for SIMD Computation, Journal of Computer Science on Research and Development, Proceedings of the International Supercomputing Conference ISC10., Volume 25, Numbers 1-2, pp. 25-32, 2010, DOI: 10.1007/s00450-010-0108-2 (May. 2010).
http://www.springerlink.com/content/340228x165742104/
http://freshmeat.net/projects/sleef
Data-parallel architectures like SIMD (Single Instruction Multiple Data) or SIMT (Single Instruction Multiple Thread) have been adopted in many recent CPU and GPU architectures. Although some SIMD and SIMT instruction sets include double-precision arithmetic and bitwise operations, there are no instructions dedicated to evaluating elementary functions like trigonometric functions in double precision. Thus, these functions have to be evaluated one by one using an FPU or using a software library. However, traditional algorithms for evaluating these elementary functions involve heavy use of conditional branches and/or table look-ups, which are not suitable for SIMD computation. In this paper, efficient methods are proposed for evaluating the sine, cosine, arc tangent, exponential and logarithmic functions in double precision without table look-ups, scattering from, or gathering into SIMD registers, or conditional branches. We implemented these methods using the Intel SSE2 instruction set to evaluate their accuracy and speed. The results showed that the average error was less than 0.67 ulp, and the maximum error was 6 ulps. The computation speed was faster than the FPUs on Intel Core 2 and Core i7 processors.
Algorithm Analysis
Computational Complexity
Introduction to Basic Data
Structures
Graph Theory
Graph Algorithms
Greedy Algorithms
Divide and Conquer
Dynamic Programming
Introduction to Linear Programming
Flow Network
Paper Study: Melding the data decision pipelineChenYiHuang5
Melding the data decision pipeline: Decision-Focused Learning for Combinatorial Optimization from AAAI2019.
Derive the math equation from myself and match the same result as two mentioned CMU papers [Donti et. al. 2017, Amos et. al. 2017] while applying the same derivation procedure.
Similar to CS345-Algorithms-II-Lecture-1-CS345-2016.pdf (20)
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
In this slide, we show the simulation example and the way to compile this solver.
In this solver, the Helmholtz equation can be solved by helmholtzFoam. Also, the Helmholtz equation with uniformly dispersed bubbles can be simulated by helmholtzBubbleFoam.
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
top nidhi software solution freedownloadvrstrong314
This presentation emphasizes the importance of data security and legal compliance for Nidhi companies in India. It highlights how online Nidhi software solutions, like Vector Nidhi Software, offer advanced features tailored to these needs. Key aspects include encryption, access controls, and audit trails to ensure data security. The software complies with regulatory guidelines from the MCA and RBI and adheres to Nidhi Rules, 2014. With customizable, user-friendly interfaces and real-time features, these Nidhi software solutions enhance efficiency, support growth, and provide exceptional member services. The presentation concludes with contact information for further inquiries.
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
Your Digital Assistant.
Making complex approach simple. Straightforward process saves time. No more waiting to connect with people that matter to you. Safety first is not a cliché - Securely protect information in cloud storage to prevent any third party from accessing data.
Would you rather make your visitors feel burdened by making them wait? Or choose VizMan for a stress-free experience? VizMan is an automated visitor management system that works for any industries not limited to factories, societies, government institutes, and warehouses. A new age contactless way of logging information of visitors, employees, packages, and vehicles. VizMan is a digital logbook so it deters unnecessary use of paper or space since there is no requirement of bundles of registers that is left to collect dust in a corner of a room. Visitor’s essential details, helps in scheduling meetings for visitors and employees, and assists in supervising the attendance of the employees. With VizMan, visitors don’t need to wait for hours in long queues. VizMan handles visitors with the value they deserve because we know time is important to you.
Feasible Features
One Subscription, Four Modules – Admin, Employee, Receptionist, and Gatekeeper ensures confidentiality and prevents data from being manipulated
User Friendly – can be easily used on Android, iOS, and Web Interface
Multiple Accessibility – Log in through any device from any place at any time
One app for all industries – a Visitor Management System that works for any organisation.
Stress-free Sign-up
Visitor is registered and checked-in by the Receptionist
Host gets a notification, where they opt to Approve the meeting
Host notifies the Receptionist of the end of the meeting
Visitor is checked-out by the Receptionist
Host enters notes and remarks of the meeting
Customizable Components
Scheduling Meetings – Host can invite visitors for meetings and also approve, reject and reschedule meetings
Single/Bulk invites – Invitations can be sent individually to a visitor or collectively to many visitors
VIP Visitors – Additional security of data for VIP visitors to avoid misuse of information
Courier Management – Keeps a check on deliveries like commodities being delivered in and out of establishments
Alerts & Notifications – Get notified on SMS, email, and application
Parking Management – Manage availability of parking space
Individual log-in – Every user has their own log-in id
Visitor/Meeting Analytics – Evaluate notes and remarks of the meeting stored in the system
Visitor Management System is a secure and user friendly database manager that records, filters, tracks the visitors to your organization.
"Secure Your Premises with VizMan (VMS) – Get It Now"
1. Design and Analysis of Algorithms
Lecture 1
• Overview of the course
• Closest Pair problem
1
https://moodle.cse.iitk.ac.in
CS345A
Algorithms-II
2. Aim of the course
To empower each student with the skills to design algorithms
• With provable guarantee on correctness.
• With provable guarantee on their efficiency.
2
3. Algorithm Paradigm
Motivation:
• Many problems whose algorithms are based on a common approach.
➔ A need of a systematic study of the characteristics of such approaches.
Algorithm Paradigms:
• Divide and Conquer
• Greedy Strategy
• Dynamic Programming
3
(advanced)
(advanced)
4. Maximum Flow
Given a network for transporting certain commodity (water/bits)
from a designated source vertex 𝒔 and sink vertex 𝒕.
Each edge has a certain capacity (max rate per unit time at which commodity
can be pumped along that edge),
Compute the maximum rate at which we can pump flow from 𝒔 to 𝒕.
Constraints: capacity constraint and conservation constraint. 4
𝒔
𝒗
𝒖
𝒙
𝒚
𝒕
2
17
5
6
8
17
4
15
16
7
14
5. Miscellaneous
• Matching in Graphs
Maximum matching, Stable matching
• Amortized Analysis
A powerful technique to analyse time complexity of algorithms
• String Matching
• Linear Programming
5
6. Last topic on Algorithms
• NP Complete problems
• Approximation/randomized Algorithms
6
8. Data structures
• Augmented Binary Search Trees
• Range Minima Data structure (optimal size)
• Fibonacci Heap
8
: Additional information
9. Orthogonal Range searching
Problem: Preprocess a set of 𝒏 points so that given any query rectangle,
the number of points lying inside it can be reported efficiently.
Data structure:
size = O(𝒏 log 𝒏), Query = O( log2 𝒏),
size = O(𝒏), Query = O( 𝑛), 9
Rectangle
A novel application of augmented BST
Try to solve it…
You can surely do it…☺
Rectangle
11. An Overview
A problem in this paradigm is solved in the following way.
1. Divide the problem instance into two or more instances of the same problem.
2. Solve each smaller instance recursively (base case suitably defined).
3. Combine the solutions of the smaller instances
to get the solution of the original instance.
11
This is usually the main nontrivial step
in the design of an algorithm using
divide and conquer strategy
12. Example Problems
1. Merge Sort
2. Multiplication of two 𝒏-bit integers.
3. Counting the number of inversions in an array.
4. Median finding in linear time.
12
15. Closest Pair of Points
Problem Definition:
Given a set 𝑷 of 𝒏 > 𝟏 points in plane,
compute the pair of points with minimum Euclidean distance.
Deterministic algorithms:
• O(𝒏𝟐) : Trivial algorithm
• O(𝒏 𝐥𝐨𝐠 𝒏) : Divide and Conquer based algorithm
15
16. Hint/Tool No. 1
Exercise:
What is the maximum number of points that can be placed in a unit square
such that the minimum distance is at least 1 ?
Answer: 4.
16
1
1
2
A discrete math exercise
If there are more than
4 points, at least one
of the four small
squares will have
more than 1 points.
17. Hint/Tool No. 2
Question:
For which algorithmic problems do we need a suitable data structure ?
Answer:
If the problem involves “many” operations of same type on a given data.
For example, it is worth sorting an array only if there are going to be many
search queries on it.
Let us see if you can use this principle in today’s class itself ☺
17
When do we use a data structure ?
19. The conquer step
19
𝜹𝑳
𝜹𝑹
Compute closest pair of the
left half set
Compute closest pair of the
right half set
Notice 𝜹𝑳 < 𝜹𝑹 for this given instance
22. The combine step
22
𝜹𝑳
𝜹𝑹
𝜹𝑳
𝜹𝑳
Focus on a point 𝒑 in
left strip.
Where do we have to search for the
points in the right strip that can form a
pair with 𝒑 at distance < 𝜹𝑳 ?
𝒑
24. The combine step
24
𝜹𝑳
𝜹𝑹
𝜹𝑳
𝜹𝑳
𝜹𝑳
𝜹𝑳
Only the points lying in these
2 red squares are relevant as
far as 𝒑 is concerned.
𝒑
How many points can
there be in these 2 red
squares each of length𝜹𝑳?
Surely not more than 8
(using Hint 1)
How to find the points in
these red square for point 𝒑 ?
It will take O(𝒏) time for a given 𝒑.
It is time to use Hint/Tool no. 2.
Think for a while before going to
the next slide.
25. The combine step
25
𝜹𝑳
𝜹𝑹
𝜹𝑳
𝜹𝑳
𝜹𝑳
𝜹𝑳
We need to find points in the
2 red square for every point
in the left strip.
So build a suitable data structure
for points in the right strip so that
we can answer such query efficiently
for each point in the left strip.
What will be
the data structure ?
An array storing the points of
the right strip in increasing
order of y-coordinates.
𝜹𝑳
𝜹𝑳
𝜹𝑳
𝜹𝑳
26. Divide and Conquer based algorithm
CP-Distance(𝑃)
{ If (| 𝑃 |=1 ) return infinity;
{ Compute 𝑥-median of 𝑃;
(𝑃𝐿, 𝑃𝑅)Split-by-𝑥-median(𝑃);
𝜹𝑳 CP-Distance(𝑃𝐿) ;
𝜹𝑹 CP-Distance(𝑃𝑅) ;
𝜹 min(𝜹𝑳, 𝜹𝑹);
𝑆𝐿 strip of 𝑃𝐿;
𝑆𝑅 strip of 𝑃𝑅;
𝐴 Sorted array of 𝑆𝑅;
For each 𝑝 ∈ 𝑆𝐿,
𝒚 y-coordinate of 𝑝;
Search 𝐴 for points with y-coordinate within 𝒚 ± 𝜹;
Compute distance from 𝑝 to each of these points;
Update 𝜹 accordingly;
return 𝜹;
}
26
Divide step
Combine/conquer step
𝑶( 𝐏 log 𝐏) time
𝑶( 𝐏 ) + 2 T(|𝐏|/2) time
27. Running time of the algorithm
What is the recurrence for running time?
T(𝑛) = c 𝑛 log 𝑛 + 2 T(𝑛/2)
➔
T(𝑛) = O( 𝑛 log2𝑛)
Theorem:
There exists an O( 𝑛 log2𝑛) time algorithm to compute closest pair of 𝑛 points
in plane.
27
28. Conclusion
Homework:
1. Try to improve the running time to O( 𝑛 log 𝑛).
Hint: “the code will look similar to that of MergeSort”.
2. Ponder over the data structure for orthogonal range searching.
28
29. How does one design an algorithm ?
If you wish to find the answer on your own,
try to solve the first assignment problem on your own.
29
Without any help from the web
Without any help from the your friends
30. Assignment 1
Smallest Enclosing circle
Problem definition: Given 𝒏 points in a plane,
compute the smallest radius circle that encloses all 𝒏 point.
30