Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

4 votes
0 answers
206 views

Finding repeating sequences with less than O(n^2) time complexity

Is it possible to find repeating sequences of any length (without complete overlaps) with an average time complexity less than O(n^2) ? For example, take a string like this: 0 1 2 ...
George Robinson's user avatar
4 votes
1 answer
114 views

How to prove a problem is unsolvable in a certain Time Complexity?

While discussing the Local Minimum in n x n Matrix Problem with my professor, he suggested that there exists a solution with O(log n) time complexity for this problem. Now, I'm fairly sure he is wrong,...
Nik's user avatar
  • 53
0 votes
2 answers
145 views

Find unique or combination for given array

I have an array of numbers of size n, select all possible distinct increasing subsequence of the array, for each subsequence find the bitwise OR value and return them as result in increasing order. ...
Sid's user avatar
  • 87
2 votes
1 answer
82 views

Modified Dijkstra - Time Complexity?

I am solving the Leetcode Problem 787. Cheapest Flights Within K Stops. Basically this is single source shortest path, but with max k steps allowed. So, we can't use normal Dijkstra algorithm, where ...
Lupin's user avatar
  • 59
3 votes
4 answers
134 views

sorting algorithm in O(n) according a specific condition

Given an array A with n−1 numbers where n = 2^k for some integer k. One of the values appears exactly n/2 another appears exactly n/4, and so on. More formally, for all 1 ≤ k ≤ log n exists a value ...
GuyNet's user avatar
  • 31
0 votes
1 answer
65 views

What's the difference between O(n) and O(n+n^1/2) in algorithm?

I watched an online course which mentioned that O(n) and O(n + n^(1/2)) are equivalent in algorithms. I'm curious about why the n^(1/2) part can be ignored. What is the reason for this omission? I ...
Da-qiong's user avatar
2 votes
0 answers
79 views

What is the Time Complexity of a function if there is an upper limit to the variable

I have the following piece of code. void foo(int n){ n=n*n; for (int i=0;i<n;i++){ if(n<10) cout << i; else break; } } Now I wanted to ask if the time complexity ...
Muhammad Taha Ali's user avatar
1 vote
0 answers
42 views

Time and space complexity of a given Branch-and-Bound algorithm

I need to calculate the time and space complexity of a Branch-and-Bound algorithm, to solve a problem. The problem is: On a chess board, the knight needes to move, from a initial to a end point, doing ...
Yuri Gabriel dos Reis Souza's user avatar
0 votes
1 answer
61 views

Understanding the Time Complexity Difference of Two Ways to Generate Subsets

I was recently performing a complexity analysis on two separate methods for generating the subsets of a given set. For this question, I am removing all unessential components of the code, meaning that ...
LateGameLank's user avatar
-1 votes
2 answers
150 views

Minimize repetitions by removing all occurrences of one number

I did a program in python3 which is correct, it gives the right results, but it has Time Complexity of O(n^2). I wanna improve the Time complexity of this program. When I run it on a platform algorea ...
Mourad BENKDOUR's user avatar
0 votes
2 answers
47 views

Time complexity calculation for algorithms with nested while loops

I'm trying to figure out the time complexity of the following program. So far, my calculations yield that the worst case time complexity would be O(n^3). for i in range(1, n): j = 1 while j < i*...
Sayeedur Rahman 's user avatar
4 votes
1 answer
97 views

How to calculate the length of cycles in a graph using parallel algorithms in C?

I am getting desprite, because I can't solve this problem. I hope this is the right place to ask for help in this context. The Problem is, that I have a graph that is the union of disjoint directed ...
TJTvoid's user avatar
  • 41
3 votes
1 answer
85 views

Optimally counting number of nodes in a complete binary tree

I am looking at LeetCode problem 222. Count Complete Tree Nodes: Given the root of a complete binary tree, return the number of the nodes in the tree. According to Wikipedia, every level, except ...
Paras Khosla's user avatar
1 vote
1 answer
86 views

Hash table average complexity of functions

GOAL The goal is to use a chained hash table, with a hashing function h that satisfies the Simple Uniform Hashing Assumption, to store some numbers (the same number, if inserted multiple times, is ...
selenio34's user avatar
  • 202
1 vote
0 answers
40 views

Determining the run time of an algorithm solving Latin Square

any help would be appreciated. Here is the problem: https://erich-friedman.github.io/puzzle/latin/ Now, I write some code to solve the problem and want to find the time complexity of the problem, I ...
cong le's user avatar
  • 35

15 30 50 per page
1
2 3 4 5
322