2020/09/08

 public class QueueList {

    public static class Node {

        public Node next;

        private Object data;

        private Node(Object data) {

            this.data = data;

        }

    }

    private Node head; // remove from the tail

    private Node tail; // add things here

    public boolean isEmplty() {

        return head == null;

    }

    public Object peek() {

        return head.data;

    }

    public void add(Object data) {

        Node node = new Node(data);

        if (tail != null)

            tail.next = node;

        tail = node;

        if (head == null)

            head = node;

   }

    public Object remove() {

        Object temp = head.data;

        head = head.next;

        if (head == null)

            tail = null;

        return temp;

    }

}

//

public class bubbleSort{  

    static void bubbleSorted(int[] arr) {  

        int n = arr.length;  

        int temp = 0;  

         for(int i=0; i < n; i++){  

                 for(int j=1; j < (n-i); j++){  

                          if(arr[j-1] > arr[j]){  

                                 //swap elements  

                                 temp = arr[j-1];  

                                 arr[j-1] = arr[j];  

                                 arr[j] = temp;  

                         }  

                                     }  

         }  

      }  

    public static void main(String[] args) {    }  

           }  

}  

//

public class selectionSort {  

    public static void selection(int[] arr) {

        for (int i = 0; i < arr.length - 1; i++) {

            int index = i;

            for (int j = i + 1; j < arr.length; j++) {

                if (arr[j] < arr[index]) {

                    index = j;// searching for lowest index

                }

            }

            final int smallerNumber = arr[index];

            arr[index] = arr[i];

            arr[i] = smallerNumber;

        }

    }

    public static void main(final String a[]) {        }  

    }  

}  

//