Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Union of two arrays #1794

Merged
merged 23 commits into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c760166
Create reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
cbad183
Added documentation
alvinphilips Oct 19, 2021
54143f2
Added documentation
alvinphilips Oct 19, 2021
41af1e4
Renamed tests to test
alvinphilips Oct 19, 2021
fb86292
Fixed issue with incorrect using statement
alvinphilips Oct 19, 2021
6c5794a
updating DIRECTORY.md
Oct 19, 2021
e9cd4fd
clang-format and clang-tidy fixes for fb86292d
Oct 19, 2021
b222cb2
Added Test cases
alvinphilips Oct 19, 2021
ffbbc65
Merge branch 'binary-tree' of https://github.com/polarvoid/C-Plus-Plu…
alvinphilips Oct 19, 2021
2208192
Merge branch 'master' into master
alvinphilips Oct 19, 2021
0421f55
Update operations_on_datastructures/reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
657f759
Update operations_on_datastructures/reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
aabd5a2
Update operations_on_datastructures/reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
ff091f7
Update operations_on_datastructures/reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
76255dd
Update operations_on_datastructures/reverse_binary_tree.cpp
alvinphilips Oct 19, 2021
14a26c3
Changed int to int64_t
alvinphilips Oct 19, 2021
39bb9b9
Updated documentation wording
alvinphilips Oct 19, 2021
46936a7
Merge branch 'TheAlgorithms:master' into master
alvinphilips Oct 19, 2021
1ade0de
Merge branch 'TheAlgorithms:master' into master
alvinphilips Oct 20, 2021
eb32bf7
Merge branch 'TheAlgorithms:master' into master
alvinphilips Oct 21, 2021
3954ceb
Fixed wrong integer type
alvinphilips Oct 23, 2021
2af706b
Merge branch 'master' into union-of-two-arrays
alvinphilips Oct 23, 2021
972a520
clang-format and clang-tidy fixes for 2af706b1
Oct 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions math/check_prime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
* @brief
* Reduced all possibilities of a number which cannot be prime.
* Eg: No even number, except 2 can be a prime number, hence we will increment
* our loop with i+6 jumping and check for i or i+2 to be a factor of the number;
* if it's a factor then we will return false otherwise true after the loop terminates at the terminating condition which is (i*i<=num)
* our loop with i+6 jumping and check for i or i+2 to be a factor of the
* number; if it's a factor then we will return false otherwise true after the
* loop terminates at the terminating condition which is (i*i<=num)
*/

#include <cassert> /// for assert
#include <iostream> /// for IO operations
#include <cassert> /// for assert
#include <iostream> /// for IO operations

/**
* Function to check if the given number is prime or not.
Expand All @@ -24,14 +25,13 @@ bool is_prime(T num) {
bool result = true;
if (num <= 1) {
return false;
} else if (num == 2 || num==3) {
} else if (num == 2 || num == 3) {
return true;
} else if ((num%2) == 0 || num%3 == 0) {
} else if ((num % 2) == 0 || num % 3 == 0) {
return false;
}
else {
} else {
for (T i = 5; (i * i) <= (num); i = (i + 6)) {
if ((num % i) == 0 || (num%(i+2)==0 )) {
if ((num % i) == 0 || (num % (i + 2) == 0)) {
result = false;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion operations_on_datastructures/union_of_two_arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace operations_on_datastructures {
* @returns void
*/
void print(const std::vector<int32_t> &array) {
for (int64_t i : array) {
for (int32_t i : array) {
std::cout << i << " "; /// Print each value in the array
}
std::cout << "\n"; /// Print newline
Expand Down