Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Empty Linked List Case #

Sumit Rawal answered on May 18, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • is head of linked list null
  • code to make a bool is empty function for singly linked lists in c++
  • What are some reasons why my linked list would appear empty after I tried reversing it?

  • Empty Linked List Case #

    0

    In the above code, we check if the linked list is empty by checking the head of the linked list. If the self.head is None on line 12, it implies that it’s an empty linked list and there’s nothing there. The head pointer doesn’t point to anything at all, and therefore there is no node in the linked list. If there is no node in the linked list, we set the head pointer to the new_node that we created on line 13. In the next line, we simply return. The case of an empty linked list is relatively easy to handle. 

    Popularity 1/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on May 18 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.