8/7/22, 1:29 AM
CS 3303-01 - AY2022-T5: Discussion Forum-Unit 2
CS 3303-01 Data Structures - AY2022-T5
Dashboard / My courses / CS 3303-01 - AY2022-T5 / 23 June - 29 June / _Discussion Forum Unit 2 /_Discussion Forum-Unit 2
?
Search forums
Discussion Forum Unit 2
Discussion Forum-Unit 2
# Settings
Display replies in nested form
The cut-off date for posting to this forum is reached so you can no longer post to it.
Discussion Forum-Unit 2 by Rupali Memane (Instructor) - Tuesday, 14 June 2022, 10:27 AM
Discussion Assignment
For the following problems, develop your own answers and post your answers to the discussion forum. Review the responses of at least 3 of your peers. If you find that your peer has come up with a different answer than your own, engage your peer in a dialogue to 8compare notes9 to determine where the problem lies.
If you have discovered a different way of understanding the problem or solving the problem share your approach with your peers The objective of this assignment is to collaboratively learn and develop correct results for each of the problems. Asymptotic analysis is a difficult concept to master as such we will all benefit by understanding each others perspectives.
1. Suppose that algorithm A takes 1000r steps and algorithm B takes 2 steps for a problem of size n. For what size of problem is algorithm A faster than B (meaning algorithm A has fewer steps than B)? In your answer describe not only what the answer is but how you arrived at the answer.
2. Give the upper bound (big O notation) that you can for the following code fragment, as a function of the initial value of n.
for(int i = 0; i < n; i++){ for(int j = 0; j< i; j++){ //do swap stuff, constant time
Do you think that the lower bound is likely to be the same as the answer you gave for
the upper bound? In your response state why or why not.
252 words
Permalink
Re: Discussion Forum-Unit 2 by Victor Ezekiel - Thursday, 23 June 2022, 4:52 PM
https://my.uopeople.edu/mod/forum/discuss.php?d=808719
1/60
8/7/22, 1:29 AM
CS 3303-01 - AY2022-T5: Discussion Forum-Unit 2
1. Suppose that algorithm A takes 10003_steps and algorithm B takes2 steps for a problem of size n. For what size of tl problem is algorithm A faster than B (meaning algorithm A has fewer steps than B)? In_your answer describe not only wh the answer is but how you arrived at the answer.
From the reading assignment, I understood that growth rate is described as the rate at which the cost of an algorithm grows
integer.
public class comparison_unit2 { public static void main(String[] args) { for (int n = 1; ; n++) { int algoA = (int) (1000 * Math.pow(n,3)); int algoB = (int) Math.pow(2,n); if (algoA < algoB){
System.out.println("algorithm A = System.out.println("algorithm B = break;
+ algoA); +algoB;
When n >= 24, AIgorithm A = 13824000 and B = 16777216.
2. Gi