<commit_before>//
//  Quick.h
//  QuickSort
//
//  Created by <NAME> on 2016. 10. 3..
//  Copyright © 2016년 <NAME>. All rights reserved.
//

#ifndef Quick_h
#define Quick_h

#include "Essential.h"

int *build_dataset(FILE *fp);
int *partition(int *data_set, int p, int r);



int *build_dataset(FILE *fp){
    int *data_set;
    int read_count = 0;
    
    data_set = calloc(1, sizeof(int));
    
    while(!feof(fp)){
        int *temp_data_set;
        
        temp_data_set = realloc(data_set, (++read_count)*sizeof(int));
        data_set = temp_data_set;
        
        fscanf(fp,"%d,",&data_set[read_count-1]);
    }
    fclose(fp);
    
    return data_set;
}

int *partition(int *data_set, int p, int r){
    
    int x = data_set[r];
    
    return data_set;
}



#endif /* Quick_h */<commit_msg>Implement major functions<commit_after>//
//  Quick.h
//  QuickSort
//
//  Created by <NAME> on 2016. 10. 3..
//  Copyright © 2016년 <NAME>. All rights reserved.
//

#ifndef Quick_h
#define Quick_h

#include "Essential.h"

int *build_dataset(FILE *fp);
int partition(int *data_set, int f, int l);
int randomized_partition(int *data_set, int f, int l);
int *quick_sort(int *data_set, int f, int k);

int *build_dataset(FILE *fp)
{
    int *data_set;
    int read_count = 0;
    
    data_set = calloc(1, sizeof(int));
    
    while(!feof(fp))
    {
        int *temp_data_set;
        
        temp_data_set = realloc(data_set, (++read_count)*sizeof(int));
        data_set = temp_data_set;
        
        fscanf(fp,"%d,",&data_set[read_count-1]);
    }
    fclose(fp);
    
    return data_set;
}

int partition(int *data_set, int f, int l)
{
    int x = data_set[l];
    int i = f-1;
    int j = f;
    
    for(j=f; j+1 != i; j++)
    {
        if(data_set[j]<=x)
        {
            int swap_temp = data_set[++i];
            data_set[i] = data_set[j];
            data_set[j] = swap_temp;
        }
        int swap_temp = data_set[++i];
        data_set[i] = data_set[l];
        data_set[l] = swap_temp;
    }
    return i;
}

int randomized_partition(int *data_set, int f, int l){
    
    return partition(data_set, f, l);
}

int *quick_sort(int *data_set, int f, int k)
{
    if (f<k)
    {
        int q = partition(data_set, f, k);
        quick_sort(data_set, q, q-1);
        quick_sort(data_set, q+1, k);
    }
    return data_set;
}



#endif /* Quick_h */
{'fraction_non_alphanumeric': 0.14926624737945493, 'fraction_numerical': 0.013417190775681341, 'mean_word_length': 2.309292649098474, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2982693', 'n_tokens_mistral': 960, 'n_tokens_neox': 928, 'n_words': 214}