You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27
Original file line number
Diff line number
Diff line change
@@ -212,6 +212,22 @@ Implementation using trees is better as we can apply union by rank and path comp
212
212
In case of linked list find takes O(n) time and union also takes O(n) time and create takes O(1) time
213
213
214
214
215
+
## Back Tracking
216
+
217
+
- Permutations means ordered combinations. Eg. My juice is made by a combination of 10 fruits (order does not matter), but in case of permutations the order does matter. Basically changing the order can change the outcome means permutations. Changing the order has no effect on outcome is combination
218
+
- Backtracking uses recursion where each call in the stack has its stored values and backtracking makes
219
+
use of those values to do decision making at a particular level in the recursion tree
220
+
221
+
## Pattern Matching
222
+
223
+
- For KMP to find all occurences of a pattern in a string, whenever the match is found, we assign the
224
+
pointer of pattern variable value that is there in the prefix suffix array at an index less then the
225
+
current value of the pointer and we start comparing again.
226
+
- Boyer-Moore algorithm is much more efficient than KMP at places where pattern to be searched has characters
227
+
as different as possible. If the characters are same, then in worst case it will give a time complexity of
228
+
O(mn) where it will end up comparing most of the characters, therefore, in case characters are mostly same
229
+
use KMP
230
+
215
231
# Topic0: Programming Questions
216
232
217
233
## Note:
@@ -439,6 +455,7 @@ In case of linked list find takes O(n) time and union also takes O(n) time and c
439
455
-[Find the sum of digits for all numbers from 1 to N for a given N](/dynamic-programming/question30.c)
440
456
-[Given a string of digits, find the length of the longest substring of a string, such that the length of the substring is '2k' digits and sum of left k digits is equal to the sum of right k digits](/dynamic-programming/question31.c)
441
457
-[Given a rod of length 'n' inches and an array of prices that contains prices of all pieces of size smaller than n, find the max value obtainable by cutting the rod and selling the pieces](/dynamic-programming/question32.c)
0 commit comments