Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Node
- {
- public int data;
- public Node link;
- public static Node oddEvenList (int[] ar)
- {
- Node first;
- }
- public static Node insertNode(Node root, int nextNode)
- {
- Node temp = new Node();
- Node node;
- temp.data = nextNode;
- temp.link = null;
- if (root == null)
- {
- root = temp;
- }
- else
- {
- node = root;
- while (node.next != null)
- node = node.next;
- node.next = temp;
- }
- return root;
- }
- public static Node toList (int[] ar)
- {
- Node root = null;
- for (int i = 0; i < ar.length; i++)
- root = insertNode(root, arr[i]);
- return root;
- }
- }
- public static void main(String[] args)
- {
- int[] ar = {4,16,8,5,24,17,25};
- Node root = toList(ar);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement