-
Notifications
You must be signed in to change notification settings - Fork 172
Added Trie Logic #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Trie Logic #86
Conversation
def __init__(self): | ||
self.start = trienode('') | ||
def insert(self,id,data): # returns true on successful insertion (data == password) | ||
temp = self.start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an appropriate variable name for temp
Refer to - https://www.quora.com/Why-is-using-a-variable-name-temp-considered-bad-practice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the variable name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name is still temp
. Please change it to something meaningful @GajeshS
data-structures/trie/trie.py
Outdated
class trie: # use case: username/password | ||
def __init__(self): | ||
self.start = trienode('') | ||
def insert(self,id,data): # returns true on successful insertion (data == password) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use key
instead of data
as a variable name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the variable name
data-structures/trie/trie.py
Outdated
return True | ||
def findNode(self,id): # returns false if node doesn't exist and true, node if it does | ||
temp = self.start | ||
for x in id: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use appropriate variable name for variable x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
data-structures/trie/trie.py
Outdated
t.insert('test2',"dummy2") | ||
print(t.findNode('test')) # (false,None) | ||
a,b = t.findNode('test1') | ||
print(a,b) # (true,memref) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of printing a memref
use an appropriate message.
Refer to - https://www.geeksforgeeks.org/trie-insert-and-search/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments. Going forward, kindly request you to use meaningful and appropriate variable names.
Also, to understand the significance behind meaningful names
Please read chapter 2 of the book - Clean Code
Refer to https://github.com/SaikrishnaReddy1919/MyBooks/blob/master/%5BPROGRAMMING%5D%5BClean%20Code%20by%20Robert%20C%20Martin%5D.pdf
@GajeshS |
Hey, |
Please address all the review comments @GajeshS |
def __init__(self): | ||
self.start = trienode('') | ||
def insert(self,id,data): # returns true on successful insertion (data == password) | ||
temp = self.start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name is still temp
. Please change it to something meaningful @GajeshS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename temp
#67 Added logic for Trie for use cases such as storing username/password.