WebClub-NITK / Hacktoberfest-2k18

Repository for Hacktoberfest 2018 open for the global open source community.
https://webclub-nitk.github.io/Hacktoberfest-2k18/
19 stars 102 forks source link

Find the bug in Insertion in Linked List code #10

Open sharanyakamath opened 6 years ago

sharanyakamath commented 6 years ago

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

PoojithaR commented 6 years ago

i claim!!

mahim23 commented 6 years ago

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