I am facing runtime error in almost all the questions of Linked list. Due to which a few test cases are only passed.
link: https://github.com/kush1912/Data-Structures-and-Algorithms-in-C-/blob/master/LINKED%20LIST/kappend.cpp
Linked List Run time error
Hello @vidyajaykushwaha,
This happening for the case when K>N.
example:
7
1 2 2 1 8 5 6
8
In this case, the following code will try to access a memory that has not been assigned.
for(int i=0;i<n;i++)
{
runner = runner->next;
}
Hope, it would help.
Give a like, if you are satisfied.
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.