We were discussing the use of object storage as a time series data store. The notion of buckets in a time-series database translates well to object storage. As one gets filled, data can start filling another. With the help of cold, warm and hot labels, it is easy to maintain progression of data. This data can then serve all the search queries over times series just like events in a time series database.
#codingexercise
Performing inversion count utilizing merge sort:
#codingexercise
Performing inversion count utilizing merge sort:
int GetCountInversionsByMergeSort(ref List<int> A, ref List<int> B, int left, int right)
{
int count = 0;
if (right > left) {
int mid = (right+left)/2;
count = GetCountInversionsByMergeSort(A, B, left, mid);
count += GetCountInversionByMergeSort(A, B, mid +1, right);
count += GetCountByMerge(A, B, left, mid+1, right);
}
return count;
}
Int GetCountByMerge(ref List<int> A, ref List<int> B, int left, int mid, int right)
{
int count = 0;
int I = left;
int j = mid;
int k = right;
while( (i<=mid-1) && (j <=right)){
if (A[i] <= A[j]) {
B[k] = A[i];
k++;
l++;
} else {
B[k] = A[j];
k++;
j++;
count = count + (mid-i);
}
}
While (I <= mid-1){
B[k] = A[i];
k++;
i++;
}
While(j <= right) {
B[k] = A[j];
j++;
k++;
}
For (int m = left; m <=right; m++)
A[m] = B[m];
return count;
}
No comments:
Post a Comment