TITeja Illainakadurga.hashnode.dev·Oct 2, 2024 · 1 min readTopological Sort AlgorithmTopological sort algorithm using DFS import java.util.*; public class Main { public static class Graph { int v; int e; List<List<Integer>> arrList; public Graph(int v, int e) { this.v = v; this.e = e; arrList...00
TITeja Illainakadurga.hashnode.dev·Oct 2, 2024 · 1 min readDjikstra Algorithm in JavaDjikstra Algorithm in Java import java.util.*; public class Main { public static class Node implements Comparable<Node> { public int vertices; public int distance; public Node(int vertices, int distance) { this.vertices = vert...00
TITeja Illainakadurga.hashnode.dev·Oct 2, 2024 · 1 min readDFS and BFS on a Single GraphBFS and DFS Algorithm on a single Graph Take an Example of the below Graph import java.util.*; public class Main { public static class Graph { int v; int e; List<List<Integer>> arrList; public Graph(int v, int e) { this.v...00
TITeja Illainakadurga.hashnode.dev·Oct 2, 2024 · 1 min readQuick Sort Algorithm :Quick sort Algorithm : Time Complexity : O(n*log(n)) Space Complexity : O(1) Not a stable algorithm, Relative ordering of the elements is not guaranteed. import java.util.*; public class Main { public static void main(String[] args) { int[...00
TITeja Illainakadurga.hashnode.dev·Oct 2, 2024 · 1 min readSyntax and basic things to brush up on before starting/restarting leetcodeArrays int[] arr = new int[10]; System.out.println(arr.length); int[][] arr2 = new int[10][10]; System.out.println(arr2.length); System.out.println(arr2[0].length); Integer[] referenceArray = new Inte...00