+ Reply to Thread
Results 1 to 6 of 6

Thread: Worst case analysis

  1. #1
    Chinmoy's Avatar
    Chinmoy is offline Programming Expert
    Join Date
    Feb 2008
    Location
    where heaven meets earth
    Posts
    410
    Rep Power
    18

    Worst case analysis

    Worst-Case Analysis


    Most algorithms do not perform the same in all cases; normally an algorithm's performance varies with the data passed to it. Typically, three cases are recognized: the best case, worst case, and average case. For any algorithm, understanding what constitutes each of these cases is an important part of analysis because performance can vary significantly between them. Consider even a simple algorithm such as linear search. Linear search is a natural but inefficient search technique in which we look for an element simply by traversing a set from one end to the other. In the best case, the element we are looking for is the first element we inspect, so we end up traversing only a single element. In the worst case, however, the desired element is the last one we inspect, in which case we end up traversing all of the elements. On average, we can expect to find the element somewhere in the middle.

    Reasons for Worst-Case Analysis

    A basic understanding of how an algorithm performs in all cases is important, but usually we are most interested in how an algorithm performs in the worst case. There are four reasons why algorithms are generally analyzed by their worst case:

    1.Many algorithms perform to their worst case a large part of the time. For example, the worst case in searching occurs when we do not find what we are looking for at all. Imagine how frequently this takes place in some database applications.

    2.The best case is not very informative because many algorithms perform exactly the same in the best case. For example, nearly all searching algorithms can locate an element in one inspection at best, so analyzing this case does not tell us much.

    3.Determining average-case performance is not always easy. Often it is difficult to determine exactly what the "average case" even is. Since we can seldom guarantee precisely how an algorithm will be exercised, usually we cannot obtain an average-case measurement that is likely to be accurate.

    4.The worst case gives us an upper bound on performance. Analyzing an algorithm's worst case guarantees that it will never perform worse than what we determine. Therefore, we know that the other cases must perform at least as well.


    Although worst-case analysis is the metric for many algorithms, it is worth noting that there are exceptions. Sometimes special circumstances let us base performance on the average case. For example, randomized algorithms such as quicksort use principles of probability to virtually guarantee average-case performance.
    God is real... unless declared an integer

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Worst case analysis

    Um, Chinmoy, this tutorial's been posted at IBM Press - 1565924533 - Mastering Algorithms with C.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  4. #3
    Chinmoy's Avatar
    Chinmoy is offline Programming Expert
    Join Date
    Feb 2008
    Location
    where heaven meets earth
    Posts
    410
    Rep Power
    18

    Re: Worst case analysis

    I had that doubt! Dont have the book, so cant' check! Sory, as you see, posted it right alongwith the last one!
    God is real... unless declared an integer

  5. #4
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Worst case analysis

    Oh well, can't be helped then.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  6. #5
    shruti is offline Newbie
    Join Date
    Jul 2008
    Posts
    16
    Rep Power
    0

    Re: Worst case analysis

    Actually , i don't have that much idea about it.

  7. #6
    novice's Avatar
    novice is offline Newbie
    Join Date
    Oct 2008
    Posts
    13
    Rep Power
    0

    Re: Worst case analysis

    i have a question : How is it a C/C++ related tutorial ?
    or is it just a part of the complete tutorial

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Worst case runtime of an algorithm
    By PatrickM in forum General Programming
    Replies: 3
    Last Post: 02-22-2011, 03:19 PM
  2. Replies: 5
    Last Post: 10-27-2010, 12:25 AM
  3. knowing worst case speeds for accessing/modifying data
    By xecure in forum General Programming
    Replies: 3
    Last Post: 09-22-2010, 02:21 PM
  4. Your Language's Worst!
    By ZekeDragon in forum General Programming
    Replies: 14
    Last Post: 03-03-2010, 09:12 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts