subject

In Big-Θ notation, analyze the running time of the following pieces of code/pseudo-code. Describe the running time as a function of the input size (here, n)

int *a = new int [10]; // new is O(1)
int size = 10;
for (int i = 0; i < n; i ++)
{
if (i == size)
{
int newsize = 3*size/2;
int *b = new int [newsize]; // new is O(1)
for (int j = 0; j < size; j ++) b[j] = a[j];
delete [] a; // delete is O(1)
a = b;
size = newsize;
}
a[i] = i*i;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:30
The "instance" relationship shows that something is an object of a
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
The gene form of a trait is called a(n) 
Answers: 2
question
Computers and Technology, 24.06.2019 11:00
In three to five sentences, describe how you can organize written information logically and sequentially
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
Your mom wants to purchase a laptop computer. she said she wants her new computer to be able to play her dvds so she can listen to music and wants to know what type of optical drives will play her disk. which type of drive should she look for?
Answers: 1
You know the right answer?
In Big-Θ notation, analyze the running time of the following pieces of code/pseudo-code. Describe th...
Questions
question
Mathematics, 08.03.2021 01:20
question
Mathematics, 08.03.2021 01:20
question
Mathematics, 08.03.2021 01:20
question
Mathematics, 08.03.2021 01:20
Questions on the website: 13722363