private int patition(int left, int right) {
    	Random random = new Random();
    	int pivot = random.nextInt(right-left+1) + left;
    	swap(pivot, right);
    	int currentIndex = left;
    	for(int i = left; i < right; ++i) {
    		if(memory[i] < memory[right]) {
    			swap(i, currentIndex);
    			++currentIndex;
    		}
    	}
    	swap(currentIndex, right);
    	return currentIndex;
    }