Problems understanding concept of nodes and linked list

后端 未结 1 1551
自闭症患者
自闭症患者 2020-12-22 03:39

i am new to Data Structures and Algorithim and i am having some troubles getting around the whole topic of linked list and how its connected to nodes. The problem that is co

相关标签:
1条回答
  • 2020-12-22 04:18

    The problem that is confusing me is with pointers and what they point to?

    In java reference works as pointer to an object in memory that internally can point to another one in the same way.

    Let's try to understand it visually:

    What happens to the pointer head when the object obj is added to an empty linked list?

    In below snapshot head is a reference that point to first object in the memory and first object contains another reference next that points to second object and so on...

    enter image description here

    Write A Constructor to represent (i)

    I think that you can do it as your homework.

    Hint: (As shown in above snapshot as well)

    1. create a new node
    2. point next of new node to next of head
    3. point head to new node
    0 讨论(0)
提交回复
热议问题