Menu

[Solved]Create Java Code Creates Link List Finds Minimum Maximum Average Link List Import Javaxswi Q37231327

create a java code that creates a link list and finds a minimummaximum and average of the link list

import javax.swing.JOptionPane;

public class LinkedList
{private Node head;
   private Node tail;
   private int size;
   private int low;
   private int high;
   public LinkedList() {
       head = null;
       tail = null;
       size = 0;
       low = 0;
       high = 100; }
   public LinkedList(Node h, Node t, int s, int l, inthi) {
       head = h;
       tail = t;
       size = s;
       low = l;
       high = hi;}
   public void createList(){
       String input =JOptionPane.showInputDialog(null,”Please enter an integer <1000:”,
              “Size of LinkedList”,JOptionPane.QUESTION_MESSAGE);
   size=Integer.parseInt(input);
   System.out.println(“Size = “+size);
   input = JOptionPane.showInputDialog(null,”Please enteran integer > 0:”,
              “Lowest Value in the LinkedList”,JOptionPane.QUESTION_MESSAGE);
   low = Integer.parseInt(input);
   input = JOptionPane.showInputDialog(null,”Please enteran integer < 1000:”,
              “Highest Value in the LinkedList”,JOptionPane.QUESTION_MESSAGE);
   high = Integer.parseInt(input);
   // Create the linked list by adding the new nodes tothe end of the list
   int s = size;
   size = 0;
   for (int i=0; i<s; i++) {
       int k = low +(int)((high-low+1)*Math.random());
       addEnd(k); }
   System.out.println(“returning from createlist”+getHead()); }
   public void addBegining(int v){
       Node t = new Node();
       t.setData(v);
       t.setNext(null);
       if (head == null){
           head = t;
           tail = t;}
       else {
          t.setNext(head);
           head = t;}
       size++; }
   public void addEnd(int v)
   {
   }
   public int getMinimum()
   {
       int min = head.getData();
       Node t = head;
       while (t != null)
       {
           if (min >t.getData())
              min = t.getData();
           t =t.getNext();
       }
       return min;
   }
   public int getMaximum()
   {
      
       return 0;
   }
   public double getAverage()
   {
      
       return 0;
   }
   public boolean search(int key)
   {
              return false;
   }
   public void sort()
   {
       // ******** copy the linked list toan array, sort the array, copy it back to linked list*************
   }
   public Node getHead() { return head;}
   public Node getTail() {return tail;}
   public int getSize() { return size;}
   public int getLow() { return low;}
   public int getHigh() { return high;}
}

public class Node private int data; private Node next; public Node() data-10 next - null; public Node (int d, Node t) datad;

public class Node private int data; private Node next; public Node() data-10 next – null; public Node (int d, Node t) datad; next- t; public void setData(int v) data – v; public void setNext (Node n) next n; public int getData) return data;) public Node getNext() freturn next;) Show transcribed image text public class Node private int data; private Node next; public Node() data-10 next – null; public Node (int d, Node t) datad; next- t; public void setData(int v) data – v; public void setNext (Node n) next n; public int getData) return data;) public Node getNext() freturn next;)

Expert Answer


Answer to create a java code that creates a link list and finds a minimum maximum and average of the link list import javax.swing…. . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *