# Can SQL Server query time-complexity (latency) reach O(1) given a set of optimizations?

Imagine one has two SQL tables containing daily time-series data. Both of the tables have primary key (and since it’s SQL Server the key is also clustered). The key is composite and includes field BUSINESS_DATE of type Date. Both table are partitioned monthly. Table_Short contains only 2 years worth of data. Table_Long contains 50 years… Read More Can SQL Server query time-complexity (latency) reach O(1) given a set of optimizations?

# Python set iteration time complexity

What is the time complexity of the following python code? create set x add n items in x remove n items in x add 1 item in x iterate x m times import time def test(n, m): answer = 0 start = time.time() x = set([i for i in range(n)]) for i in list(x): x.remove(i)… Read More Python set iteration time complexity

# Difference between time complexity O(ab) and O(N^2)

I assume that this code ideally representation of O(n^2) complexity. The reason is for function in another for function for (int i = 0; i < array. length; i++) for (int j = 0; j < array.length; j++) System.out.println(array[i] + "," + arrayfj]); Also, I read that code below is represent O(ab) time complexity. But… Read More Difference between time complexity O(ab) and O(N^2)

# Reduce time complexity in formatting loop

I am writing a component in Vue that lets us take an array of objects for a table and apply HTML formatting to the data, but the way I have it written currently is an O(n^2) complexity, and I am not sure how to make it any faster. example row data: [ { "product": "Socks",… Read More Reduce time complexity in formatting loop

# What is the time complexity of removing/accessing property in an object in javascript

I was watching a youtube tutorial in DS&A (using JS) and he mentioned that the time complexity of accessing or removing property in an object is constant? how is that possible shouldn’t we search for this property first and then delete it or access it. so, it should be linear! >Solution : JavaScript objects are… Read More What is the time complexity of removing/accessing property in an object in javascript

# Time complexity of a haskell function

Consider the following code for a function isPrime. f :: Integer -> Integer f n = head (filter isPrime [0..n]) Assuming that isPrime k computes a boolean in O(k) time, what is the time complexity of f n? My thought process was that filter is linear time, and we are given isPrime is also linear… Read More Time complexity of a haskell function

# time complexity of concatenating strings in python

What is is the time complexity for the following function in Python? The function takes two inputs, string1 and string2, concatenates them together using "+" and returns the concatenated string. def concat_strings(string1, string2): return string1 + " " + string2 is it O(n + m) where n is the length of string1 and m is… Read More time complexity of concatenating strings in python

# time complexity of finding 2d peak with greedy ascent algorithm

*there are just one peak the textbook im studying says the time complexity of greedy ascent algorithm is O(nm) and O(n^2) when m=n. So it means in the worst case, I have to visit all elements of the 2d array. But I think that case is only when the row or column is 1, and… Read More time complexity of finding 2d peak with greedy ascent algorithm

# What should be the time complexity of the program

public static void printArray(int n) { for(int i = 0;i <=Integer.MAX_VALUE;i++) { if(i == n) break; System.out.print(i+" "); } } What should be the time complexity of the program? >Solution : O(N) because it is a single for loop, with the time spent running completely dependent on the N argument value

# Removing from the beginning of an std::vector in C++

I might be missing something very basic here but here is what I was wondering – We know removing an element from the beginning of an std::vector ( vector ) in C++ is an O(n) operation because all the other elements have to be shifted one place backwards. But why isn’t it implemented such that… Read More Removing from the beginning of an std::vector in C++