diff --git a/theory/backtracking/brackets.cpp b/theory/backtracking/brackets.cpp new file mode 100644 index 0000000..31b520a --- /dev/null +++ b/theory/backtracking/brackets.cpp @@ -0,0 +1,41 @@ +#include +#include + +void generateBrackets(std::string output, int n, int open, int close, int i) { + + // base case + if(i==2*n) { + std::cout << output << std::endl; + return; + } + + // open + if(open> n; + + generateBrackets(output, n, 0,0,0); + +} + + + + + + diff --git a/theory/backtracking/findingSubsets.cpp b/theory/backtracking/findingSubsets.cpp index d7af2f2..3099d31 100644 --- a/theory/backtracking/findingSubsets.cpp +++ b/theory/backtracking/findingSubsets.cpp @@ -23,6 +23,30 @@ void findSubsets(char *input, char *output, int i, int j) { } +void substringsBit(std::string s1, int i) { + + int index = 0; + while(i != 0) { + int last_bit=i&1; + if(last_bit) + std::cout << s1[index]; + index++; + i = 1>>1; + } + + std::cout << std::endl; + +} + +void generateSubstring(std::string s1) { + + for(int i = 0; i < (1<