Find the bug in the following code to insert a value into an ordered linked list:
void insert(lnode*& curr, int val) {
if (curr == NULL)
curr = new lnode(val, NULL);
else if (lnode->val > val)
curr = new lnode(val, curr->next);
else {
curr = curr->next;
insert(curr, val);
}
}
Submit the code after correcting the bug.
Details
Technical Specifications: C++ programming language should be used
Type of issue: Single
Time Limit: 4 days
Directory Structure
Name your cpp file as .cpp and save it inside 'algorithms' --> 'insertion_ll' folder.
Add your code file inside this folder.
Eg path: algorithms/insertion_ll/Sharanya.cpp
Note
Please claim the issue first by commenting here before starting to work on it.
Description
Find the bug in the following code to insert a value into an ordered linked list:
Submit the code after correcting the bug.
Details
Technical Specifications: C++ programming language should be used Type of issue: Single Time Limit: 4 days
Directory Structure
Name your cpp file as.cpp and save it inside 'algorithms' --> 'insertion_ll' folder.
Add your code file inside this folder.
Eg path:
algorithms/insertion_ll/Sharanya.cpp
Note
Please claim the issue first by commenting here before starting to work on it.