What are the time complexities of these two algorithms? I got 3n/2 + 6 for the first one, and 3logn + 6 for the second and I'm not sure if I'm doing them right.
int i = 0 ;
double evenSum = 0.0 ;
while ( i < n) {
evenSum = evenSum + data[i] ;
i += 2;
}
StdOut.println(evenSum);
and the second is similar it just multiples by 2
int i = 0 ;
double evenSum = 0.0 ;
while ( i < n) {
evenSum = evenSum + data[i] ;
i *= 2;
}
StdOut.println(evenSum);
and I got 3n/2 + 6 and 3log n + 6