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.List; | |
import java.util.ArrayList; | |
public class Test { | |
public static void main(String []args) | |
{ | |
List<String> output = permut("ABC"); | |
System.out.println("===== Output ====="); |
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.Arrays; | |
public class QuickSort | |
{ | |
static int partitionCounter = 0; | |
public static void main(String[] args) | |
{ | |
// Test cases | |
// 1. Unsorted array with event no. of elements |
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
public class LinkedList<T> { | |
private Node<T> head; | |
// Having a tail will help in making append O(1). | |
private Node<T> tail; | |
/** | |
* Appends a value to the end of the list. | |
* |
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
public class LinkedList { | |
private Node head; | |
public static void main(String[] args) { | |
LinkedList ll = new LinkedList(); | |
ll.add(1); | |
ll.add(2); | |
ll.add(3); | |
ll.add(4); |
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
// https://www.geeksforgeeks.org/inorder-successor-in-binary-search-tree/ | |
public class BSTInorderSuccessor { | |
public static void main(String[] args) { | |
BinarySearchTree tree = new BinarySearchTree(); | |
Node n20 = new Node(20); | |
tree.insert(n20); | |
Node n8 = new Node(8); | |
tree.insert(n8); |
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
object HelloWorld { | |
def main(args: Array[String]) { | |
println("Hello Scala!") | |
// Writing scala applications | |
// The entry point of a scala application is a main method with | |
// this signature - def main(args: Array[String]) | |
// The declaration "object HelloWorld" is a way to create Signleton objects | |
// in scala. You will learn more about that later. |
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
// The Graph used in example : | |
// | |
// (A) | |
// | | |
// (B) - (H) | |
// | | | |
// (C) - (E) - (G) | |
// | | | |
// (D) (F) | |
// |
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
// The Graph used in example : | |
// | |
// (A) | |
// | | |
// (B) - (H) | |
// | | | |
// (C) - (E) - (G) | |
// | | | |
// (D) (F) | |
// |
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
// Based on - https://www.baeldung.com/java-dijkstra | |
import java.util.HashMap; | |
import java.util.HashSet; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.Map.Entry; | |
import java.util.Set; | |
public class DijkstrasAlgorithm { |
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.Arrays; | |
public class QuickSort { | |
public static void main(String[] args) { | |
int arr[] = {11,12,13,14,15,16,17,10}; | |
sort(arr, 0, arr.length-1); | |
System.out.println("Sorted Array :"+ Arrays.toString(arr)); | |
OlderNewer