mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 02:04:31 +08:00
docs: rename files
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
package DynamicProgramming; /**
|
package DynamicProgramming;
|
||||||
* Author : SUBHAM SANGHAI
|
|
||||||
|
/**
|
||||||
* A DynamicProgramming based solution for Edit Distance problem In Java
|
* A DynamicProgramming based solution for Edit Distance problem In Java
|
||||||
* Description of Edit Distance with an Example:
|
* Description of Edit Distance with an Example:
|
||||||
* <p>
|
* <p>
|
||||||
@ -13,37 +14,13 @@ package DynamicProgramming; /**
|
|||||||
* kitten → sitten (substitution of "s" for "k")
|
* kitten → sitten (substitution of "s" for "k")
|
||||||
* sitten → sittin (substitution of "i" for "e")
|
* sitten → sittin (substitution of "i" for "e")
|
||||||
* sittin → sitting (insertion of "g" at the end).
|
* sittin → sitting (insertion of "g" at the end).
|
||||||
* Description of Edit Distance with an Example:
|
*
|
||||||
* <p>
|
* @author SUBHAM SANGHAI
|
||||||
* Edit distance is a way of quantifying how dissimilar two strings (e.g., words) are to one another,
|
|
||||||
* by counting the minimum number of operations required to transform one string into the other. The
|
|
||||||
* distance operations are the removal, insertion, or substitution of a character in the string.
|
|
||||||
* <p>
|
|
||||||
* <p>
|
|
||||||
* The Distance between "kitten" and "sitting" is 3. A minimal edit script that transforms the former into the latter is:
|
|
||||||
* <p>
|
|
||||||
* kitten → sitten (substitution of "s" for "k")
|
|
||||||
* sitten → sittin (substitution of "i" for "e")
|
|
||||||
* sittin → sitting (insertion of "g" at the end).
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
/**Description of Edit Distance with an Example:
|
|
||||||
|
|
||||||
Edit distance is a way of quantifying how dissimilar two strings (e.g., words) are to one another,
|
|
||||||
by counting the minimum number of operations required to transform one string into the other. The
|
|
||||||
distance operations are the removal, insertion, or substitution of a character in the string.
|
|
||||||
|
|
||||||
|
|
||||||
The Distance between "kitten" and "sitting" is 3. A minimal edit script that transforms the former into the latter is:
|
|
||||||
|
|
||||||
kitten → sitten (substitution of "s" for "k")
|
|
||||||
sitten → sittin (substitution of "i" for "e")
|
|
||||||
sittin → sitting (insertion of "g" at the end).**/
|
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Edit_Distance {
|
public class EditDistance {
|
||||||
|
|
||||||
|
|
||||||
public static int minDistance(String word1, String word2) {
|
public static int minDistance(String word1, String word2) {
|
||||||
int len1 = word1.length();
|
int len1 = word1.length();
|
||||||
@ -87,8 +64,7 @@ public class Edit_Distance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Driver program to test above function
|
public static void main(String[] args) {
|
||||||
public static void main(String args[]) {
|
|
||||||
Scanner input = new Scanner(System.in);
|
Scanner input = new Scanner(System.in);
|
||||||
String s1, s2;
|
String s1, s2;
|
||||||
System.out.println("Enter the First String");
|
System.out.println("Enter the First String");
|
||||||
@ -96,8 +72,7 @@ public class Edit_Distance {
|
|||||||
System.out.println("Enter the Second String");
|
System.out.println("Enter the Second String");
|
||||||
s2 = input.nextLine();
|
s2 = input.nextLine();
|
||||||
//ans stores the final Edit Distance between the two strings
|
//ans stores the final Edit Distance between the two strings
|
||||||
int ans = 0;
|
int ans = minDistance(s1, s2);
|
||||||
ans = minDistance(s1, s2);
|
|
||||||
System.out.println("The minimum Edit Distance between \"" + s1 + "\" and \"" + s2 + "\" is " + ans);
|
System.out.println("The minimum Edit Distance between \"" + s1 + "\" and \"" + s2 + "\" is " + ans);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,13 +2,12 @@ package DynamicProgramming;
|
|||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
public class Ford_Fulkerson {
|
public class FordFulkerson {
|
||||||
Scanner scan = new Scanner(System.in);
|
|
||||||
final static int INF = 987654321;
|
final static int INF = 987654321;
|
||||||
static int V; // edges
|
// edges
|
||||||
|
static int V;
|
||||||
static int[][] capacity, flow;
|
static int[][] capacity, flow;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
@ -1,7 +1,7 @@
|
|||||||
package Misc;
|
package Misc;
|
||||||
|
|
||||||
public class heap_sort {
|
public class heap_sort {
|
||||||
public void sort(int arr[]) {
|
public void sort(int[] arr) {
|
||||||
int n = arr.length;
|
int n = arr.length;
|
||||||
|
|
||||||
// Build heap (rearrange array)
|
// Build heap (rearrange array)
|
||||||
@ -22,7 +22,7 @@ public class heap_sort {
|
|||||||
|
|
||||||
// To heapify a subtree rooted with node i which is
|
// To heapify a subtree rooted with node i which is
|
||||||
// an index in arr[]. n is size of heap
|
// an index in arr[]. n is size of heap
|
||||||
void heapify(int arr[], int n, int i) {
|
void heapify(int[] arr, int n, int i) {
|
||||||
int largest = i; // Initialize largest as root
|
int largest = i; // Initialize largest as root
|
||||||
int l = 2 * i + 1; // left = 2*i + 1
|
int l = 2 * i + 1; // left = 2*i + 1
|
||||||
int r = 2 * i + 2; // right = 2*i + 2
|
int r = 2 * i + 2; // right = 2*i + 2
|
||||||
@ -47,7 +47,7 @@ public class heap_sort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* A utility function to print array of size n */
|
/* A utility function to print array of size n */
|
||||||
static void printArray(int arr[]) {
|
static void printArray(int[] arr) {
|
||||||
int n = arr.length;
|
int n = arr.length;
|
||||||
for (int i = 0; i < n; ++i)
|
for (int i = 0; i < n; ++i)
|
||||||
System.out.print(arr[i] + " ");
|
System.out.print(arr[i] + " ");
|
||||||
|
Reference in New Issue
Block a user