Hacktoberfest-2k18 icon indicating copy to clipboard operation
Hacktoberfest-2k18 copied to clipboard

Find the bug in Insertion in Linked List code

Open sharanyakamath opened this issue 7 years ago • 2 comments

Description

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 <your_name>.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.

sharanyakamath avatar Oct 02 '18 17:10 sharanyakamath

i claim!!

PoojithaR avatar Oct 12 '18 09:10 PoojithaR

@PoojithaR please create a pull request to this repository instead of your forked repository.

mahim23 avatar Oct 12 '18 09:10 mahim23