From 5ae0374120416106dae0c2196e3bdfec9c47dec5 Mon Sep 17 00:00:00 2001 From: anebz Date: Sun, 7 Apr 2019 21:35:26 +0200 Subject: [PATCH] Updated READMEs general readme and chapter 11's algorithm --- Chapter 11 Advanced topics/README.md | 10 +++++++++- README.md | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Chapter 11 Advanced topics/README.md b/Chapter 11 Advanced topics/README.md index dd5fb53..6be1841 100644 --- a/Chapter 11 Advanced topics/README.md +++ b/Chapter 11 Advanced topics/README.md @@ -20,4 +20,12 @@ Another issue called *clustering*, a hash table with an underlying array of size ### 11.4.4. Quadratic probing and double hashing -The distance between probes doesn't have to be linear, it can be quadratic, or use another hash function to determine the probe distance. \ No newline at end of file +The distance between probes doesn't have to be linear, it can be quadratic, or use another hash function to determine the probe distance. + +## 11.5. Rabin-Karp substring search + +Searching for a substring S in a bigger string B, brute force approach takes O(s(b-s)) time, by searching through the first b - s + 1 characters in B and for ech, checking if the next s characters match S. + +If two strings are the same, they must have the same hash. But it's also possible for two different strings to have the same hash. If we efficiently precompute a hash value for each sequence of s characters within B, we can find the location of S in O(b) time. For example, hash function is sum of each character. The substring S has value of 24 for example. We go through the string B, check how many times the sum of characters is 24, and check which one (if any) are indeed equal to S. + +How to compute the hash value? If we calculate hash value of each substring, that still takes O(s(b-s)). Instead, we know that hash(s[1:4]) = hash(s[:3]) - code(s[0]) + code(s[4]). This takes O(b) time. \ No newline at end of file diff --git a/README.md b/README.md index 19c1236..2f880dc 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,18 @@ * check unique characters * check if permutation -* replace character by substring \ No newline at end of file +* replace character by substring +* Levenshtein distance +* String compression +* Matrix rotation +* String rotation +* Hash tables (chapter 7) +* Magic index (chapter 8) + +## Chapter 7 Object-oriented design + +* Hash tables + +## Chapter 8 Recursion + +* Magic index \ No newline at end of file