3 double func3 Ciut [] A)E ine coune = Oi int sum Randam prng = new RandomeC); Cire izo; coure <2588i
I am confusing about the worst time case complexity for these two questions.
More precisely, I am confused about the complexity of the if-statement.
first nested loop complexity will just have constant times
over summation of i=0 to n-1, which results in n
inner loop will have summation of j=0 to n-2, which results in n-1
so I might conclude this is constant operation * n * (n-1) * complexity of if-statement.
this would go similar with second problem too,
would this if statements that does constant amount of work such like count++ according to conditions will be Theta(1) for the worst case time running? or will it be something else?
Would be glad to know how this works step by step, thank you.
![3 double func3 Cint [] A)E
ine coune = oi
int sum
Randam prng
= new Random();
for
Cive iz0; coure <2588 i <A, leryth; itt) {
if (prng. next Double C <0,5)E
Coure tt i
Sum t= A Ti];
return Sum / 25.0;](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd8eb46cb-dfe9-4e1a-ae9b-bfcabdf884c9%2F9d83570d-61ed-4344-b223-c7e67a7f88da%2Ftyow6z_processed.png&w=3840&q=75)
![2 int func2 [int[] AlE
int coune = O;
for Cine íz O; i< A.lengths itt){
for Cine j20; j <A.length-Lijtt){
if li !=j &ļ ACij == Ai;])E.
Coune tti
3
reeurn coune's](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd8eb46cb-dfe9-4e1a-ae9b-bfcabdf884c9%2F9d83570d-61ed-4344-b223-c7e67a7f88da%2Fy0qfwcc_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)