forked from HarshCasper/NeoAlgo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ricardo Prins
committed
Jun 30, 2020
1 parent
e1a6ccf
commit 89b0e0e
Showing
176 changed files
with
1,025 additions
and
969 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
3 changes: 1 addition & 2 deletions
3
C++/SubArrayWithGivenSum.cpp → C++/cp/SubArrayWithGivenSum.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
108 changes: 54 additions & 54 deletions
108
C++/longest_increasing_subsequence.cpp → C++/dp/longest_increasing_subsequence.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
//the following program finds length of longest increasing subsequence in the given array using dynamic programming | ||
//the subsequence is a part of given parent array that has same order of elements as of parent array. | ||
#include<iostream> | ||
using namespace std; | ||
|
||
int | ||
main () | ||
{ | ||
|
||
int arr[8] = { 10, 22, 9, 33, 21, 50, 41, 6 }; | ||
|
||
cout << "The elements of array are:"; | ||
|
||
for (int i = 0; i < 8; i++) | ||
{ | ||
|
||
cout << arr[i] << " "; | ||
|
||
} | ||
int n = 8; //number of elements in array | ||
int count[n]; | ||
|
||
for (int i = 0; i < n; i++) | ||
{ | ||
|
||
count[i] = 1; //initially assign every element as 1 because every element is longest increasing subsequence in itself | ||
} | ||
for (int i = 1; i < n; i++) | ||
{ //loop starts from index 1 | ||
for (int j = 0; j < i; j++) | ||
{ //next loop runs till one index less than i | ||
if (arr[i] > arr[j] && count[j] + 1 > count[i]) | ||
{ // if it finds number smaller than current ith index and it's next element in count array is greater than ith index by one | ||
count[i] = count[j] + 1; //then increment the count of ith element in count array by 1 | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
int max = 0; //initially assign max variable as 0 | ||
for (int i = 0; i < n; i++) | ||
{ | ||
|
||
if (count[i] > max) | ||
{ //if current element is larger than max | ||
max = count[i]; //assign maximum value in max variable | ||
} | ||
|
||
} | ||
|
||
cout << "\n" << "The length of longest increasing subsequence is " << max; | ||
|
||
} | ||
//the following program finds length of longest increasing subsequence in the given array using dynamic programming | ||
//the subsequence is a part of given parent array that has same order of elements as of parent array. | ||
#include<iostream> | ||
using namespace std; | ||
|
||
int | ||
main () | ||
{ | ||
|
||
int arr[8] = { 10, 22, 9, 33, 21, 50, 41, 6 }; | ||
|
||
cout << "The elements of array are:"; | ||
|
||
for (int i = 0; i < 8; i++) | ||
{ | ||
|
||
cout << arr[i] << " "; | ||
|
||
} | ||
int n = 8; //number of elements in array | ||
int count[n]; | ||
|
||
for (int i = 0; i < n; i++) | ||
{ | ||
|
||
count[i] = 1; //initially assign every element as 1 because every element is longest increasing subsequence in itself | ||
} | ||
for (int i = 1; i < n; i++) | ||
{ //loop starts from index 1 | ||
for (int j = 0; j < i; j++) | ||
{ //next loop runs till one index less than i | ||
if (arr[i] > arr[j] && count[j] + 1 > count[i]) | ||
{ // if it finds number smaller than current ith index and it's next element in count array is greater than ith index by one | ||
count[i] = count[j] + 1; //then increment the count of ith element in count array by 1 | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
int max = 0; //initially assign max variable as 0 | ||
for (int i = 0; i < n; i++) | ||
{ | ||
|
||
if (count[i] > max) | ||
{ //if current element is larger than max | ||
max = count[i]; //assign maximum value in max variable | ||
} | ||
|
||
} | ||
|
||
cout << "\n" << "The length of longest increasing subsequence is " << max; | ||
|
||
} |
File renamed without changes.
Oops, something went wrong.