Vidyalelo
Data Structure · Q112

Introduction to Data Structures

Programming · Data Structure · question 112

Q112

What is the functionality of the following piece of code? Select the most appropriate. public void function(int data) int flag = 0; if( head != null) Node temp = head.getNext(); while((temp != head) && (!(temp.getItem() == data))) temp = temp.getNext(); flag = 1; break; if(flag) System.out.println("success"); else System.out.println("fail");

A.
Print success if a particular element is not found
B.
Print fail if a particular element is not found
Answer
C.
Print success if a particular element is equal to 1
D.
Print fail if the list is empty

Answer: Option B

Solution

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