Skip to content

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

linked list implement in python #175

wants to merge 2 commits into from

Conversation

highgarden7
Copy link

@highgarden7 highgarden7 commented Jun 6, 2018

Submission Checklist

  • Your pull request targets the master branch of the repository.
  • You have only one commit (if not, squash them into one commit).
  • You have read the Contributing guidelines and your changes follow them.

Type of Change

  • Bug fix
  • New implementation

PR Description

linked list implement in python
it has only two functions(insert, print)

Issue #174

Sorry, something went wrong.

self.root = None

def insert(self, data):
if self.root == None:

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:
Copy link

@kwanukwanu kwanukwanu Jun 7, 2018

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

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

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

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:

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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants