what conditions i am missing. please debug it.
link to my code - https://ide.codingblocks.com/s/247776
Run time error!
hey, i am unable to get what logic u are trying to apply to this, although some mistakes i found are:
let me just point out the mistakes
- question demands the answers in sorted order, so store the values in a global vector and sort it in the end and display
- if the vector is empty then u can print -1 that is no nodes present
- u don’t need to find the node, u can apply the same checks on the node’s value
- in ur left and right’s recursive calls u r sending i++. which sends the same value and increments for this function(the calling function), so i is never incremented in real sense and hence an infinite loop
https://ide.codingblocks.com/s/242560 reference code
hey, the error in ur code, is mentioned in my first line itself , the output has to be sorted