sorted Array Via Linked List

Sorting elements of an array via Sorted List

Sorting elements of an array via Sorted List class Link { Link next; int value; Link(int val) { value = val; } } public class SortedArrayviaSortedList { static int arr[]; int i; Link pPrevious = null; Link pfirst; Link pCurrent = pfirst; SortedArrayviaSortedList(int arr[]) {

sorted Linked List in Java

Sorted Linked List in Java

Implementing sorted Linked List in Java class Link { public int data; public Link next; Link(int value) { data = value; } } public class SortedLinkedList { Link pfirst; Link pCurrent; Link pPrevious; public void SortedInsert(int value) { Link newLink = new Link(value); pCurrent =

queue in Java using LinkedList

Queue in Java using LinkedList

Implementing Queue in Java using LinkedList class Link { Link next; int value; Link(int val) { value = val; } } public class QueueLinkedList { Link pfirst; Link pLast; public void enqueue(int value) { Link newLink = new Link(value); if(isEmpty()) pfirst = newLink; else pLast.next

doubly list in java

Double ended List in Java

Double ended List in Java class Link { int val; Link next; Link(int value) { val = value; } public String toString() { return “{” + val + “}” ; } } public class DoublyList { Link pfirst = null; Link pLast= null; public void

print numbers without using loops

Java program to print counting without using loop

Print counting till n (40 in this case) without using loop Solution : Recursion public class PrintTillHundred { public static void main(String…s) { recurse(1); } public static void recurse(int i) { if(i>40) { System.out.println(“Number greater than 40, Program ending……….. “); return; } else { System.out.println(i);

Stack via LinkedList in java

Implementing Linked List based Stack in Java

Linked List based implementation of Stack in Java class Link { int value; Link next; Link(int val) { value = val; } } class StackLinkedList { static Link pfirst =null; public static void push( int val) { Link newLink = new Link(val); if(pfirst == null)

Linked List in Java

Singly Linked List in Java

Linked List in Java class Link { int key; int Data; Link next; //Constructor Link(int k, int d) { key = k; Data = d; } //overriding toString() method public String toString() { return “{ ” + Data + ” } “; } } public

Priority Queue in Java

Priority Queue in Java

Array based Priority Queue in java import java.util.Arrays; class Priorityy implements Comparable<Priorityy> { int size; static int front = 0; int rear = 0; static Priorityy[] arr = new Priorityy[3]; int key; String value; public Priorityy(int key, String value) { this.key = key; this.value =