Circular LinkedList in Java

前端 未结 3 713
陌清茗
陌清茗 2021-01-18 03:49

I am brushing up on my data structures by reading a book and one of the questions it asks is to build a circular Single Linked List by not using \"first\" & \"last\" po

3条回答
  •  死守一世寂寞
    2021-01-18 04:25

    Since the linked list is circular, there would be no first and last element.

    You can traverse entire list starting from any node (current in this context).

    So Node class would only have a next reference, and CircularLinkedList will have only current reference.

    Hope this helps.
    Good luck.

提交回复
热议问题