0

e.g

Here Function heapifyUp is getting called twice (I Need a single call).

return self.heapifyUp(parentIndex) if self.heapifyUp(parentIndex) != -1 else realIndex

1 Answer 1

1

Well, it's called twice because
you call it twice... :-)

To call it once, assign the result to a variable:

res = self.heapifyUp(parentIndex)
return res if res != -1 else realIndex

(BTW, you don't need the ; at the end)

Sign up to request clarification or add additional context in comments.

1 Comment

actually i am calling heapifyUp function in recursion. so i have to break somewhere else if will go on calling itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.