Great progress in the course so far! Here’s some feedback on sets to help improve your code~
Remember to pass in all of the required arguments (ex. max_size) when initializing a class object. Check your methods in Set for how you are creating sets, using Set(). Did you pass in max_size?
When you call class methods, remember to use self.name_of_method() to call it! Otherwise, it will be undefined.
Making note of time and space complexities is best practice. You will be asked to do this in interviews. I recommend doing so for your set functions :)
Your imports don’t work! Make sure your tests pass before submitting. I recommend having modules in the same file, or look into why the imports are not working. (A lot of strange import errors with all of the files!)
You are facing a logical error in your sets class! When you initialize a new set inside your union/intersection/other functions, you are not passing in any parameters. However, your Set class requires a max_size to be specified upon initialization! Either make that optional, or use it. This might have all your tests pass if the functions are implemented correctly. :)
Your set class should also allow users to have the “option” of adding a list of items during initialization —> s = Set(5, [“apple”, “orange”]).
Your set should not have a limit for how many elements can be added. It can use max size to initialize/resize the underlying hash table, but you should be able to add as many elements as you want, unless that element already exists (no duplicates). Look over your add method.
Great job on working on the challenges! Here are a couple of improvements you can make for full credit:
Strings
Refactoring: Contains, find_index, and find_all_indexes all have a lot of overlapping code. Think about how you can break this apart into helper functions OR implement functions by calling one of the required functions, such that there is no repeated code in your file.
Add a couple of unit tests for better testing! It is easier than you would think. Look through the unit test file Alan gave, and use that pattern to call your functions on some edge case inputs.
Annotate your functions for time and space complexity. What’s the big O? How much space are you using (Are you initializing a new list, new variables, etc.)?
LinkedList length method: Although this is not required, it would be good to think about how you can improve the time complexity of this function, now that you have a size property that tracks the number of elements in your list. Can it be faster?
LinkedList insert at index and replace methods currently do not pass all unit tests. Try to debug, use print statements, to see what's going on.
Feel free to come to office hours or reach out if you need help with any of these!
You need got publish your blog post for full credit! Its a great article —> just publish it!
Call Routing Project: You benchmarked time complexity for only one of the solutions. Do this for both solutions for the extra point. In addition, this will allow you to compare which solution works better! I also recommend having your second scenario also output the solution in a text file, since it is a LOT of print statements in the terminal.
Strings: refactor your code such that there is no duplicate code in the file. Is there a way you could use 1 of the three functions and use them in the other two for the same result? Or use a helper function?
I see that you annotated for time complexity. Do the same for space complexity. How much space is your function using? Are you allocating any arrays, sets, dictionaries, etc?