What order is an algorithm that has as a growthrate function
Solution
Hi, I have answerd problem 7 and first 3 parts of problem 8.
Please repost all remaining questions in separate post.
7)
In Big-O notation, we generally ignore lower order terms
and constant multipliers
a. 8*n^3 - 9*n
8*n^3 > 9*n
also ignoring 8 , so, Big-O = O(n^3)
b).
7*logn + 20
ignoring 20 and 7
Big-O = O(logn)
c).
7*logn + n
here n > 7*logn
So, Big-O = O(n)
8)
a). to compute sum of first n even numbers , we nned to traverse 2*n terms one by one, So, T(n) = O(n)
b)
Displaying all elements of array means => you need to traverse all the elements of the array one by one in loop
So, if n is the size of the array, T(n) = O(n)
c)
You have to traverse linked list from head to tail to display
all the elements of sorted linked list.
So, if you have n node in linked list, it takes O(n)
