We also tried to write a method that found the size of a stack by only using the stack's methods. Many people found unique solutions which left us in wonder. This showed us the ubiquitous ways a programmer may approach a problem yet each solutions efficiency would still be in question.
In our first lab we tried to program a word counter that can also show us some statistics about our usage of certain words. Our TA, in his example, implemented it by using dictionaries to hold words and their frequencies. However I wanted to try a different approach so I used a duple list to store words and their frequencies. This approach had some problems that weren't encountered in the dictionary approach. First of all, as duples are immutable, when you encounter the same word again in the same content you just can't update the frequency in the duple. So I sorted my initial list of words before parsing to find frequency for each word by easily iterating over the list until I came up on a new word. Although, I'm not sure about the efficiency of my algorithm it is nice to come up with different approaches every now and then.
Til next time, take care!
No comments:
Post a Comment