-
Notifications
You must be signed in to change notification settings - Fork 207
linked list implement in python #175
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
base: master
Are you sure you want to change the base?
Conversation
self.root = None | ||
|
||
def insert(self, data): | ||
if self.root == None: |
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.
// if self.root == None, set the Node(data) as a self.root
def insert(self, data): | ||
if self.root == None: | ||
self.root = Node(data) | ||
else: |
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.
// if not, set the self.root as a temp
|
||
|
||
def search(self, data): | ||
Cur = self.root |
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.
// set the self.root as a Cur
del(temp) | ||
return True | ||
|
||
temp = temp.next |
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.
// set the temp.next as a temp
|
||
class BST(object): | ||
def __init__(self): | ||
self.root = None |
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.
// initialize the self.root
prev = temp | ||
temp = temp.right | ||
|
||
if prev.data > data: |
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.
// if previous data is bigger than data, Node(data) becomes previous left
|
||
if prev.data > data: | ||
prev.left = Node(data) | ||
else: |
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.
// if not, Node(data) becomes previous right
Submission Checklist
master
branch of the repository.Type of Change
PR Description
linked list implement in python
it has only two functions(insert, print)
Issue #174