0

For each part (A) (D) below, clearly indicate whether the runtime is O(log n) or O(n). Can someone please explain how this works?

```
public class Q9f
{
public static void main(String[] args)
{
int n = ...;
int[] a = new int[n];
// (A)
for (int index = 0; index < a.length; ++index)
a[index] = index;
// (B)
int index = 1;
while (index < n)
{
a[index] = a[index] + a[index-1];
index *= 2; // index is doubled
}
// (C)
for (int value: a)
System.out.println(value);
// (D)
index = n-1;
while (index > 0)
{
a[index] += 1; // add 1 to a[index]
index /= 2;
}
} // main()
} // class Q9f
```