diff --git a/LongestSubSequence.c b/LongestSubSequence.c index bf2e7e54..6f5cf8e8 100644 --- a/LongestSubSequence.c +++ b/LongestSubSequence.c @@ -1,33 +1,6 @@ #include #include -int* longestSubsequence(int* ARRAY, int LENGTH, int**RESULT,int* leRESULT_LENGTH){ - if(LENGTH<=1){ - *RESULT=ARRAY; - *leRESULT_LENGTH=LENGTH; - - } - else{ - int PIVOT=ARRAY[0],n; - int* LongestSub=NULL; - longestSubsequence(ARRAY+1,LENGTH-1,&LongestSub,&n); - if (PIVOT<=LongestSub[0]){ - int *newArray=(int *)realloc(NULL,(n+1)*sizeof(int)); - int i; - newArray[0]=PIVOT; - for(i=1;imaxi_length){ - - maxi_length=LS_RESULT_length+1; - maxi=(int*)realloc(maxi,(maxi_length)*sizeof(int)); - maxi[0]=PIVOT; - for(i=1;iLONGEST_SUB_LENGTH){ + + LONGEST_SUB_LENGTH=TEMPORARY_ARRAY_LENGTH+1; + LONGEST_SUB=(int*)realloc(LONGEST_SUB,(LONGEST_SUB_LENGTH)*sizeof(int)); + LONGEST_SUB[0]=PIVOT; + for(i=1;i