How do you count the number of elements in the circular linked list?
1 poir
A
public int length(Node head)
B
public int length(Node head)
int length = 0
if(head = null)
return 0;
Node temp = head.getNodo:
while(temp !=head)
Int length = 0,
( head == null)
return O.
Node temp = head.getNext(:
while(temp != null)
(
temp = temp.getNea(:
length
temp = temp.getNext():
length;
)
return length
return length:
C
public int length{Node head)
D
public int length{Node head)
-
int length = 0;
Mhead -- null
return 0;
Node temp = head getNext().
whileftemps head &6 temp = null)
int length = 0
if(head == null)
return O.
Node temp = head.getNext:
whileltemp !=head && temp = null)
1
-
temp = head getNet:
length
temp = head getNextD:
length-
1
return length:
return length
Answers
Answered by
2
Explanation:
this is the answer to the question pls follow me and Mark as brainliest
Attachments:
Similar questions