in python i need to make this code into this recursive code ## NON-RECURSIVE COD
ID: 3750199 • Letter: I
Question
in python i need to make this code
into this recursive code
Explanation / Answer
We need to update recursively the self._current,self._previous and self._currentIndex
def searchHelper():
if(self._current==NULL):return False
if(self._current.getData()==targetItem):return True
if(self._current.getData()>targetItem):return False
# If none of the above are true then we proceed to need node in linked list
self._previous=self._current
self._current=self._current.getNext()
self._currentIndex+=1
return searchHelper()
So our code is just doing recursion from start to end untill it reaches null or higher value it keeps on iterating and when it sees them it returns false. When it sees a number it returns true
If you have anyother doubts we can discuss in comment section
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.