This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
class Dijkstra { | |
private static int minDistance(int dist[], boolean visited[]) { | |
// Initialize min value | |
int min = Integer.MAX_VALUE, min_index = -1; | |
for (int v = 0; v < dist.length; v++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A Java program for Prim's Minimum Spanning Tree (MST) algorithm. | |
// The program is for adjacency matrix representation of the graph | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
class Prim { | |
// A utility function to find the vertex with minimum key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
public class CopiarPegarBorrarDeshacer { | |
static public int append(Stack<Character> stack, String buff) { | |
int count = 0; | |
for(char c:buff.toCharArray()){ | |
stack.push(c); | |
count++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
public class Solution { | |
public static class Step { | |
public int x, y, dist; | |
public Step(int x, int y, int dist) { | |
this.x = x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Vector; | |
class Btree<T> { | |
private Node<T> root; | |
public Btree() { | |
this.root = null; | |
} | |
public Btree(Node<T> root) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; // Import the Scanner class | |
import java.util.Vector; // import the ArrayList class | |
import java.util.Collections; | |
public class VectorExample { | |
public static class Pair { | |
private int first; | |
private int second;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; // Import the Scanner class | |
import java.util.Stack; | |
public class StackExample { | |
public static void main(String[] args){ | |
int n; | |
String buff; | |
Scanner scanner = new Scanner(System.in); // Create a Scanner object | |
Stack<String> stack = new Stack<String>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; // Import the Scanner class | |
import java.util.Comparator; | |
public class HeapExample { | |
public static class Heap<Key> { | |
private Key[] data; | |
private int n; | |
private int size; | |
private Comparator cmp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; // Import the Scanner class | |
public class Main { | |
public static void main(String[] args){ | |
int n, buff; | |
Node tmp; | |
Scanner scanner = new Scanner(System.in); // Create a Scanner object | |
Queue myQueue = new Queue(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; // Import the Scanner class | |
public class Main { | |
public static void main(String[] args){ | |
int n, buff; | |
Node tmp; | |
Scanner scanner = new Scanner(System.in); // Create a Scanner object | |
Stack myStack = new Stack(); |