I don't have a lot of knowledge computing the complexity. Can you help estimate the complexity of the following pseudo-codes?
Algorithm 1:
Input: V1, V2 and V3 and another vector C// Vectors of size n
Output: response..
V_f = f(V1, V2, 3) // function performs simple multiplication and additions on the vector
for i in range(0,n) // loop over element in the vector
if V_f(i) != C(i)
// sort the V1(i), V2(i) and V3(i) and retrieve the middle value
// if the middle value is in a range of certain values then launch Algorithm 2
// Over the result of Algorithm 2 (using if expressions), print the response
// end and return result
Algorithm 2
Input: Sorted
Values C{1}, C{2} and C{3} and the vector C
Output: Response:
for i in range (o,n) // loop over the elements
// According to the values of C and C{i}, perform additions (using if expressions)
// end and return result
The operations inside the loops are just additions or simple tests. Also, Algorithm 2 is executed withing Algorithm1, which means I have a loop inside a loop (right?):
for i in range (n)
// operations
// for j in range (n)
// operations
So does this mean the time complexity of this algorithm is O(n^2)
? where n is the size of of the vector?
Also as a general question, if Algorithm 1 and algorithm 2 are executed in parallel, what is the overall complexity? is it the sum or the max of the complexity of each algorithm?