Algorithm Analysis

Started by
0 comments, last by Fruny 17 years, 10 months ago
I am studying for my Algorithm Analysis class, i need to fill in this table: Operation: Finding a particular item Finding the ith element Finding the maximum item Adding an item Deleting a particular item for: Unsorted array, Sorted array, Unsorted linked list, Sorted linked list the different levels of compelxcity are: O(k) O(lg N) O(N) O(N lg N) O(N2) O(N3) O(Nk) O(2N) For all of these i am looking for the worst case. Finding item,Finding ith element,Finding maximum item,Adding an item,Delete item So far here is what i have, in the order listed above: Unsorted array : O(N),O(k),O(N),O(k), O(N) Sorted array : O(lg N),O(k),O(k),O(N), O(N) Unsorted linked list : O(N),O(N),O(N),O(k), O(k) Sorted linked list : O(N),O(N),O(k),O(N), O(k) Sorry if this is hard to read, i am not sure how to put a chart into a post. If anyone could point out any mistakes, or confirm my results that would be great, Thanks.
Advertisement
Looks OK, assuming that "deleting a particular item" doesn't require to find it first.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement