1) Program A and B are analyzed and found to have worst-
case running times no greater than 150nlog2n and n2
respectively.Answer the folloWing questions if possible..
i) which program has the better guarantee on the running
time,for larger values of n(n>10000) ?
ii) which program has the better guarantee on the running
time,for small values of n(n<100) ?
iii) which program will run faster on average for n =1000
2) wRite a program to compute the number of collisions
required in a long random sequence of
insertions using linear probing ,quadratic probing and
double hashing
3) what is the optimal way to compute A1 A2 A3 A4 A5 A6
where the dimensions of the matrices are
A1:10*20 A2 : 20 * 1 A3 : 1 * 40 A4 : 40*5 A5 : 5 * 30
A6 : 30 X 15
Answer Posted / vinothkumar.r
Its clear
150nlog(base-2)n will have advantage on larger inputs
n^2 has advantage on large inputs
But without the exact function we cant estimate the exact
point at which the two graphs exchanges their advantages.
given n>2 log(base-2)n is greater than 1 where as n^2 > 150
only when n>10 so approx it crosses at may be at n=12(Taking
them as exact time complexity not as asymptotic notations)
at 1000 clearly n^2 is better as it is only 10^6 whereas
150nlogn is approx 150*10*10(approx)
| Is This Answer Correct ? | 6 Yes | 10 No |
Post New Answer View All Answers
Why do we use collections?
Can you please explain the difference between string and an array?
How do you perform a merge sort?
What is the difference between one and two dimensional?
What happens in insertion sort?
Define level of the tree?
What is sort order?
“int a[] = new int[3]{1, 2, 3}” – This a legal way of defining the arrays?
What is sorting in data structure?
Is hashset thread safe?
What do you mean by hash table?
What is sorting and classifying?
What is binary search in data structure?
What is a hash in programming?
What is the difference between hashset and hashmap?