Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 8619672a by MARCHE Claude

### add new file for verifythis challenge1 (not syntactically correct yet)

parent e40a14af
 (* Longest Common Prefix (LCP) - 45 minutes VERIFICATION TASK ----------------- Longest Common Prefix (LCP) is an algorithm used for text querying. In the following, we model text as an integer array. You may use other representations (e.g., Java Strings), if your system supports them. LCP can be implemented with the pseudocode given below. Formalize and verify the following informal specification for LCP. Input: an integer array a, and two indices x and y into this array Output: length of the longest common prefix of the subarrays of a starting at x and y respectively. Pseudocode: int lcp(int[] a, int x, int y) { int l = 0; while (x+l s.a[y + !l] then 1 else absurd let sort (s:suffixArray) (data : array int) = for i = 0 to data.length do let j = ref i in while j > 0 && compare s data[!j-1] data[!j] > 0 do let b = !j - 1 in let t = data[!j] in data[!j] <- data[b]; data[b] <- t; decr j done done let test1 () = int[] arr = {1,2,2,5}; let sa = create_suffixArray arr in let x = lcp sa 1 2 in assert {x = ?}; int[] brr = {1,2,3,5}; let sa = create_suffixArray brr in let x = lcp sa 1 2 in assert {x = ?}; int[] crr = {1,2,3,5}; let sa = create_suffixArray crr in let x = lcp sa 2 3 in assert {x = ?}; int[] drr = {1,2,3,3}; let sa = create_suffixArray drr in let x = lcp sa 2 3 in assert {x = ?} end module LRS private static int solStart = 0; private static int solLength = 0; private static int[] a; public static void main(String[] args) { a = new int[args.length]; for (int i=0; i"+solLength); } public static void doLRS() { SuffixArray sa = new SuffixArray(a); for (int i=1; i < a.length; i++) { int length = sa.lcp(i); if (length > solLength) { solStart = sa.select(i); solLength = length; } } } end //Based on code by Robert Sedgewick and Kevin Wayne.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!