Saved Bookmarks
| 1. |
A linked list is formed from the objects of the class Node. The class structure of the Node is given below :class Node{int n;Node link;}Write an Algorithm OR a Method to search for a number from an existing linked list. The method declaration is as follows : |
|
Answer» class Node { int n; Node link; void FindNode (Node str, int b) { Node t; t = str; while (t ! = null) { if (t. n = = b) { system. out. println ("Number is present in linked list"); system. exit(0); } t = t. link; } system. out. println ("Number is not present in linked list"); } } |
|