Skip to main content

Questions tagged [algorithm-analysis]

Analyzing an algorithm to determine its time and space performance.

2votes
7answers
4kviews

Why is big O notation an asymptotic notation/analysis?

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
21votes
6answers
5kviews

Using a different algorithm depending on the size of the input

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
3votes
1answer
310views

Algorithms: How do I sum O(n) and O(mlog(n)) together?

I'm doing a running time analysis using the aggregate method and I'm a bit confused about what would be the result in this case. I have some intuition in inferring that it would be O(mlog(n)) but I'm ...
neo's user avatar
  • 51
1vote
3answers
190views

How can I mix this grid to guarantee it being solvable in X minimum steps?

Note: This question is not about this particular instance of this grid with these exact words, but about any combination of words. I am programming a puzzle game where you have to arrange a grid of ...
Florian Walther's user avatar
32votes
5answers
49kviews

Algorithms: How do I sum O(n) and O(nlog(n)) together?

I have the follow algorithm which finds duplicates and removes them: public static int numDuplicatesB(int[] arr) { Sort.mergesort(arr); int numDups = 0; for (int i = 1; i < arr.length; ...
chopper draw lion4's user avatar
1vote
1answer
115views

Some questions about shortest-path algorithms

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
23votes
4answers
4kviews

When speaking, how can I say that the time complexity order of an algorithm is O(N log N)?

What term can I use to describe something with O(N log N) complexity? For example: O(1): Constant O(log N): Logarithmic O(N): Linear O(N log N): ?????? O(N2): Quadratic O(N3): Cubic
matiascelasco's user avatar
0votes
2answers
1kviews

Calculating time complexity of a code snippet

I am trying to calculate the time complexity of the below code snippet def func() { for(i=1; i<=n; i++) { for(j=1; j<=n; j=j+i) { print("hello") } }...
learnToCode's user avatar
20votes
8answers
28kviews

Why is binary search,which needs sorted data, considered better than linear search?

I have always heard that linear search is a naive approach and binary search is better than it in performance due to better asymptotic complexity. But I never understood why is it better than linear ...
Aseem Bansal's user avatar
0votes
2answers
363views

fastest way to find number of smaller elements to the right of an array

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
34votes
5answers
16kviews

Divide and Conquer algorithms – Why not split in more parts than two?

In divide and conquer algorithms such as quicksort and mergesort, the input is usually (at least in introductory texts) split in two, and the two smaller data sets are then dealt with recursively. It ...
beta's user avatar
  • 1,012
4votes
1answer
1kviews

What is the most suitable data structure for IPv4 addresses with intersecting ranges?

Mostly in all routers and operating systems the Longest Prefix Match algorithm is used for searching the trie of IPv4 addresses. Packet filters like Iptables don't need some special data structure for ...
red0ct's user avatar
5votes
4answers
641views

Processing a 2D matrix - need to speed up my O(n^4) algorithm

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
3votes
1answer
417views

Why the names Omega and Theta in Big Omega and Big Theta?

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
0votes
1answer
1kviews

Counting primitive operations on recursive functions

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

153050per page
close