Which Of The Following Piece Of Code Has The Functionality Of #80
Which of the following piece of code has the functionality of counting the number of elements in the 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 - Singly Linked Lists - Quiz No.1.
Which of the following piece of code has the functionality of counting the number of elements in the list?
public int length(Node head) { int size = 0; Node cur = head; while(cur!=null) { size++; cur = cur.getNext(); } return size; }
public int length(Node head) { int size = 0; Node cur = head; while(cur!=null) { cur = cur.getNext(); size++; } return size; }
public int length(Node head) { int size = 0; Node cur = head; while(cur!=null) { size++; cur = cur.getNext(); } }
public int length(Node head) { int size = 0; Node cur = head; while(cur!=null) { size++; cur = cur.getNext().getNext(); } return size; }
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