Skip to content
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

Completed preCourse-1 #2069

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PreCourse-1: completed exercises 1,2,3.
rameshavinash94 committed Jan 19, 2025
commit e4ac5f6d2eba1a265abc66e8b90c7ef1dd72febc
13 changes: 6 additions & 7 deletions Exercise_3.py
Original file line number Diff line number Diff line change
@@ -51,10 +51,7 @@ def _traverseLinkedList(self, findVal):
If the target_data is not found, it returns (None, None).
"""
tmpNode = self.head

if tmpNode.data == findVal:
return None, tmpNode

prev = None
while tmpNode:
if tmpNode.data == findVal:
return prev, tmpNode
@@ -73,9 +70,9 @@ def find(self, key):
return
prev, curr = self._traverseLinkedList(key)
if curr:
print( f"element {curr.data} found @ {curr}")
print( f"element {key} found @ {curr}")
return curr
print('element {curr.data} not found')
print( f'element {key} not found')

def remove(self, key):
"""
@@ -109,5 +106,7 @@ def printLinkedList(self):
newList.append(15)
newList.find(30)
newList.find(90)
newList.find(10)
newList.remove(10)
newList.printLinkedList()
newList.printLinkedList()
newList.find(10)