time-complexity

Java Data Structures Reference

Can anyone give me references of a web site containing a summary of the main Java data structures, and their respective complexity in time (for some given operations like add, find, remove), e.g. Hashtables are O(1) for finding, while LinkedLists are O(n). Some details like memory usage would be nice too This would be really helpful for...

Is it ever possible to have Big O less than O(1)?

Possible Duplicate: are there any O(1/n) algorithms? Is it ever possible for your code to be Big O less than O(1)? ...

Time Complexity O() of isPalindrome()

I have this method isPalindrome() and am trying to find the time complexity of it, and also rewrite the code more efficiently. boolean isPalindrome(String s) { boolean bP = true; for(int i=0; i<s.length(); i++) { if(s.charAt(i) != s.charAt(s.length()-i-1)) { bP = false; } } return bP; } Now I know this code...

Comlexity of algorithms - exercises

Hello. I'm learning for an exam in an introductory course to computer science, and i have a problem with the topic of complexity, both in "regular" algorithms and also in recursive algorithms (usually we get these questions written as C code). I was wondering if there're online examples somewhere in the internet and/or book that covers ...

time complexity analysis of code

Hello, I have this code: int foo(int n) { int x=2; while (x<n) { x = x*x*x; } return x; } Now, i need to analyze its time complexity. I noticed it reaches n much faster than just log(n). I mean, it does less steps than O(log(n)) would do. I read the answer but have no idea how they got to it: It is O(log(...

Program/algorithm to find the time complexity of any given program.

As the title suggests i would like to know whether it is possible to "WRITE A PROGRAM or ALGORITHM" to find the time complexity of any given program taken as input? Input : any program(P) [in any language or of a particular language] Output : time complexity of that program(P). Have there been any prior attempts to write such a progra...

The Timecomplexity of Built in SQL Functions such as sum, count, avg

What is the time complexity of a function such as count, sum, avg or any other of the built in "math"-functions in mysql, sql server, oracle and others? One would think that calling sum(myColumn) would be Linear? But count(1) isn't, how come and what are the Real time-complexity? In a perfect world I would want sum, avg and count to b...

O Notation Help

I am getting stuck with the class work we got this week and its a subject i really want to learn so for once i thought i would do the additional reading!!!! The method is provided for us and i am just writign some test cases. This is where my knowledge gets a little hazy. If the time increases then i am underestimatign the complexity i ...

Examples of Algorithms which has O(1), O(n log n) and O(log n) complexities.

What are some algorithms which we use daily that has O(1), O(n log n) and O(log n) complexities? ...

order of complexity of the algorithm in O notation

Can anyone tell me order of complexity of below algorithm? This algorithm is to do following: Given an unsorted array of integers with duplicate numbers, write the most efficient code to print out unique values in the array. I would also like to know What are some pros and cons in the context of hardware usage of this implementation ...

Running time of minimum spanning tree? ( Prim method )

I have written a code that solves MST using Prim method. I read that this kind of implementation(using priority queue) should have O(E + VlogV) = O(VlogV) where E is the number of edges and V number of Edges but when I look at my code it simply doesn't look that way.I would appreciate it if someone could clear this up for me. To me it s...

Finding the index of an entry in a linked list in better than O(n) time...

I have a scenario where I'm pushing change-lists to another system. Each list contains zero or more inserted, updated or deleted notifications. Inserting is easy; the notification contains the target index and a pointer to the item. Updating is easy; I pass a pointer to the item. Deleting seems straight-forward; I need to pass the ...

upper bound, lower bound

What does it mean to prove an upper bound or lower bound to an algorithm? ...

fast similarity detection

I have a large collection of objects and I need to figure out the similarities between them. To be exact: given two objects I can compute their dissimilarity as a number, a metric - higher values mean less similarity and 0 means the objects have identical contents. The cost of computing this number is proportional to the size of the sm...

Comparison Sorting Algorithm Complexity

Why is the lower bound for the time complexity of comparison-based sort algorithms O(n log n)? ...

Why the time complexity in dll is faster than deletion of a node in sll?

Why the time complexity in doubly linked list which is O(1) is faster than deletion of a node in singly linked list which is O(n)? ...

What is the difference between O, Ω, and Θ?

I am learning algorithm analysis. I am having trouble understanding the difference between O, Ω, and Θ. The way they're defined is as follows: f(n) = O(g(n)) means c · g(n) is an upper bound on f(n). Thus there exists some constant c such that f(n) is always ≤ c · g(n), for large enough n (i.e., n ≥ n0 for some constant n...

Question about NP-Completeness of the Independent Set Problem.

I thought that, when proving that a problem P is NP-Complete, we were supposed to reduce a known NPC problem to P. But, looking at the solution to the Independent Set problem, it seems to not go this way. To prove that Independent Set is NP-Complete, you take a graph G, find its inverse G', and then compute CLIQUE(G'). But, this is doin...

Is insertion time complexity of sorted-list implementation of priority queue O(n)?

From wikipedia: Sorted list implementation: Like a checkout line at the supermarket, but where important people get to "cut" in front of less important people. (O(n) insertion time, O(1) get-next time, O(n*log(n)) to build) I think if searching the insert position with binary search algorithm,the insertion time complexity...

Time complexity for java ArrayList

Is ArrayList an array or a list in java? what is the time complexity for the get operation, is it O(n) or O(1)? ...