betsybaileyy / core_data_structures Goto Github PK
View Code? Open in Web Editor NEWExploring the core data structures of computer science.
License: MIT License
Exploring the core data structures of computer science.
License: MIT License
Your is_subset
method is backwards. You are supposed to check if the current object (self
) is a subset of the passed in object(i.e. other_set
)
Good work on this assignment! Your tests covered a lot of typical cases and your test cases all passed.
I do feel that your tests could have covered more edge cases. One small change that would've improved the robustness of your tests would be to check self.size in more places.
Right now, your palindromes code is not taking into account edge cases such as whitespace and punctuation. It works with a sample like racecar
, but not with a sample like race car
or race.cAr
. All of there should return True
as palindromes.
Please resubmit once you have a chance to fix the above cases and work on strings.
likley_hood
variable), and it fails on bigger cases. Try adding this code at the bottom of search.py and running python3 search.py
. You can also print what the halved
variable inside the while loop at the end of it (around line 56).# List with all numbers from 0 to 999
list_1 = [i for i in range(1000)]
# Returns None on this case
print(binary_search_iterative(list_1, 665))
'LinkedQueue' object has no attribute 'size'
, which is exactly what it sounds like and needs an additional line of code somewhere (or using a linked list property once that property is implemented).height
, there is an error about variables not being declared. This is because left_len
and right_len
only get set if the if
statements are true, and they are not always true. To fix this, you can set both len
variables to 0 before the if
statements, so they are at least declared if the if
statements are ever false._find_node_iterative()
and _find_parent_node_iterative()
methods by replacing their recursive counterparts in search
and insert
. When you replace the recursive methods with the iterative ones, you'll see that all tests pass (if you fixed the bugs above). You can then narrow the bug down to one of the two recursive helpers. The one with the bugs is _find_parent_node_recursive
.None
, but you should return parent
. The goal of this first if
statement is not to only handle the case that the root does not exist. It also handles the case when you are trying to insert a node that doesn't exist yet. You can imagine that this function traverses to the spot where a node should be inserted (it does this by traversing until it hits a None
), and then returning the parent of this empty spot (the empty spot is None). Returning parent
handles the no-root case because parent is first set to None as a default argument (and it will return when node, or self.root, is None), and it handles this new case when a new node needs to be inserted. This will pass a few more tests.test_init_with_list_of_strings
, you'll see that the root's right child is None, rather than 'C'. Another hint is if you look at the tests where you search for three items, you'll see that it breaks on the third item, the item that should be the right child of the node. To fix it, check to see what node you are returning when you descend to the right child in _find_parent_node_recursive
.Good work on this, Betsy! Your code is passing all tests.
This is not required, but you might consider going back through this class and adding time/space complexity annotations for the remaining methods. Not only will this be a good review, but it will also help deepen your knowledge of how hash tables work.
I also saw that there were a few comments that were out of place (e.g. lines 123 and 124). Consider going over your file and making sure that everything is orderly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.