SHARE
TWEET

Untitled

a guest Feb 14th, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Node
  2. {
  3.     public int data;
  4.     public Node link;
  5.  
  6. public static Node oddEvenList (int[] ar)
  7. {
  8.     Node first;
  9.  
  10. }
  11.  
  12. public static Node insertNode(Node root, int nextNode)
  13. {
  14.     Node temp = new Node();
  15.     Node node;
  16.     temp.data = nextNode;
  17.     temp.link = null;
  18.  
  19.     if (root == null)
  20.     {
  21.         root = temp;
  22.     }
  23.     else
  24.     {
  25.         node = root;
  26.         while (node.next != null)
  27.             node = node.next;
  28.         node.next = temp;
  29.     }
  30.     return root;
  31. }  
  32.  
  33. public static Node toList (int[] ar)
  34. {
  35.     Node root = null;
  36.     for (int i = 0; i < ar.length; i++)
  37.         root = insertNode(root, arr[i]);
  38.     return root;
  39. }
  40.  
  41. }
  42.  
  43. public static void main(String[] args)
  44. {
  45.     int[] ar = {4,16,8,5,24,17,25};
  46.     Node root = toList(ar);
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top