File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,8 @@ if __name__ == "__main__":
142142 to store unique words and checks if a word is already in the list before
143143 adding it.
144144 Checking whether a list contains an element might require traversing the
145- whole list, which is an O(n) operation.
145+ whole list, which is an O(n) operation. As the list grows in size,
146+ the lookup time increases with the size of the list.
146147 - The ` count_unique_words1 ` and ` count_unique_words3 ` functions are faster
147148 because they ** use a set** to store unique words.
148149 Checking whether a set contains an element is an O(1) operation.
@@ -154,6 +155,7 @@ if __name__ == "__main__":
154155
155156 What we can learn from this exercise:
156157 - When processing large files, it can be good to read them line by line
158+ or in batches
157159 instead of reading the whole file into memory.
158160 - It is good to get an overview over standard data structures and their
159161 advantages and disadvantages (e.g. adding an element to a list is fast but checking whether
You can’t perform that action at this time.
0 commit comments