3 double func3 Ciut [] A)E ine coune = Oi int sum Randam prng = new RandomeC); Cire izo; coure <2588i

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

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;
Transcribed Image Text: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;
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
Transcribed Image Text: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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education