Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
300 views

I wrote a solution to the problem linked below but I'm not sure about its time complexity. I was thinking it was quadratic but it passed within 0 ms when I submitted, so it might be linear idk. I ...
renanmatulianes's user avatar
-4 votes
1 answer
285 views

for (int i = 0; i < n^2; i++) { for (int j = 1; j < i; j = 2j) { for (int k = 0; k < j; k++) { System.out.println("x"); } } } My thoughts are that the outer loop ...
impossibru's user avatar
1 vote
1 answer
120 views

I'm implementing a few custom enumerators for my data model, e.g. struct Land { // … let council: Council let size: Int } extension Collection<MyModel> { func lands(in council: Council, ...
Heuristic's user avatar
  • 5,361
5 votes
1 answer
273 views

I've come across the notation recently am confused by what I see. My previous understanding is that big O is supposed to be used to denote an upper bound whereas lower or tight bound uses different ...
Daniel's user avatar
  • 53
-2 votes
1 answer
300 views

I am looking for a function or gem that gives me the cyclomatic complexity of a function. For example, using rubocop, If I write def my_func(foo) foo.details['errors'].each do |attr, message| ...
Constantin De La Roche's user avatar
0 votes
0 answers
67 views

I am trying to calculate complexity of a recursion method inside another methos in a simple while loop. I dont know how to asnwer this question, I think To just apply the answer O(N*Y) while Y stands ...
itamar nahum's user avatar
0 votes
0 answers
75 views

I need some help answering this question : How do I find the complexity of the matrix B and f knowing that I have this code : d = 123456; randn('state',d); rand('state',d); n = 1000; A = diag(1+rand(...
Rustless's user avatar
2 votes
2 answers
307 views

Problem Description We have a vector<A> v containing for 4 objects. Each object has the following members x, y, z and w. Two objects are considered equal if the have the same x and y. In that ...
Hani Gotc's user avatar
  • 920
1 vote
1 answer
130 views

I'm learning about time complexity and I understand the gist of it, but there's one thing that's really confusing me, it's about understanding the time complexity of a while loop in a for loop. This ...
Moqm's user avatar
  • 11
1 vote
0 answers
48 views

The problem which is on LeetCode says that You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. ...
Hax's user avatar
  • 154
0 votes
0 answers
46 views

Hello I have a binary search function and I want to prove that it has Logarithmic complexity. I have no idea how to prove this and would really use some help Here are my execution times for the ...
antekkalafior's user avatar
0 votes
3 answers
716 views

So I have been studying the complexity of algorithms, but this one I can't uderstand. If I use a global variable to check how many times the function is called it will calculate the number 11 then ...
user avatar
1 vote
0 answers
120 views

I am learning algorithm complexities. So far it has been an interesting ride. There is so much going behind the scenes that I need to understand. I find it difficult to understand complexity in ...
James Parker's user avatar
0 votes
1 answer
121 views

I am currently on 94. Binary Tree Traversal on leetcode and I am not sure how to analyze the run time and space complexity of the question. In my opinion, the time complexity for the question seems to ...
Jialin Zhen's user avatar
0 votes
1 answer
40 views

I am building an application which uses a lot of vectors and for which I am using a lot of third party and system assemblies. The result of this is that I have four ways to to represent 3d double ...
lmcdev's user avatar
  • 3
7 votes
1 answer
376 views

I am trying to integrate lizard to track the code complexity of an android app on sonarqube. The command used to get the complexity report from lizard is: lizard src/main -x"./test/*" -x&...
Gurunath Sripad's user avatar
0 votes
1 answer
613 views

Is there a way to remove this if else block inside snackbar by replacing it with lambda or infix or anything to make it without +2 nesting in cognitive complexity else { snackBarBuilder( ...
hodokeg's user avatar
  • 19
0 votes
1 answer
150 views

I'm studying the complexity of functions in python, and I have this two there Im not sure, one because I think it's infinite loop and second is the not in method build in on python: 1- The function f1 ...
António Rocha Gonçalves's user avatar
0 votes
0 answers
27 views

F(i, j) represents the maximum value the user can collect from i'th coin to j'th coin. F(i, j) = Max(Vi + min(F(i+2, j), F(i+1, j-1) ), Vj + min(F(i+1, j-1), F(i, j-2) )) As user wants ...
Rohit Kashyap's user avatar
1 vote
0 answers
216 views

when creating a BitArray and initializing all of its value to 0 (via constructor, new BitArray(size, false);) what is the time complexity of such operation? It's not in the docs about collections. ...
Aviv Vetaro's user avatar
0 votes
1 answer
153 views

If you had an algorithm with a loop that executed n steps the first time through, then n − 2 the second time, n − 4 the next time, and kept repeating until the last time through the loop it executed 2 ...
Manuel Hernandez's user avatar
0 votes
1 answer
380 views

I have algorithm such as: for(int i=1; i<=n; i++) for(int j=1; j<=2*n; j=j+2) for(int k=i; k<=j; k++) instr; I need to find a formula that will determine how many times the &...
Patryk Wojcieszak's user avatar
1 vote
2 answers
776 views

function recursion(n){ if n==0 return for(let i=0; i < n;i++){ for(let j=0; j< n; j++){ console.log('*'); } } recursion(n-1); } recursion(100); What is ...
user9312404's user avatar
0 votes
2 answers
391 views

Can someone please help me with the time and space complexity of this code snippet? Please refer to the leetcode question- Word break ii.Given a non-empty string s and a dictionary wordDict containing ...
curiousD's user avatar
1 vote
2 answers
129 views

I'm learning how to find algorithm complexity and I can't figure out what's the complexity of this algorithm. Could someone explain to me how to get the answer? void algorithm(int a, int b) { ...
ItsNotMyFault's user avatar