240725 Section 5
- Elijah Donnelly
- Jul 25, 2024
- 1 min read
The bulk of this week was spent watching videos and lecture. We learned about Hash Tables, Tries, Queues, and Stacks.
The idea of a hash table was interesting. From what I understand, it’s a way to find value that’s stored into an array of buckets. The hash table returns different keys, and with those keys, one can quickly search the array to find the desired value.
A trie works in a similar fashion. If there’s a word that starts with “R”, we go through the array to find the “R.” Then if the next letter is “O”, we go through the second array to find the “O.” We repeat this n number of times until we find the appropriate word we’re searching for, like “roaring.” The upside to tries is that it is very, very fast. The downside to tries is the amount of data it uses is exponential. A hash table is not as fast as a trie, but it doesn’t require as much memory.
After watching all of the videos and lectures, I tackled the inheritance problem. I mostly followed along with the video, which simplified the problem. However, there was a bug in my code.
I spent a good half hour trying to understand where my memory leak was coming from. I realized that I needed to return the pointer “new_person.” Without returning it within scope, the dynamically assigned memory was not accessible, thus causing the memory leak.
コメント