Graph Using Adjacency List

Vertext Class public class Vertex { private Integer data; private LinkedList<Integer> edgeslist; public Vertex(Integer data) { this.data=data; this.edgeslist=new LinkedList(); } public Integer getData() { return data; } public void setData(Integer data) { this.data = data;…

Binary Search Tree

Node class public class Node { private int data; private Node left; private Node right; public Node(int data) { this.data=data; this.left=left; this.right=right; } public int getData() { return data; } public void setData(int data) {…

Binary Tree

Node Class public class Node { private int data; private Node leftChild; private Node rightChild; public Node(int data) { this.data = data; this.leftChild = null; this.rightChild = null; } public int getData() { return data;…

Tree

Node Class public class Node { private int data; private ArrayList arraylist; public Node(int data) { this.data=data; this.arraylist=new ArrayList(); } public int getData() { return data; } public void setData(int data) { this.data = data;…

Min Cost Path

Min Cost Path public class MinCostPath { public static void main(String args[]) { int a[][] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; printArray(a); System.out.println("Min Cost : " + mincostpath(a)); } private static…

Queue Using LinkedList

Queue Using LinkedList Node Class public class Node { private int data; private Node next; public Node(int data,Node next) { this.data=data; this.next=next; } public int getData() { return data; } public void setData(int data) {…

Circular Queue

Circular Queue public class CircularQueue { private int[] a; private int start = -1; private int end = -1; private int startX = -1; private int endX = -1; private int size = 0; public…

Graph Using Adjacency Matrix

Adjacency Matrix import java.util.Scanner; public class AdjacencyMatrix { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int vertex[] = new int[scanner.nextInt()]; int edges[][] = new int[vertex.length][vertex.length]; for (int i = 0; i…

Quick Sort

Quick Sort public class Quicksort { public static void main(String args[]) { int a[] = {4, 2, 3, 1, 6, 5, 0}; quicksort(a, 0, a.length - 1); printArray(a); } private static void printArray(int a[]) {…

Merge Sort

Merge Sort public class Mergesort { public static void main(String args[]) { int a[] = {4, 2, 3, 1, 6, 5, 0}; mergesort(a, 0, a.length - 1); printArray(a); } private static void printArray(int a[]) {…