Merge branch 'Lazeeez' of https://github.com/Lazeeez/C-Plus-Plus into Lazeeez

This commit is contained in:
Lajat5
2021-11-06 09:21:50 +00:00
2 changed files with 33 additions and 31 deletions

View File

@@ -225,13 +225,11 @@
## Numerical Methods ## Numerical Methods
* [Bisection Method](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/bisection_method.cpp) * [Bisection Method](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/bisection_method.cpp)
* [Brent Method Extrema](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/brent_method_extrema.cpp) * [Brent Method Extrema](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/brent_method_extrema.cpp)
* [Composite Simpson Rule](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/composite_simpson_rule.cpp)
* [Durand Kerner Roots](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/durand_kerner_roots.cpp) * [Durand Kerner Roots](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/durand_kerner_roots.cpp)
* [False Position](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/false_position.cpp) * [False Position](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/false_position.cpp)
* [Fast Fourier Transform](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/fast_fourier_transform.cpp) * [Fast Fourier Transform](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/fast_fourier_transform.cpp)
* [Gaussian Elimination](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/gaussian_elimination.cpp) * [Gaussian Elimination](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/gaussian_elimination.cpp)
* [Golden Search Extrema](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/golden_search_extrema.cpp) * [Golden Search Extrema](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/golden_search_extrema.cpp)
* [Inverse Fast Fourier Transform](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/inverse_fast_fourier_transform.cpp)
* [Lu Decompose](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/lu_decompose.cpp) * [Lu Decompose](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/lu_decompose.cpp)
* [Lu Decomposition](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/lu_decomposition.h) * [Lu Decomposition](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/lu_decomposition.h)
* [Midpoint Integral Method](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/midpoint_integral_method.cpp) * [Midpoint Integral Method](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/numerical_methods/midpoint_integral_method.cpp)

View File

@@ -165,8 +165,10 @@ std::vector<Point> convexHull(std::vector<Point> points, uint64_t size) {
m++; // Update size of modified array m++; // Update size of modified array
} }
// If modified array of points has less than 3 points, convex hull is not possible // If modified array of points has less than 3 points, convex hull is not
if (m < 3) return {}; // possible
if (m < 3)
return {};
// Create an empty stack and push first three points to it. // Create an empty stack and push first three points to it.
std::stack<Point> S; std::stack<Point> S;
@@ -179,7 +181,8 @@ std::vector<Point> convexHull(std::vector<Point> points, uint64_t size) {
// Keep removing top while the angle formed by // Keep removing top while the angle formed by
// points next-to-top, top, and points[i] makes // points next-to-top, top, and points[i] makes
// a non-left turn // a non-left turn
while (S.size() > 1 && orientation(nextToTop(&S), S.top(), points[i]) != 2) { while (S.size() > 1 &&
orientation(nextToTop(&S), S.top(), points[i]) != 2) {
S.pop(); S.pop();
} }
S.push(points[i]); S.push(points[i]);
@@ -201,7 +204,8 @@ std::vector<Point> convexHull(std::vector<Point> points, uint64_t size) {
// Keep removing top while the angle formed by // Keep removing top while the angle formed by
// points next-to-top, top, and points[i] makes // points next-to-top, top, and points[i] makes
// a non-left turn // a non-left turn
while (St.size() > 1 && orientation(nextToTop(&St), St.top(), points[i]) != 2) { while (St.size() > 1 &&
orientation(nextToTop(&St), St.top(), points[i]) != 2) {
St.pop(); St.pop();
} }
St.push(points[i]); St.push(points[i]);