Calculate the time complexity of the given question

By analysis rule

voidfunc() {

int x = 0 i = 0 j=1;

cout<< "Enter an Integer value";

cin>>n;

while (i<n] {

x //

i++;

}

while (j<n){

}

}

hp

The time complexity of the given code can be analyzed as follows:

1. The first while loop runs for n times as the value of i increments from 0 to n-1. Therefore, the time complexity of the first while loop is O(n).

2. The second while loop also runs for n times as the value of j increments from 1 to n. Therefore, the time complexity of the second while loop is also O(n).

3. Since the two loops are independent and not nested, we can add their time complexities to get the overall time complexity. Therefore, the overall time complexity of the given code is O(n) + O(n) = O(2n) = O(n).

Therefore, the time complexity of the given code is O(n).