worst-case

data structures and algorithms e-books

Hi, Where can I find e-books on Data Structures and Algorithms? I am currently reading "Computer Algorithms: Introduction to design and Analysis" by Sara Baase and Allen Van Gelder. I would like to have additional information to supplement what's in this book. Also some references on worst-case analysis would be great. ...

Worst case running time (Big O)

Hi every one. I have this question, and I don't know how to solve it, because I don't understand it. :( The question is: Programs A and B are analyzed and are found to have worst case running times no greater than 150n log n and n2, respectively. Answer the following questions: i) Which program has the better guarantee on...

How to determine the best case and worst case of an program(algorithm)?

Suppose I have this program, I want to compare 2 input lists. Assume array A and array B. How do I determine the best case and worst case of the function? Here is my code in [php]: foreach($array_1 as $k){ if(!in_array($k, $array_2)){ array_push($array_2, $k); } } What is the best case and worst case of the for loo...

How to count the number of operations in a loop and give a theta characterization

I just want to make sure if I am doing this correct. I am trying to count the number of operations performed for the worst case scenario in java int sum = 0; for (int i = 0; i < n; i++ ) sum++; Is the number of operations 2+3n or 3+3n? I got the answer from counting int sum = 0 and int i = 0 for the "2" and i < n, i++, and su...