SlideShare a Scribd company logo
1 of 5
Download to read offline
Q1.
To implement the TwoLineSegmentIntersect algorithm, we can use the following steps:
1. Calculate the slope of each line segment.
2. Calculate the y-intercept of each line segment.
3. If both line segments are ver�cal, check if they overlap on the x-axis.
4. If one or both line segments are not ver�cal, calculate the intersec�on point of the two lines.
5. Check if the intersec�on point is within both line segments.
The �me complexity of this algorithm can be analyzed as follows:
1. Calcula�ng the slope and y-intercept of each line segment takes constant �me, so this step
has a �me complexity of O(1).
2. Checking if both line segments are ver�cal takes constant �me, so this step also has a �me
complexity of O(1).
3. Calcula�ng the intersec�on point of two non-ver�cal line segments involves solving a system
of two linear equa�ons, which can be done in O(1) �me using Cramer's rule. Therefore, this step has
a �me complexity of O(1).
4. Checking if the intersec�on point is within both line segments takes constant �me, so this
step also has a �me complexity of O(1).
Therefore, the overall �me complexity of the TwoLineSegmentIntersect algorithm is O(1), which
means that its running �me does not depend on the input size n.
Since the �me complexity is constant, the graph of n vs T(n) will be a horizontal line at some constant
value. Therefore, it cannot be compared with the graphs of n vs n, n vs log n, n vs n2, n vs n log n, n
vs n2log n, or n vs n3, which are all increasing func�ons of n.
GRAPH:
Q2.
To implement the isTriangle algorithm, we can use the following steps:
Calculate the distance between P1 and P2.
Calculate the distance between P2 and P3.
Calculate the distance between P3 and P1.
Check if any two of the calculated distances are greater than the third distance. If so, the three points
form a triangle. Otherwise, they do not.
The �me complexity of this algorithm can be analyzed as follows:
Calcula�ng the distance between two points involves compu�ng the square root of the sum of the
squares of the differences between their x and y coordinates. This opera�on takes constant �me, so
each of the three distance calcula�ons has a �me complexity of O(1).
Checking if any two of the calculated distances are greater than the third distance involves
comparing three numbers, which takes constant �me, so this step also has a �me complexity of O(1).
Therefore, the overall �me complexity of the isTriangle algorithm is O(1), which means that its
running �me does not depend on the input size n.
Since the �me complexity is constant, the graph of n vs T(n) will be a horizontal line at some constant
value. Therefore, it cannot be compared with the graphs of n vs n, n vs log n, n vs n2, n vs n log n, n
vs n2log n, or n vs n3, which are all increasing func�ons of n
GRAPH:
Q3.
To implement the isConcavePolygon algorithm, we can use the following steps:
Iterate over each vertex in the polygon and calculate the cross product of the vectors formed by the
current vertex and its adjacent ver�ces.
If any of the cross products have the same sign, the polygon is convex. Otherwise, it is concave.
The �me complexity of this algorithm can be analyzed as follows:
Itera�ng over each vertex and calcula�ng the cross product of two vectors takes constant �me, so
this step has a �me complexity of O(n).
Checking if any of the cross products have the same sign involves comparing n numbers, which takes
constant �me, so this step also has a �me complexity of O(n).
Therefore, the overall �me complexity of the isConcavePolygon algorithm is O(n), which means that
its running �me depends linearly on the input size n.
The graph of n vs T(n) for this algorithm will be a straight line. Since the �me complexity is O(n), the
graph will look similar to the graph of n vs n, but with a steeper slope. It will be less steep than the
graphs of n vs n2, n vs n log n, n vs n2log n, or n vs n3, but steeper than the graph of n vs log n.
Therefore, the �me complexity of the isConcavePolygon algorithm is O(n).
Q4.
The Graham's Scan algorithm is used to compute the convex hull of a set of points. The algorithm
proceeds as follows:
Find the point with the lowest y-coordinate (and the lowest x-coordinate if there is a �e) and
designate it as the "pivot" point.
Sort the remaining points by polar angle with respect to the pivot point. If two points have the same
polar angle, discard the one that is farther from the pivot point.
Iterate over the sorted points and use a stack to keep track of the "upper hull" of the convex polygon.
For each point:
a. Pop points from the stack un�l the top two points and the current point form a right turn (i.e., the
cross product of the two vectors formed by the points is posi�ve).
b. Push the current point onto the stack.
Repeat step 3 in reverse order to compute the "lower hull" of the convex polygon.
Combine the upper and lower hulls to obtain the convex hull.
The �me complexity of this algorithm can be analyzed as follows:
Finding the point with the lowest y-coordinate (and the lowest x-coordinate if there is a �e) can be
done by itera�ng over all the points once, which takes O(n) �me.
Sor�ng the remaining points by polar angle with respect to the pivot point takes O(n log n) �me
using an efficient sor�ng algorithm like quicksort or mergesort.
Itera�ng over the sorted points and using a stack to compute the upper and lower hulls takes O(n)
�me, since each point is pushed and popped from the stack at most once.
Combining the upper and lower hulls takes O(n) �me, since each point in the two hulls is added to
the final convex hull exactly once.
Therefore, the overall �me complexity of the convexHull algorithm is O(n log n), dominated by the
sor�ng step.
The graph of n vs T(n) for this algorithm will be a curve that grows faster than a straight line but
slower than a parabola. It will be steeper than the graph of n vs n log n but flater than the graph of n
vs n2. Therefore, the �me complexity of the convexHull algorithm is O(n log n).
GRAPH:

More Related Content

Similar to Geometric_algo.pdf

Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Charlton Inao
 
Graph applications chapter
Graph applications chapterGraph applications chapter
Graph applications chapterSavit Chandra
 
Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Charlton Inao
 
Newton cotes integration method
Newton cotes integration  methodNewton cotes integration  method
Newton cotes integration methodshashikant pabari
 
tw1979 Exercise 1 Report
tw1979 Exercise 1 Reporttw1979 Exercise 1 Report
tw1979 Exercise 1 ReportThomas Wigg
 
1 Lab 3 Newton’s Second Law of Motion Introducti.docx
1 Lab 3 Newton’s Second Law of Motion  Introducti.docx1 Lab 3 Newton’s Second Law of Motion  Introducti.docx
1 Lab 3 Newton’s Second Law of Motion Introducti.docxmercysuttle
 
An Introduction to Elleptic Curve Cryptography
An Introduction to Elleptic Curve CryptographyAn Introduction to Elleptic Curve Cryptography
An Introduction to Elleptic Curve CryptographyDerek Callaway
 
Hormann.2001.TPI.pdf
Hormann.2001.TPI.pdfHormann.2001.TPI.pdf
Hormann.2001.TPI.pdfssuserbe139c
 
Introduction to Digital Signal Processing (DSP) - Course Notes
Introduction to Digital Signal Processing (DSP) - Course NotesIntroduction to Digital Signal Processing (DSP) - Course Notes
Introduction to Digital Signal Processing (DSP) - Course NotesAhmed Gad
 
Calculus academic journal (sample)
Calculus academic journal (sample)Calculus academic journal (sample)
Calculus academic journal (sample)Vincentius Soesanto
 
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 

Similar to Geometric_algo.pdf (20)

Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05
 
Graph applications chapter
Graph applications chapterGraph applications chapter
Graph applications chapter
 
Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05
 
Newton cotes integration method
Newton cotes integration  methodNewton cotes integration  method
Newton cotes integration method
 
Geometric algorithms
Geometric algorithmsGeometric algorithms
Geometric algorithms
 
Signals and Systems Assignment Help
Signals and Systems Assignment HelpSignals and Systems Assignment Help
Signals and Systems Assignment Help
 
tw1979 Exercise 1 Report
tw1979 Exercise 1 Reporttw1979 Exercise 1 Report
tw1979 Exercise 1 Report
 
1 Lab 3 Newton’s Second Law of Motion Introducti.docx
1 Lab 3 Newton’s Second Law of Motion  Introducti.docx1 Lab 3 Newton’s Second Law of Motion  Introducti.docx
1 Lab 3 Newton’s Second Law of Motion Introducti.docx
 
cupdf.com_control-chap7.ppt
cupdf.com_control-chap7.pptcupdf.com_control-chap7.ppt
cupdf.com_control-chap7.ppt
 
Stochastic Processes Assignment Help
Stochastic Processes Assignment HelpStochastic Processes Assignment Help
Stochastic Processes Assignment Help
 
An Introduction to Elleptic Curve Cryptography
An Introduction to Elleptic Curve CryptographyAn Introduction to Elleptic Curve Cryptography
An Introduction to Elleptic Curve Cryptography
 
Hormann.2001.TPI.pdf
Hormann.2001.TPI.pdfHormann.2001.TPI.pdf
Hormann.2001.TPI.pdf
 
Computer Network Assignment Help
Computer Network Assignment HelpComputer Network Assignment Help
Computer Network Assignment Help
 
Brute force
Brute forceBrute force
Brute force
 
Parallel algorithm in linear algebra
Parallel algorithm in linear algebraParallel algorithm in linear algebra
Parallel algorithm in linear algebra
 
Wang1998
Wang1998Wang1998
Wang1998
 
Introduction to Digital Signal Processing (DSP) - Course Notes
Introduction to Digital Signal Processing (DSP) - Course NotesIntroduction to Digital Signal Processing (DSP) - Course Notes
Introduction to Digital Signal Processing (DSP) - Course Notes
 
Calculus academic journal (sample)
Calculus academic journal (sample)Calculus academic journal (sample)
Calculus academic journal (sample)
 
Control chap7
Control chap7Control chap7
Control chap7
 
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
 

Recently uploaded

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

Geometric_algo.pdf

  • 1. Q1. To implement the TwoLineSegmentIntersect algorithm, we can use the following steps: 1. Calculate the slope of each line segment. 2. Calculate the y-intercept of each line segment. 3. If both line segments are ver�cal, check if they overlap on the x-axis. 4. If one or both line segments are not ver�cal, calculate the intersec�on point of the two lines. 5. Check if the intersec�on point is within both line segments. The �me complexity of this algorithm can be analyzed as follows: 1. Calcula�ng the slope and y-intercept of each line segment takes constant �me, so this step has a �me complexity of O(1). 2. Checking if both line segments are ver�cal takes constant �me, so this step also has a �me complexity of O(1). 3. Calcula�ng the intersec�on point of two non-ver�cal line segments involves solving a system of two linear equa�ons, which can be done in O(1) �me using Cramer's rule. Therefore, this step has a �me complexity of O(1). 4. Checking if the intersec�on point is within both line segments takes constant �me, so this step also has a �me complexity of O(1). Therefore, the overall �me complexity of the TwoLineSegmentIntersect algorithm is O(1), which means that its running �me does not depend on the input size n. Since the �me complexity is constant, the graph of n vs T(n) will be a horizontal line at some constant value. Therefore, it cannot be compared with the graphs of n vs n, n vs log n, n vs n2, n vs n log n, n vs n2log n, or n vs n3, which are all increasing func�ons of n. GRAPH:
  • 2. Q2. To implement the isTriangle algorithm, we can use the following steps: Calculate the distance between P1 and P2. Calculate the distance between P2 and P3. Calculate the distance between P3 and P1. Check if any two of the calculated distances are greater than the third distance. If so, the three points form a triangle. Otherwise, they do not. The �me complexity of this algorithm can be analyzed as follows: Calcula�ng the distance between two points involves compu�ng the square root of the sum of the squares of the differences between their x and y coordinates. This opera�on takes constant �me, so each of the three distance calcula�ons has a �me complexity of O(1). Checking if any two of the calculated distances are greater than the third distance involves comparing three numbers, which takes constant �me, so this step also has a �me complexity of O(1).
  • 3. Therefore, the overall �me complexity of the isTriangle algorithm is O(1), which means that its running �me does not depend on the input size n. Since the �me complexity is constant, the graph of n vs T(n) will be a horizontal line at some constant value. Therefore, it cannot be compared with the graphs of n vs n, n vs log n, n vs n2, n vs n log n, n vs n2log n, or n vs n3, which are all increasing func�ons of n GRAPH: Q3. To implement the isConcavePolygon algorithm, we can use the following steps: Iterate over each vertex in the polygon and calculate the cross product of the vectors formed by the current vertex and its adjacent ver�ces. If any of the cross products have the same sign, the polygon is convex. Otherwise, it is concave. The �me complexity of this algorithm can be analyzed as follows: Itera�ng over each vertex and calcula�ng the cross product of two vectors takes constant �me, so this step has a �me complexity of O(n). Checking if any of the cross products have the same sign involves comparing n numbers, which takes constant �me, so this step also has a �me complexity of O(n).
  • 4. Therefore, the overall �me complexity of the isConcavePolygon algorithm is O(n), which means that its running �me depends linearly on the input size n. The graph of n vs T(n) for this algorithm will be a straight line. Since the �me complexity is O(n), the graph will look similar to the graph of n vs n, but with a steeper slope. It will be less steep than the graphs of n vs n2, n vs n log n, n vs n2log n, or n vs n3, but steeper than the graph of n vs log n. Therefore, the �me complexity of the isConcavePolygon algorithm is O(n). Q4. The Graham's Scan algorithm is used to compute the convex hull of a set of points. The algorithm proceeds as follows: Find the point with the lowest y-coordinate (and the lowest x-coordinate if there is a �e) and designate it as the "pivot" point. Sort the remaining points by polar angle with respect to the pivot point. If two points have the same polar angle, discard the one that is farther from the pivot point. Iterate over the sorted points and use a stack to keep track of the "upper hull" of the convex polygon. For each point: a. Pop points from the stack un�l the top two points and the current point form a right turn (i.e., the cross product of the two vectors formed by the points is posi�ve). b. Push the current point onto the stack. Repeat step 3 in reverse order to compute the "lower hull" of the convex polygon. Combine the upper and lower hulls to obtain the convex hull. The �me complexity of this algorithm can be analyzed as follows: Finding the point with the lowest y-coordinate (and the lowest x-coordinate if there is a �e) can be done by itera�ng over all the points once, which takes O(n) �me. Sor�ng the remaining points by polar angle with respect to the pivot point takes O(n log n) �me using an efficient sor�ng algorithm like quicksort or mergesort. Itera�ng over the sorted points and using a stack to compute the upper and lower hulls takes O(n) �me, since each point is pushed and popped from the stack at most once. Combining the upper and lower hulls takes O(n) �me, since each point in the two hulls is added to the final convex hull exactly once. Therefore, the overall �me complexity of the convexHull algorithm is O(n log n), dominated by the sor�ng step.
  • 5. The graph of n vs T(n) for this algorithm will be a curve that grows faster than a straight line but slower than a parabola. It will be steeper than the graph of n vs n log n but flater than the graph of n vs n2. Therefore, the �me complexity of the convexHull algorithm is O(n log n). GRAPH: