https://notability.com/n/1lVb9ohIO53Azz2SNMrzZ1

Algorithm q1(A, B):
    Input: arrays A and B each containing n >= 1 integers (they both contain the same number of integers)
    Output: <unknown>

    int c = 0;
    for (int i = 0; i < n; i++) {
        int s = 0;
        for (int j = 0; j < n; j++) {
            s = s + A[0];
            for (int k = 1; k < j; k++) {
                s = s + A[k];
            }
        }
        if (B[i] == s) {
            c++;
        }
    }
    return c;

O(n^3)

Algorithm q2(A):
    Input: array A containing n >= 1 integers
    Output: <unknown>

    int select_sum = 0;
    int i = n - 1;
    while (i > 0) {
        select_sum  = select_sum + A[i];
        i = i / 2;
    }
    return select_sum;

O(log(n))

Algorithm q3(A, lo, hi):
    Input: array A containing m integers, 0 <= lo <= hi < m
    Output: <unknown>

    if (lo >= hi) 
        return;

    int value = (A[lo] + A[hi]) / 2;
    if (value > 10) {
        printf("%d %d", lo, hi);
        return;
    }
    q3(A, lo + 1, hi);

O(n)

Algorithm q4(A, lo, hi):
    Input: array A containing m integers, 0 <= lo <= hi < m
    Output: <unknown>

    if (lo + 1 >= hi) 
        return;

    int j = (lo + hi) / 2;
    if (A[lo] < A[hi]) {
        q4(A, lo, j);
        q4(A, j, hi);
    }
    else {
        q4(A, j, hi);
        q4(A, lo, j);        
    }
    for (int i = lo; i < hi; i++) {
        print("%d", A[i]);
    }

O(n*log(n))