Skip to main content

Questions tagged [algorithm-analysis]

Analyzing an algorithm to determine its time and space performance.

Filter by
Sorted by
Tagged with
9 votes
9 answers
3k views

Using Big O notation, it is clear that I should go with the more efficient approach, but I know that there is a significant cost in terms of initialization for more efficient solutions. The Problem: ...
BlueyRules's user avatar
2 votes
7 answers
4k views

An asymptote in mathematics represents a value (line) to which the observed function constantly approaches. In other words, as the value of X increases towards infinity, i.e. decreases towards minus ...
dassd's user avatar
  • 147
1 vote
1 answer
130 views

I'm trying to understand why anyone would prefer Floyd-Warshal over Dijkstra: Dijkstra gives a correct result, using an understandable system, combined with backtracking. Floyd-Warshal makes an ...
Dominique's user avatar
  • 1,844
0 votes
2 answers
395 views

In Daily Coding Problem, Miller&Wu have the following problem : Given an array of integers, return a new array where each element in the new array is number of smaller elements to the right of ...
molyss's user avatar
  • 181
0 votes
1 answer
1k views

I'm reading Algorithm Design and Applications, by Michael T. Goodrich and Roberto Tamassia, published by Wiley. They teach the concept of primitive operations and how to count then in a given ...
André Carvalho's user avatar
5 votes
4 answers
684 views

I have an n x n matrix which I need to convert into a list sorted by value. Starting with the maximum value cell at (row x1, col y1), I must immediately exclude all cells where (x >= x1, y <= y1)...
Irfan434's user avatar
  • 187
3 votes
1 answer
436 views

There was a question asking what the "O" stands for in "Big O", the answer to which seems to be "Ordnung von"/"order of". I wonder what's the origin of the ...
xji's user avatar
  • 791
21 votes
6 answers
5k views

I recently finished a course on advanced algorithms, and another on complexity & computability theory, and in the past few days my mind has been somewhat preoccupied by this question. Why don't we ...
cliesens's user avatar
  • 345
1 vote
0 answers
223 views

I have multiple rectangular frames, with different fixed heights. The width should be minimized and there is a maximum width. Then there are many different smaller rectangles. These should be packed ...
Wombosvideo's user avatar
3 votes
3 answers
3k views

Is there anything that can calculate the Big-O notation of a function? While learning about Big-O, it is implied that it is pretty trivial to do in your head once you know the basic rules, however if ...
Anon's user avatar
  • 3,649
0 votes
1 answer
153 views

I am doing the Ransom Note algorithm in Hackerrank. The thing is I am not using maps and all the tests pass except for three which execution time takes a lot more. (Kotlin language) I have two ...
apksherlock's user avatar
-1 votes
1 answer
161 views

A software company develops software packages for commercial animal farming. A special function in C calculates the daily amount of feed for different kind of animals dependent on their bodyweight....
tenepolis's user avatar
  • 285
-3 votes
1 answer
224 views

I am a newbie to algorithms. One thing that i always get confused is about calculation of algorithm runtimes. For example: The following piece of code in Python for i in range(n): #O(?) i*=k ...
Kiran Hegde's user avatar
0 votes
1 answer
904 views

I have the idea of develop a model that predicts the battery charge level of my system for now until the following 5 days. The battery is charged using a solar panel. I am writing my code in Python 2....
Andermutu's user avatar
2 votes
1 answer
416 views

First, this question is not really about binary search as I neither have sorted data, nor any sortable data at all. :-) W.r.t the "unsortable" claim see below; but I think the title term "unsortable"...
Martin Ba's user avatar
  • 7,861
1 vote
1 answer
2k views

I am trying to reverse engineer a checksum or CRC wherein an 8 bit number* gets converted to a 5 bit number for error checking. I have an incomplete list of data values and checksums, and need to ...
DrWizard's user avatar
1 vote
1 answer
8k views

Lately i have been taking an course at brilliant.org, i was exploring a lesson on QuickSort algorithm, found a question. Which of the following would provide the optimal pivot selection at each step ...
Sujal Mandal's user avatar
-1 votes
2 answers
335 views

Here the professor said that, Tournament sort needs (n-1) + 2(n-1)logn comparisons. {Where (n-1) for calculating Maximum or say creating Tournament structure and 2(n-1)logn for other elements to sort}...
Bhaskar's user avatar
  • 47
1 vote
2 answers
6k views

Selection Sort(A[1,2..n]:array of integers) 1.for i=1 to n-1 2.for j=i+1 to n 3.if A[j]<A[i] 4 swap(A[i],A[j]) I am trying to prove the correctness of this algorithm,I read from my book ...
Joel Separ's user avatar
5 votes
2 answers
1k views

I have set of spatial points defined by coordinates (x,y) . I want to find the bounding rectangle of given area that maximizes the number of point inside the rectangle. The obtained rectangle should ...
sanket's user avatar
  • 59
2 votes
3 answers
2k views

This is a very simple function to find if a string is composed of unique characters. I believe that this is a O(n) time complexity as it loops once and has a single if condition. Am I correct? Is ...
Pradeepl's user avatar
  • 133
3 votes
1 answer
553 views

I want to sole this problem: Write a method to return all valid combinations of n-pairs of parentheses. The method should return an ArrayList of strings, in which each string represents a ...
user72708's user avatar
  • 159
2 votes
4 answers
3k views

I am highly confuse while calculating time complexity of Merge Sort Algorithm. Specifically on the Dividing Step. In the dividing step we have to calculate the mid point of "n" i.e. "q = n/2". How ...
Bhaskar's user avatar
  • 47
-1 votes
3 answers
535 views

What is the complexity of the following loop? for(i=1;i<n;i=2^i) sum+=i;
Anshul Negi's user avatar
2 votes
1 answer
329 views

I have a large set of values (let's say 1M entries) where I need to apply an exponential smoothing algorithm, but only incrementing one value at a time (all others decay to zero). The trivial ...
Laurent Grégoire's user avatar