Vidyalelo
Data Structure · Q134

Introduction to Data Structures

Programming · Data Structure · question 134

Q134

What is the functionality of the following code? Choose the most appropriate answer. public int function() if(head == null) return Integer.MIN_VALUE; int var; Node temp = head; Node cur; while(temp.getNext() != head) cur = temp; temp = temp.getNext(); if(temp == head) var = head.getItem(); head = null; return var; var = temp.getItem(); cur.setNext(head); return var;

A.
Return data from the end of the list
B.
Returns the data and deletes the node at the end of the list
Answer
C.
Returns the data from the beginning of the list
D.
Returns the data and deletes the node from the beginning of the list

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board