Top "Time-complexity" questions

The time complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the size of the input to the problem.

Why lookup in a Binary Search Tree is O(log(n))?

I can see how, when looking up a value in a BST we leave half the tree everytime we compare …

data-structures time-complexity big-o binary-search-tree
Given a list of numbers and a number k, return whether any two numbers from the list add up to k

This question was asked in the Google programming interview. I thought of two approaches for the same: Find all the …

arrays algorithm time-complexity dynamic-programming subsequence
Time complexity for Shell sort?

First, here's my Shell sort code (using Java): public char[] shellSort(char[] chars) { int n = chars.length; int increment = n / 2; …

algorithm big-o time-complexity shellsort
Time complexity of node deletion in singly- and doubly-linked lists

Why is the time complexity of node deletion in doubly linked lists (O(1)) faster than node deletion in singly linked …

linked-list complexity-theory time-complexity singly-linked-list doubly-linked-list
Time complexity of contains(Object o), in an ArrayList of Objects

As the title says, I was wondering what the time complexity of the contains() method of an ArrayList is.

java arraylist time-complexity
Finding Big O of the Harmonic Series

Prove that 1 + 1/2 + 1/3 + ... + 1/n is O(log n). Assume n = 2^k I put the series into the summation, but I have …

time-complexity big-o complexity-theory
Find all possible substring in fastest way

For String A = "abcd" then answer should be {a,ab,abc,abcd,b,bc,bcd,c,cd,d} To find …

java algorithm performance substring time-complexity
When can an algorithm have square root(n) time complexity?

Can someone give me example of an algorithm that has square root(n) time complexity. What does square root time …

time-complexity
Difference between the time complexity required to build Binary search tree and AVL tree?

While I was learning Binary search tree(Balanced and unbalanced), I come up with questions which I need to resolve: …

algorithm data-structures binary-search-tree time-complexity avl-tree
nth fibonacci number in sublinear time

Is there any algorithm to compute the nth fibonacci number in sub linear time?

performance algorithm math time-complexity fibonacci