Tutorialspoint.dev
Welcome To Tutorialspoint.dev
Officially launched 18th May 2019
Analysis

What does ‘Space Complexity’ mean?

Space Complexity: The term Space Complexity is misused for Auxiliary Space at many places. Following are the correct definitions of Auxiliary Space and Space Complexi...
Analysis

A Time Complexity Question

What is the time complexity of following function fun()? Assume that log(x) returns log value in base 2. void fun() {    int i, j;  &...
Analysis Heap Heap

Time Complexity of building a heap

Consider the following algorithm for building a Heap of an input array A. BUILD-HEAP(A) heapsize := size(A); for i := floor(heapsize/2) downto 1 ...
Analysis Articles

Time Complexity where loop variable is incremented by 1, 2, 3, 4 ..

What is the time complexity of below code? void fun(int n) {    int j = 1, i = 0;    while (i < n)    { ...
Analysis Articles time complexity

Time Complexity of Loop with Powers

What is the time complexity of below function? void fun(int n, int k) {     for (int i=1; i<=n; i++)     { &#x...
Mathematical sieve Mathematical

Sieve of Eratosthenes in 0(n) time complexity

The classical Sieve of Eratosthenes algorithm takes O(N log (log N)) time to find all prime numbers less than N. In this article, a modified Sieve is discussed that w...
Sorting Sorting

An Insertion Sort time complexity question

Question : How much time Insertion sort takes to sort an array of size n in below form? arr[] = 2, 1, 4, 3, 6, 5,….i, i-1, …..n, n-1 Answer : At first ...
Sorting Insertion Sort inversion

Time complexity of insertion sort when there are O(n) inversions?

What is an inversion? Given an array arr[], a pair arr[i] and arr[j] forms an inversion if arr[i] < arr[j] and i > j. For example, the array {1, 3, 2, 5} has on...
Sorting Quick Sort Sorting Quiz

Can QuickSort be implemented in O(nLogn) worst case time complexity?

The worst case time complexity of a typical implementation of QuickSort is O(n2). The worst case occurs when the picked pivot is always an extreme (smallest or larges...
Analysis Heap Heap

Time Complexity of building a heap

Consider the following algorithm for building a Heap of an input array A. BUILD-HEAP(A) heapsize := size(A); for i := floor(heapsize/2) downto 1 ...

Subscribe to Our Newsletter