Question

In: Computer Science

1. State and explain the definition of big-O. 2. Explain why we use big-O to compare...

1. State and explain the definition of big-O.
2. Explain why we use big-O to compare algorithms.
3. Explain why binary search runs in O(log n) time.
4. Under what conditions is it possible to sort a list in less than O(nlog n) time?
5. List and explain the worst-case and average-case running times for each Vector method below:
(a) insert(iterator here, Object item)

(b) insertAtHead

(c) insertAtTail (aka push back)

(d) get(iterator here)

(e) get(index i)

(f) remove(iterator here)

(g) remove(index i)

(h) splice(iterator place here, iterator from here, iterator to here)
(Be sure you understand when (and why) push back runs in constant average time.)

Solutions

Expert Solution

Please post 5 question as different question,

1.

Big O notation used to determine the performance of an algorithm in the worst-case scenario.
Mathematically :
ƒ(x)={ O(g(x), if there is a xc where   x0 ( 1, ) and a k where k is constant such that

ƒ(x)<=k*g(x) for all  x>=xc   

2. Explain why we use big-O to compare algorithms.

Performance of the algorithm depends on -

1. Way of implementation

2. The number of inputs provided.

big-O notation provide the performance of an algorithm against varying input in the worst case .

That's why we consider the big-O notation

3. Explain why binary search runs in O(log n) time.

In Binary search , search always starts from middle, It checks the conditions whether to go to left or right side. Thus height of tree created is O(logn), and run-time complexity is O(logn)

4.Under what conditions is it possible to sort a list in less than O(nlog n) time?

If no of inputs to sorted is know and also maximum value in the input is known, It can be sorted in O(n) time complexity where n is the maximum element in the input.

example Bucket sort


Related Solutions

Prove the following problems. 1 .Use the definition of big O to explain why or why...
Prove the following problems. 1 .Use the definition of big O to explain why or why not 3/(x2 + 3x) = O(3). Prove your answer. 2 .Use the definition of  Θ to explain why or why not sqrt(2 + sqrt(3x)) =  Θ(x1/4). Prove your answer. 3 .Explain why 5x2 =  Θ(2x2) is true and  5x2 ~ 2x2 is not true.
1. Find the big−O, big−Ω estimate for x7y3+x5y5+x3y7. [Hint: Big-O, big- Θ, and big-Omega notation can...
1. Find the big−O, big−Ω estimate for x7y3+x5y5+x3y7. [Hint: Big-O, big- Θ, and big-Omega notation can be extended to functions in more than one variable. For example, the statement f(x, y) is O(g(x, y)) means that there exist constants C, k1, and k2 such that|f(x, y)|≤C|g(x, y)|whenever x > k1 and y > k2] 2. Find a div b and a mod b when: (a) a = 30303, b = 333 (b) a = −765432, b = 3827 3. Convert...
Why we need to use elastic limit state?
Why we need to use elastic limit state?
1. can we be fat and still be healthy? 2. State why/why not 3. Find at...
1. can we be fat and still be healthy? 2. State why/why not 3. Find at least ONE academically credible source to support your opinion AND provide a brief summary of that article.
(a) Explain the difference between big-O and big-theta, and give examples of each to show the...
(a) Explain the difference between big-O and big-theta, and give examples of each to show the difference. (b) How can we say that two functions have the same asymptotic complexity, using big-theta notation? (c) Rank the following functions in order of increasing complexity (rate of growth), and indicate which functions have the same asymptotic complexity. x2; x log(x); 2x; log(x) + 7; 92x2 + 57x + 3921; 4x; 27x2 + 8x3; 22x+5; log(x42); 3x + 12.
1. How do we know which strategic marketying tools to use and why? 2. Explain the...
1. How do we know which strategic marketying tools to use and why? 2. Explain the meaning and value of integrated marketing communications. 3. Explain with two personal example the value of a sales promotion which propted you to buy a product.
Calculate the Big-O time complexity. Show work 1. n^2 + 3n + 2 2. (n^2 +...
Calculate the Big-O time complexity. Show work 1. n^2 + 3n + 2 2. (n^2 + n)(n ^2 + π/2 ) 3. 1 + 2 + 3 + · · · + n − 1 + n
2. Describe ASK, explain how it works and why we use it:    3. Explain what...
2. Describe ASK, explain how it works and why we use it:    3. Explain what PCM does and how it works:    4. Which of the following networking device(s) block(s) broadcast traffic, thus dividing networks into separate subnets? (Hint: only OSI Network layer devices can divide networks into separate subnets): Routers, Switches, Wireless Access Points (bridges)    5. List the three types of multiplexing from the text and explain how they work: . List two network layer protocols and...
Please calculate the Big-O cost and explain how: 1) void recurX(long x) {           ...
Please calculate the Big-O cost and explain how: 1) void recurX(long x) {            if(x==0) System.out.print("*");   else { recurX(x/2); recurX(x/2); } } 2) void recurY(long y) {            if(n==0) return;            for(long i=0;i<y;i++) System.out.print("*"); recurY(n/2);        }
Match the following functions to their respective big-O notation 1. 5 + 0.001n3 + 0.025n 2....
Match the following functions to their respective big-O notation 1. 5 + 0.001n3 + 0.025n 2. 100nlog n + n5 + 100n 3. n2log n + nlog n 4. 2n + n5 + 5n 5. 100n + 0.01n2 A. O(n3) B. O(5n) C. O(n2) D. O(n5) E. O(n2log n)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT