title: Use a linked list to implement a Priority Queue
body: <p>I have implemented a priority queue using a linked list. In this priority queue the smallest int value has the highest value and therefore by calling the remove method the smallest method will be removed.</p>
  
  <p><strong>Code for Node Class</strong></p>
  
  <pre><code>public class Node {
  
      public int iData;
      public Node next;
  
      public Node(int x) {
          iData = x;
      }
  
      public void displayNode() {
          System.out.println(iData + " ");
      }
  
  }
  </code></pre>
  
  <p><strong>Code for Link List</strong></p>
  
  <pre><code>public class LinkList {
  
      private Node first;
  
      public LinkList() {
          first = null;
      }
  
      public boolean isEmpty() {
          return first == null;
      }
  
      public void insert(int x) {
          Node newNode = new Node(x);
          Node previous = null;
          Node current = first;
  
          while (current != null &amp;&amp; x &lt; current.iData) {
              previous = current;
              current = current.next;
          }
  
          if (previous == null) {
              newNode.next = first;
              first = newNode;
          }
  
          else {
              previous.next = newNode;
              newNode.next = current;
          }
      }
  
      public Node remove() {
          Node previous = null;
          Node current = first;
          Node temp = current;
  
          while (current.next != null) {
              previous = current;
              current = current.next;
          }
  
          previous.next = null;
  
          return temp;
      }
  
      public void display() {
          Node current = first;
  
          while (current != null) {
              current.displayNode();
              current = current.next;
          }
  
          System.out.println(" ");
      }
  
  }
  </code></pre>
  
  <p><strong>Code for Priority Queue</strong></p>
  
  <pre><code>public class PriorityQ {
  
      private LinkList list;
  
      public PriorityQ() {
          list = new LinkList();
      }
  
      public void insert(int x) {
          list.insert(x);
      }
  
      public void remove() {
          list.remove();
  
      }
  
      public void displayList() {
          System.out.println("Largest Value to Smallest");
          list.display();
      }
  
  }
  </code></pre>
  
  <p>It is working fine at the moment, however i am not sure if my remove method in the link list class is the best way to go about removing elements. So i am looking for suggestions.</p>