diff --git a/DynamicProgramming/Edit_Distance.java b/DynamicProgramming/EditDistance.java similarity index 65% rename from DynamicProgramming/Edit_Distance.java rename to DynamicProgramming/EditDistance.java index e6745479f..210469b84 100644 --- a/DynamicProgramming/Edit_Distance.java +++ b/DynamicProgramming/EditDistance.java @@ -1,5 +1,6 @@ -package DynamicProgramming; /** - * Author : SUBHAM SANGHAI +package DynamicProgramming; + +/** * A DynamicProgramming based solution for Edit Distance problem In Java * Description of Edit Distance with an Example: *

@@ -13,37 +14,13 @@ package DynamicProgramming; /** * 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). + * + * @author SUBHAM SANGHAI **/ -/**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; -public class Edit_Distance { - +public class EditDistance { public static int minDistance(String word1, String word2) { 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); String s1, s2; System.out.println("Enter the First String"); @@ -96,8 +72,7 @@ public class Edit_Distance { System.out.println("Enter the Second String"); s2 = input.nextLine(); //ans stores the final Edit Distance between the two strings - int ans = 0; - ans = minDistance(s1, s2); + int ans = minDistance(s1, s2); System.out.println("The minimum Edit Distance between \"" + s1 + "\" and \"" + s2 + "\" is " + ans); } } diff --git a/DynamicProgramming/Ford_Fulkerson.java b/DynamicProgramming/FordFulkerson.java similarity index 94% rename from DynamicProgramming/Ford_Fulkerson.java rename to DynamicProgramming/FordFulkerson.java index 36100c68c..7a162fbb0 100644 --- a/DynamicProgramming/Ford_Fulkerson.java +++ b/DynamicProgramming/FordFulkerson.java @@ -2,13 +2,12 @@ package DynamicProgramming; import java.util.LinkedList; import java.util.Queue; -import java.util.Scanner; import java.util.Vector; -public class Ford_Fulkerson { - Scanner scan = new Scanner(System.in); +public class FordFulkerson { final static int INF = 987654321; - static int V; // edges + // edges + static int V; static int[][] capacity, flow; public static void main(String[] args) { diff --git a/Misc/heap_sort.java b/Misc/heap_sort.java index bb5c2365a..5222be409 100644 --- a/Misc/heap_sort.java +++ b/Misc/heap_sort.java @@ -1,7 +1,7 @@ package Misc; public class heap_sort { - public void sort(int arr[]) { + public void sort(int[] arr) { int n = arr.length; // Build heap (rearrange array) @@ -22,7 +22,7 @@ public class heap_sort { // To heapify a subtree rooted with node i which is // 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 l = 2 * i + 1; // left = 2*i + 1 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 */ - static void printArray(int arr[]) { + static void printArray(int[] arr) { int n = arr.length; for (int i = 0; i < n; ++i) System.out.print(arr[i] + " ");