i am not getting correct output,if any thing wrong please correct , and also point out that point.
in code, i am searching element using linear search in array.
Logical error in code
You have to pass another parameter i, which searches for the key in the array recursively.
I modified your code a bit. Check it out.
you have done another code. my query is that any thing is wrong in code or not.
i think , my code is correct because sir has taught “Recursion array is sorted” in lecture
I have done changes in your code only. Tell me if you are able to understand them.
i am understanding every thing.but i want to know about my code.correct or not
i want to know that why my code is not working .as for as i know that logic is also correct
so please tell me any thing wrong in code ,don’t give other solution
Your code is not correct because you are searching for the key element only in the first index of the array, when it can be present anywhere.
And as far as I know, arr+1 statement makes no sense because arr is an array and not an integer.
if my code is wrong then how sir has done in lecture"Recursion array is sorted" please explain
also i can increment array index
Please provide me the link of this lecture video you are talking about. I have not seen it.
Plus the code which I have sent you is correct and linear search using recursion is done in that way only.
i don’t want to print index number, my motive is number is present or not only
The code which I have provided to you only prints whether the number is present or not. There is nothing wrong in that. And that is how it should be done.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.