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

m #2

Merged
merged 109 commits into from
Dec 30, 2020
Merged

m #2

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
051d4f8
Directed Cycle detection added in C++
YASH01009 Dec 12, 2020
8efb4c3
dutch national flag algo implemented
Sidhant-Gupta Dec 13, 2020
9297bd3
Dutch national flag algo implemented
Sidhant-Gupta Dec 13, 2020
81cd4b8
Add Caeser Cipher and Modified Caeser Cipher
Sejal-G Dec 14, 2020
aa38f73
Added NQueens in Java
YASH01009 Dec 14, 2020
ad0f813
Added NQueens in C++
YASH01009 Dec 14, 2020
29d8f69
Add Homophonic Cipher in C++
Sejal-G Dec 14, 2020
7d22622
Added Egg Dropping Problem
Bharati2612 Dec 14, 2020
c532a3f
Added Josephus Problem in C++
YASH01009 Dec 15, 2020
f872e3e
Merge branch 'master' into YASH01009_DCYCLE
HarshCasper Dec 15, 2020
391d589
Added all requested changes
YASH01009 Dec 15, 2020
a9d39c4
Merge remote-tracking branch 'origin/YASH01009_DCYCLE' into YASH01009…
YASH01009 Dec 15, 2020
94a9431
link to the problem added
Sidhant-Gupta Dec 15, 2020
531eb8b
formatted code
iamrajiv Dec 16, 2020
e7a7ff6
Reformat the code to make it more reusable
Sejal-G Dec 16, 2020
29b6701
Variables names changed
YASH01009 Dec 16, 2020
fb93343
Merge branch 'master' into YASH01009_NQUEENS_C++
YASH01009 Dec 16, 2020
9bd9fd0
Requested changes done
YASH01009 Dec 16, 2020
da183ca
Requested changes done
YASH01009 Dec 16, 2020
de48854
Added the solution for Count ways to N'th Stair. issue #1455
aeyshubh Dec 16, 2020
7925740
Merge pull request #11 from ShubhamPatel33/ShubhamPatel33-patch-7
aeyshubh Dec 16, 2020
b2286e8
Added solution to Staircase Problem in Readme
aeyshubh Dec 16, 2020
f960650
Merge pull request #12 from ShubhamPatel33/ShubhamPatel33-patch-8
aeyshubh Dec 16, 2020
be4ff6a
Added solution for Count ways to nth stair issue #1455
aeyshubh Dec 16, 2020
9924f9c
Merge pull request #13 from ShubhamPatel33/ShubhamPatel33-code_4
aeyshubh Dec 16, 2020
9f9f7b8
Added hyperlink to the README (#14)
aeyshubh Dec 16, 2020
d42e3e9
Updated the code
aeyshubh Dec 16, 2020
1091c75
Merge pull request #15 from ShubhamPatel33/ShubhamPatel33-patch-5-1
aeyshubh Dec 16, 2020
0195069
Added balanced paranthesis
Dec 17, 2020
d45d8b5
Fixed typo
Dec 17, 2020
712cf07
Update DirectedCycleDetection.cpp
iamrajiv Dec 17, 2020
eba6d12
Formatted the code .
aeyshubh Dec 18, 2020
c006f6a
Merge pull request #16 from ShubhamPatel33/ShubhamPatel33-patch-9
aeyshubh Dec 18, 2020
c6aeffb
Formatted code
aeyshubh Dec 18, 2020
dd2d34b
Merge pull request #17 from ShubhamPatel33/ShubhamPatel33-patch-10
aeyshubh Dec 18, 2020
6bdfbc5
isBalanced(), eg added
Dec 20, 2020
b690153
Create Interpolation_search.go
fomalhauting Dec 20, 2020
5be94f6
Delete Interpolation_search.go
fomalhauting Dec 20, 2020
9a8f2c6
vernam cipher implemented
Sidhant-Gupta Dec 20, 2020
3932851
Create interpolation_search.go
fomalhauting Dec 20, 2020
7cfb9b7
Update README.md
fomalhauting Dec 20, 2020
852acf8
Update README.md
fomalhauting Dec 20, 2020
13ddfd1
Bellmanm Ford implemented
Sidhant-Gupta Dec 20, 2020
749671e
made the specified changes
Sidhant-Gupta Dec 20, 2020
4f6ecd0
added specified changes
Sidhant-Gupta Dec 20, 2020
4840850
indentation made consistent
Sidhant-Gupta Dec 20, 2020
6179c82
bellman ford proper indentation
Sidhant-Gupta Dec 20, 2020
58431cb
Update interpolation_search.go
fomalhauting Dec 20, 2020
ba0f650
detect negative cycle and bellman ford done
Sidhant-Gupta Dec 20, 2020
777eaa9
made the specified changes
Sidhant-Gupta Dec 21, 2020
925634d
Merge branch 'master' into YASH01009_NQUEENS_C++
YASH01009 Dec 21, 2020
9d32621
Merge branch 'master' into YASH01009_JOSEPHUS
YASH01009 Dec 21, 2020
cd0c988
Changes done
YASH01009 Dec 21, 2020
dfbbbe0
Merge remote-tracking branch 'origin/YASH01009_JOSEPHUS' into YASH010…
YASH01009 Dec 21, 2020
2547058
Changes done
YASH01009 Dec 21, 2020
97b9d31
made specified changes
Sidhant-Gupta Dec 21, 2020
5d15159
Reformat the code and Resolve the changes.
Sejal-G Dec 23, 2020
151929d
Merge branch 'master' into ShubhamPatel33_mergeconf
aeyshubh Dec 23, 2020
c89c691
made specified changes and code made robust
Sidhant-Gupta Dec 23, 2020
08721eb
made specified changes and code made robust
Sidhant-Gupta Dec 23, 2020
1c0a3ef
formatted code
iamrajiv Dec 23, 2020
ee70e53
Updated readme fie in cpp folder
Sidhant-Gupta Dec 23, 2020
161385f
Merge branch 'sidhant_graphs' of https://github.com/Sidhant-Gupta/Neo…
Sidhant-Gupta Dec 23, 2020
9fbed4e
README FILE UPDATED
Sidhant-Gupta Dec 23, 2020
93186d8
Shortest Distance Between Words
ErzaTitania-2001 Dec 25, 2020
d404d2d
Update and rename GC2.java to Shortest_Dist.java
ErzaTitania-2001 Dec 25, 2020
01b12e2
Update README.md
ErzaTitania-2001 Dec 25, 2020
3b3bc6d
Merge pull request #1634 from itsIapetus/Woc_contributions
shraddhavp Dec 26, 2020
333070d
Merge pull request #1648 from Sidhant-Gupta/sidhant_graphs
shraddhavp Dec 26, 2020
596a6c9
Removed spaces between < >
ErzaTitania-2001 Dec 26, 2020
d2fc046
Shifted to stack section
Dec 26, 2020
0ab6bdc
Shifted to stack section
Dec 26, 2020
242844b
Added RatInMaze.py
Pranav016 Dec 13, 2020
4248b44
Updated RatInMaze.py
Pranav016 Dec 16, 2020
c027775
Formatted RatInMaze acc. to Pep8
Pranav016 Dec 26, 2020
6c7495a
Add .deepsource.toml
deepsourcebot Dec 27, 2020
50d8168
Merge pull request #1488 from YASH01009/YASH01009_DCYCLE
HarshCasper Dec 27, 2020
37fe0ff
Merge pull request #1501 from Pranav016/rat-in-maze
HarshCasper Dec 27, 2020
ca093f6
Merge pull request #1518 from Sidhant-Gupta/sidhant_prs
HarshCasper Dec 27, 2020
fad459c
Merge branch 'master' into YASH01009_NQUEENS_JAVA
HarshCasper Dec 27, 2020
161cc9c
Merge pull request #1531 from YASH01009/YASH01009_NQUEENS_JAVA
HarshCasper Dec 27, 2020
00d43b4
Merge pull request #1532 from Sejal-G/sejal
HarshCasper Dec 27, 2020
1ba9496
Merge pull request #1534 from YASH01009/YASH01009_NQUEENS_C++
HarshCasper Dec 27, 2020
80dc17a
[ImgBot] Optimize images
ImgBotApp Dec 27, 2020
1d685e1
Merge branch 'master' into YASH01009_JOSEPHUS
HarshCasper Dec 27, 2020
3c8ad7b
Update Shortest_Dist.java
ErzaTitania-2001 Dec 27, 2020
6ccdf40
Merge pull request #1629 from TesseractCoding/imgbot
HarshCasper Dec 27, 2020
080a9b3
Merge pull request #1633 from Sidhant-Gupta/sidhant_vernam
HarshCasper Dec 27, 2020
1674e5f
Added the beginner pitch and did required changes to readme file as well
Bharati2612 Dec 27, 2020
547017b
added Unique BST in C
rutujadhanawade Dec 27, 2020
bd1d464
removed whitespaces
iamrajiv Dec 27, 2020
cd70bf2
Added Breadth First Search in Python formatted with Pep8 (#1569)
Pranav016 Dec 27, 2020
7da6e83
Add knapsack01 (#1659)
kartikp36 Dec 27, 2020
49ddf87
Update README.md
rutujadhanawade Dec 27, 2020
ea53c98
formatted code
iamrajiv Dec 28, 2020
7f7a719
Merge pull request #1731 from rutujadhanawade/uniquebst-C
iamrajiv Dec 28, 2020
26b20c3
formatted code
iamrajiv Dec 28, 2020
2bdd98f
Merge pull request #1692 from ErzaTitania-2001/master
iamrajiv Dec 28, 2020
3cc0c94
Bellman_Ford.py added under Graphs (#1727)
charlie219 Dec 28, 2020
421b33e
Merge pull request #1559 from YASH01009/YASH01009_JOSEPHUS
shraddhavp Dec 28, 2020
3b0d285
Merge pull request #1601 from gargVader/gargVader-parenthesis
shraddhavp Dec 28, 2020
c78d73f
Merge branch 'master' into gargVader-stockspan
Dec 28, 2020
1480460
feat: Added the Slack Workspace Link
HarshCasper Dec 28, 2020
9bb3e32
Merge pull request #1767 from TesseractCoding/slack-button-add
HarshCasper Dec 28, 2020
ebf39a5
Merge pull request #1588 from ShubhamPatel33/ShubhamPatel33_mergeconf
HarshCasper Dec 29, 2020
9042a94
Added Resources README
HarshCasper Dec 29, 2020
0e9308a
Merge pull request #1711 from gargVader/gargVader-stockspan
HarshCasper Dec 29, 2020
819d0ca
Merge branch 'master' into Bharati2612_Egg
HarshCasper Dec 29, 2020
c6d6b32
Merge pull request #1551 from Bharati2612/Bharati2612_Egg
HarshCasper Dec 29, 2020
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
22 changes: 22 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version = 1

[[analyzers]]
name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"

[[analyzers]]
name = "go"
enabled = true

[analyzers.meta]
import_paths = ["github.com/TesseractCoding/NeoAlgo"]

[[analyzers]]
name = "javascript"
enabled = true

[analyzers.meta]
environment = ["nodejs"]
14 changes: 12 additions & 2 deletions C-Plus-Plus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
- [Z Algorithm](cp/zalgorithm.cpp)
- [ArraySub](cp/ARRAYSUB.cpp)
- [Suduko Solver](cp/SudukoSolver.cpp)
- [Josephus Problem](cp/Josephus.cpp)
- [NQueens](cp/NQueens.cpp)
- [Longest Subarray with Zero Sum](cp/ZeroSum.cpp)
- [Next Largest Permutation](cp/NextPermutation.cpp)

Expand Down Expand Up @@ -83,9 +85,13 @@
- [Post-order (LRN) Tree Traversal](graphs/Postorder_Traversal.cpp)
- [Pre-order (NLR) Tree Traversal](/graphs/Preorder_Traversal.cpp)
- [Prim's Algorithm](graphs/Prim_Algorithm.cpp)
- [Depth First Search Algorithm](graphs/DFS.cpp)
- [Cycle Detection in Graph](graphs/detect_cycle.cpp)
- [Cycle Detection in a Directed Graph](graphs/DirectedCycleDetection.cpp)
- [Check for bipartite graph](graphs/Check_for_bipartite_graph.cpp)
- [Toplogical Sort in Diredted Acyclic Graph (DAG)](graphs/TopologicalSort.cpp)
- [Detect Negative Cycle in Graph](graphs/DetectNegativeCycle.cpp)
- [Bellman Ford's Algorithm](graphs/BellmanFord.cpp)

## Searching

Expand Down Expand Up @@ -116,6 +122,8 @@
## Stack based problems

- [Largest rectangular area under histogram](stack/Largest_rect_area_under_histogram.cpp)
- [Check for balanced parenthesis](stack/Check_for_balanced_parenthesis.cpp)
- [Stock Span Problem](stack/Stock_span_problem.cpp)

## Machine Learning

Expand Down Expand Up @@ -150,6 +158,8 @@ _add list here_
- [Implement Floyd-Warshall Algorithm](dp/floyd_warshall.cpp)
- [Maximum Subarray Sum](dp/Max_subarray_sum(DP).cpp)
- [Rectangle Cutting Problem](dp/Rectangle_cutting.cpp)
- [Partition Problem](dp/Partition_Problem.cpp)
- [Egg Dropping Problem](dp/Egg_Dropping.cpp)
- [Wild Card Pattern Matching](dp/WildCardMatching.cpp)
- [Matrix Chain Multiplication](dp/Matrix_Chain_Multiplication.cpp)
- [Zero One Knapsack](dp/Zero_One_Knapsack.cpp)
Expand All @@ -162,6 +172,7 @@ _add list here_

- [Affine substitution Cipher](cryptography/Affine_substitution_Cipher.cpp)
- [Vigenere Cipher](cryptography/Vigenere_Cipher.cpp)
- [Vernam Cipher](cryptography/VernamCipher.cpp)

## Computational Geometry

Expand All @@ -184,5 +195,4 @@ _add list here_
- [Least Common Multiple](other/lcm.cpp)
- [Kth largest element](other/Kth_largest_element.cpp.cpp)
- [Kth smallest element](other/Kth_smallest_element.cpp)
- [Generate all Subsets](other/subsets.cpp)
- [Stock Span Problem](other/Stock_span_problem.cpp)
- [Generate all Subsets](other/subsets.cpp)
34 changes: 34 additions & 0 deletions C-Plus-Plus/cp/Josephus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
Josephus problem is a famous problem.
In each iteration we kill the every kth
person in a circular arrangement of n persons.
Find the person who is alive at the end.
0-based indexing
link to the problem : https://en.wikipedia.org/wiki/Josephus_problem
**/

#include <iostream>
using namespace std;

int solution(int n, int k) {
if (n == 1)
return 0;
return (k + solution(n - 1, k)) % n;
}

int main() {
int people, gap;
cin >> people >> gap;
cout << solution(people, gap) << '\n';
return 0;
}

/**
Input :
4 2
Output :
0

Time Complexity : O(n)
Space Complexity : O(1)
**/
71 changes: 71 additions & 0 deletions C-Plus-Plus/cp/NQueens.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
N-Queens problem is a famous problem
The paradigm used to solve the problem is backtracking
The problem is to find a way to place n queens on nXn board
such that no queen can kill the other
**/

#include <bits/stdc++.h>
using namespace std;

#define N 20

void solve(bool board[N][N], bool cols[N], bool ndiag[2*N-1], bool rdiag[2*N-1], int row, string asf, int n) {

if(row == n) {
cout << asf << '.' << '\n';
return;
}

for(int col=0; col<n; col++) {
if(cols[col] == false && ndiag[row+col] == false &&
rdiag[row-col+n-1] == false) {
// place the queen
cols[col] = true;
ndiag[row+col] = true;
rdiag[row-col+n-1] = true;
board[row][col] = true;
solve(board, cols, ndiag, rdiag, row+1, asf+to_string(row)+"-"+to_string(col)+", ", n);
// backtrack
cols[col] = false;
ndiag[row+col] = false;
rdiag[row-col+n-1] = false;
board[row][col] = false;
}
}
}

int main() {
int n;
cin >> n;

bool board[N][N];
bool cols[N];
bool ndiag[2*N-1], rdiag[2*N-1];

// initialize
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
board[i][j] = false;

// initialize that no column has a queen
for(int i = 0; i < n; i++)
cols[i] = false;

for(int i = 0; i < 2*n-1; i++) {
ndiag[i] = false;
rdiag[i] = false;
}

solve(board, cols, ndiag, rdiag, 0, "", n);
}

/**
Input :
4
Output :
0-1, 1-3, 2-0, 3-2, .
0-2, 1-0, 2-3, 3-1, .
Space Complexity : O(n^2)
Time Complexity : upperbounded by O(n^n)
**/
47 changes: 47 additions & 0 deletions C-Plus-Plus/cryptography/Caeser_Cipher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include<bits/stdc++.h>
using namespace std;

/* Encrypts the plain text message into a cipher
text by simply replacing each letter of a given
text by a letter '3' places down the alphabet. */
string encode(string plain) {

string encrypt = "";
int length = plain.length();
for(int i = 0;i < length; ++i) {
if(plain[i] <= 91) {
//uppercase letter
encrypt += char((plain[i] - 65 + 3)%26 + 65);
} else if(plain[i] > 97) {
//lowercase letter
encrypt += char((plain[i] - 97 + 3)%26 + 97);
}
}

return encrypt;
}

int main() {

string plain,encrypt;
cout<<"Enter the plain text: ";
cin>>plain;

encrypt = encode(plain);
cout<<"Cipher Text: "<<encrypt<<endl;

}

/*
Example:
Text : TESSERACTCODING
Shift: 3
Cipher: WHVVHUDFWFRGLQJ

Text : NEOALGO
Shift: 3
Cipher: QHRDOJR

Time Complexity: O(n)
Space Complexity: O(n)
*/
92 changes: 92 additions & 0 deletions C-Plus-Plus/cryptography/Homophonic_Cipher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include<bits/stdc++.h>
using namespace std;

//Mapping one plain-text alphabet to more than one cipher-text alphabet.
void mapping(vector<vector<char> > &code) {
code[0].push_back('Q');code[0].push_back('4');
code[1].push_back('W');
code[2].push_back('E');
code[3].push_back('R');
code[4].push_back('T');code[4].push_back('5');code[4].push_back('9');code[4].push_back('0');
code[5].push_back('Y');
code[6].push_back('U');
code[7].push_back('I');
code[8].push_back('O');code[8].push_back('8');
code[9].push_back('P');
code[10].push_back('A');
code[11].push_back('S');
code[12].push_back('D');
code[13].push_back('F');code[13].push_back('7');
code[14].push_back('G');code[14].push_back('2');
code[15].push_back('H');
code[16].push_back('J');
code[17].push_back('K');
code[18].push_back('L');code[18].push_back('1');
code[19].push_back('Z');code[19].push_back('6');
code[20].push_back('X');
code[21].push_back('C');
code[22].push_back('V');
code[23].push_back('B');
code[24].push_back('N');
code[25].push_back('M');
}

/* Encodes characters of plain text by one of the
several different cipher text letters using a map. */
string encode(string plain) {

vector<vector<char> >code(26);
mapping(code);
string encrypted = "";
int n = plain.length();
for(int i = 0;i < n; ++i) {
//if lowercase character
if(plain[i] >= 97) {
int num = (rand() % (code[plain[i] - 97].size()));

if(code[plain[i]-97][num] >= 65)
encrypted = encrypted+char(code[plain[i]-97][num]- 65 + 97);
else
encrypted = encrypted+code[plain[i]-97][num];
}
//uppercase letter
else {
int num = (rand() % (code[plain[i]-65].size()));
encrypted = encrypted+code[plain[i]-65][num];
}
}

return encrypted;
}

int main(){

vector<vector<char> >code(26);
mapping(code);

string plain,encrypt;
cout<<"Enter the plain text: ";
cin>>plain;

encrypt = encode(plain);
cout<<"Cipher Text: "<<encrypt<<endl;

}

/* Mapping used:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Q W E R T Y U I O P A S D F G H J K L Z X C V B N M
4 5 8 7 2 1 6
9
0

Example:
Plain Text : TESSERACTCODING
Cipher Text: 60LL5KQEZE2R87U

Plain Text : NeoAlgo
Cipher Text: 70gQsug

Time Complexity: O(n)
Space Complexity: O(1)
*/
51 changes: 51 additions & 0 deletions C-Plus-Plus/cryptography/Modified_Caeser_Cipher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include<bits/stdc++.h>
using namespace std;

/* Encrypts the plain text message into a cipher text
by simply replacing each letter of a given text by
some places down the alphabet. */
string encode(string plain, int shift) {

string encrypt = "";
int length = plain.length();
for(int i = 0;i < length; ++i) {
if(plain[i] <= 91) {
//uppercase letter
encrypt += char((plain[i] - 65 + shift)%26 + 65);
} else if(plain[i] > 97) {
//lowercase letter
encrypt += char((plain[i] - 97 + shift)%26 + 97);
}
}

return encrypt;
}

int main() {

string plain,encrypt;
int shift;
cout<<"Enter the plain text: ";
cin>>plain;

cout<<"Enter the integer key to shift: ";
cin>>shift;

encrypt = encode(plain,shift);
cout<<"Cipher Text: "<<encrypt<<endl;

}

/*
Example:
Text : TESSERACTCODING
Shift: 4
Cipher: XIWWIVEGXGSHMRK

Text : NEOALGO
Shift: 2
Cipher: PGQCNIQ

Time Complexity: O(n)
Space Complexity: O(n)
*/
Loading