How Do You Count The Number Of Elements In The Circular Linked #94
How do you count the number of elements in the circular linked list?
This multiple choice question (MCQ) is related to the book/course gs gs121 Data Structures and Algorithms. It can also be found in gs gs121 Abstract Data Types - Circular Linked Lists - Quiz No.1.
How do you count the number of elements in the circular linked list?
public int length(Node head) { int length = 0; if( head == null) return 0; Node temp = head.getNext(); while(temp != head) { temp = temp.getNext(); length++; } return length; }
public int length(Node head) { int length = 0; if( head == null) return 0; Node temp = head.getNext(); while(temp != null) { temp = temp.getNext(); length++; } return length; }
public int length(Node head) { int length = 0; if( head == null) return 0; Node temp = head.getNext(); while(temp != head && temp != null) { temp = head.getNext(); length++; } return length; }
public int length(Node head) { int length = 0; if( head == null) return 0; Node temp = head.getNext(); while(temp != head && temp == null) { temp = head.getNext(); length++; } return length; }
Similar question(s) are as followings:
Online Quizzes of gs121 Data Structures and Algorithms
Binary Trees - Binary Search Tree - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Binary Search Tree - Quiz No.2
gs gs121 Data Structures and Algorithms
Online Quizzes
Binary Trees - Preorder Traversal - Quiz No.1
gs gs121 Data Structures and Algorithms
Online Quizzes