What order is an algorithm that has as a growthrate function

What order is an algorithm that has as a growth-rate function (asymptotic running time) 8*n^3-9*n 7*log_2n+20 7*log_2n+n What is the order of each of the following tasks in the worst case? Computing the sum of the first n even integers by using a for loop Displaying all n integers in an array Displaying all n integers in a sorted linked list Displaying all n names in a circular linked list Displaying one array element Displaying the last integer in a linked list Searching an array of n integers for a particular value by using a binary search Sorting an array of n integers into descending order by using a mergesort Adding an item to a stack of n items Adding an item to a queue of n items

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)

 What order is an algorithm that has as a growth-rate function (asymptotic running time) 8*n^3-9*n 7*log_2n+20 7*log_2n+n What is the order of each of the follo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site