<commit_before>#include <stdio.h>
#include <conio.h>
void display(int *ptr,int front, int back){
	int i;
	//printf("Array:\n");
	for(i=front;i<=back;i++){
		printf(" %d ",*(ptr+i));
	}
}
int partition(int *ptr,int front, int back){
	int pindex,i,temp;

	//put pivot logic(start, middle, end), this case chooses the end.
	int pivot = (back+front)/2;
		
	pindex=front;
	printf("\nPartition called\n");
	for(i=front;i<back+1;i++){
		printf("\n\n\ni:%d\n",i);
		printf("pivot index:%d, pivot value:%d\n",pivot,*(ptr+pivot));
		display(ptr,front,back);
		if(*(ptr+i)<=*(ptr+pivot)){
			temp=*(ptr+i);
			*(ptr+i)=*(ptr+pindex);
			*(ptr+pindex)=temp;
			
			
			if(i==pivot){
				pivot=pindex;
			}
			
			pindex++;
		}
		
	}
	
	//swap pivot with pindex
	if(*(ptr+pindex)<=*(ptr+pivot)){
		temp = *(ptr+pindex);
		*(ptr+pindex)=*(ptr+pivot);
		*(ptr+pivot)=temp;
		pivot=pindex-1;
	}
	if(*(ptr+pindex)>*(ptr+pivot)){
		temp = *(ptr+pindex-1);
		*(ptr+pindex-1)=*(ptr+pivot);
		*(ptr+pivot)=temp;
		pivot=pindex-1;
	}
	
	printf("\n\n\ni:%d\n",i);
	printf("pivot index:%d, pivot value:%d\n",pivot,*(ptr+pivot));
	display(ptr,front,back);
	return pivot;
}
void quicksort(int *ptr,int front, int back){
	
	int pivot;
	if(front<back){
		
		pivot = partition(ptr,front,back);
	
		quicksort(ptr,front,pivot-1);
		quicksort(ptr,pivot+1,back);
	}
}
int main(){
	int a[]={5,4,7,0,6,2,9,3,8,1};
	int preturn;
	int *p;
	p=a;
	quicksort(p,0,9);
	printf("\n\n\n\n\n\nSorted Array:\n");
	display(p,0,9);
	return 0;
}<commit_msg>optimized random quick sort<commit_after>#include <stdio.h>
#include <conio.h>
void display(int *ptr,int front, int back){
	int i;
	//printf("Array:\n");
	for(i=front;i<=back;i++){
		printf(" %d ",*(ptr+i));
	}
}
int partition(int *ptr,int front, int back){
	int pindex,i,temp;

	//change pivot logic(start, middle, end) here, this case chooses middle.
	int pivot = (back+front)/2;
		
	pindex=front;
	printf("\nPartition called\n");
	for(i=front;i<back+1;i++){
		printf("\n\n\ni:%d\n",i);
		printf("pivot index:%d, pivot value:%d\n",pivot,*(ptr+pivot));
		display(ptr,front,back);
		if(*(ptr+i)<=*(ptr+pivot)){
			temp=*(ptr+i);
			*(ptr+i)=*(ptr+pindex);
			*(ptr+pindex)=temp;
			
			
			if(i==pivot){
				pivot=pindex;
			}
			
			pindex++;
		}
		
	}
	
	//Swaping pivot to correct position
	temp = *(ptr+pindex-1);
	*(ptr+pindex-1)=*(ptr+pivot);
	*(ptr+pivot)=temp;
	pivot=pindex-1;
	
	printf("\n\n\ni:%d\n",i);
	printf("pivot index:%d, pivot value:%d\n",pivot,*(ptr+pivot));
	display(ptr,front,back);
	return pivot;
}
void quicksort(int *ptr,int front, int back){
	
	int pivot;
	if(front<back){
		
		pivot = partition(ptr,front,back);
	
		quicksort(ptr,front,pivot-1);
		quicksort(ptr,pivot+1,back);
	}
}
int main(){
	int a[]={5,4,7,0,6,2,9,3,8,1};
	int preturn;
	int *p;
	p=a;
	quicksort(p,0,9);
	printf("\n\n\n\n\n\nSorted Array:\n");
	display(p,0,9);
	return 0;
}
{'fraction_non_alphanumeric': 0.23905489923558026, 'fraction_numerical': 0.015635858234885336, 'mean_word_length': 4.494274809160306, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 8, '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': '7277881', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1284, 'n_words': 211}