I am trying to write a psuedocode for finding five words in a list from a text pattern that whether they exist in the text or not and if they do write their count and occurrences. I have written a psuedocode based on naïve pattern search algo but the problem is it only finds single pattern in a string not a list of words. how can I do that? ]]>

I've been trying to figure out a divide and conquer algorithm to find the minimum element in an array with O(N) complexity.

this code i found on stackoverflow but dont understand at all:

Code:

`private static int smallest(int[] array, int from, int to) {`

if (from == to) {

return array[from];

}

int middle = from + (to - from) / 2;

return Math.min(smallest(array, from, middle), smallest(array, middle + 1, to));

}

public static int smallest(int[] array){

return smallest(array, 0, array.length - 1);

}

If so, I should note this, also.

Would an approach where the first element of the array that isn't null is removed then set to null and compared to the next element of the array being set to null, by the recursive call of the function be considered a divide and conquer algorithm ? i believe this would be done in O(n) time complexity.

could someone explain to me please? ]]>

The main content of this task is that we are given n invervals [a; b] and number k. We have to find the maximum common range of any k intervals and print the indexes of intervals, that have maximum common range, to output.

https://i.stack.imgur.com/6aRxz.png

On the left side is an input - the first 2 numbers are respectively n - number of intervals, and k - number of any intervals having a maximum common range. The next n lines have 2 numbers a and b and they are representing the interval [a; b].

On the right side is and output. The first line contains the range of maximum interval. The next line contain k indexes of intervals that have maximum common range. The indexes are as follows:

3 8 -> index 1

4 12 -> index 2

2 6 -> ...

...

1 ≤ k ≤ n ≤ 1000000

1 ≤ a < b ≤ 10^9

The avaible memory is only 128 MB, so I can't implement interval tree for this task.

The problem is I have no idea how to implement a fast algorithm. Is anyone able to write a fast algorithm for this task?

Sorry for bad English :) ]]>