Tagged Questions
-6
votes
0answers
50 views
what is a possible algo used here? [closed]
An array whose result after two passes of the sorting is as given below:
5,6,7,12,11,10,19,20
which is the possible sorting algo?
a)bubble sort
b)selection sort
c)insertion sort
1
vote
1answer
130 views
Quicksort and middle pivot
I am having a head ache understanding quicksort with middle pivot. I found lot of explanations about using left most or right most, but not many about a middle one.
Can I safely assume these?:
If ...
2
votes
3answers
99 views
What kind of algorithm could be used to produce an ordering which maximizes # of satisfied 'less than' constraints?
Let's say I have a set of items {e1, e2, ..., en}, and I also have a set of constraints {c1, c2, ..., cm}, with ci := ej appears before ek, for some j and k.
I want to produce an ordering of my items ...
28
votes
5answers
1k views
I'd like to write an “ultimate shuffle” algorithm to sort my mp3 collection
I'm looking for pseudocode suggestions for sorting my mp3 files in a way that avoids title and artist repetition. I listen to crooners - Frank Sinatra, Tony Bennett, Ella Fitzgerald etc. singing old ...
2
votes
4answers
286 views
Applications of heapsort
Heapsort is a sorting algorithm that has a time complexity of O(nlogn), and performs sorting using O(1) space complexity. However, I know that because it's unstable, it doesn't find many applications ...
1
vote
3answers
226 views
Should I calculate hotness of a post on request or pre-calculate it?
Here is the Reddit's hot algorithm:
cpdef double _hot(long ups, long downs, double date):
"""The hot formula. Should match the equivalent function in postgres."""
s = score(ups, downs)
...
2
votes
2answers
254 views
About insertion sort and especially why it's said that copy is much faster than swap?
From Lafore's "Data Structures and Algorithms in Java":
(about insertion sort (which uses copy + shift instead of swap (used in bubble and selection sort)))
However, a copy isn’t as time-consuming ...
1
vote
2answers
331 views
Java Alphabetize Algorithm Insertion sort vs Bubble Sort
I am supposed to "Develop a program that alphabetizes three strings. The program should allow the user to enter the three strings, and then display the strings in alphabetical order." It's instructed ...
1
vote
1answer
341 views
Comparison of my own Insertion Sort versus the standard algorithm
I come from a background of making MVC websites and HTML5 applications, and have recently decided to dive into the sort of stuff i wasn't taught at university, namely the things most people would ...
1
vote
4answers
2k views
What sorting algorithm does STL use?
I recently started using <vector.h> library and I was wondering, since all the operations are already implemented, IF the method of the sorting algorithm is the most efficient one. Everything ...
1
vote
6answers
3k views
Merge sort versus quick sort performance
I have implemented merge sort and quick sort using C (GCC 4.4.3 on Ubuntu 10.04 running on a 4 GB RAM laptop with an Intel DUO CPU at 2GHz) and I wanted to compare the performance of the two ...
1
vote
1answer
159 views
Algorithm for determining grid based on variably sized “blocks”?
I'm trying to convert a set of "blocks" in to a grid-like layout. The blocks have a width of either 25%, 33%, 50%, 66%, or 75% of their container and each row of the grid should try to fit as many ...
1
vote
1answer
225 views
Need help with algorithm for sorting list
The answer is probably obvious but not to me at this moment, so I was wondering if somebody who is better with sorting algorithms can help lead me in the right direction. This is not homework, I am ...
7
votes
7answers
4k views
Sort algorithms that work on large amount of data
I am looking for sorting algorithms that can work on a large amount of data, i.e. that can work even when the whole data set cannot be held in main memory at once.
The only candidate that I have ...
3
votes
3answers
664 views
Basic premise on counting sort. How is k related to to Big Oh?
I am reading (Cormen) on counting sort.
I understand the structure of the algorithm but the statement:
In practice, we usually use counting sort when we have k = O(n), in
which case the ...
8
votes
5answers
640 views
Algorithm refresher. Why is heapsort an insort algorithm?
I can not see why the heapsort is considered an inplace sorting algorithm.
I mean an extra data structure populated with the elements of the array to be sorted i.e. a heap, is used to assist in the ...
14
votes
3answers
820 views
Java and .NET: Why different sorting algorithms are used by default?
Just wondering why Java and .NET Framework uses different sorting algorithm by default.
In Java Array.Sort() uses Merge Sort algorithm by default and as Wikipedia.com says:
In Java, the ...
5
votes
3answers
509 views
does quicksort provide less swapping step?
So far, most of the fastest and common sorting method is quicksort. Although it has its pro and cons. However, i'm thinking that although this sorting method is fast but does it provide shortest ...
8
votes
3answers
287 views
Data “unsort” / homogeneity algorithm
In an attempt to not reinvent a wheel, I'm asking if anyone has ideas on a data homogeneity algorithm. A brief example:
My data has several elements maybe like
Number
Color
Fruit
Letter
There ...
2
votes
5answers
2k views
Is Bubble Sort the slowest sorting algorithm? [closed]
Is Bubble Sort the slowest sorting algorithm? If the answer is no, then what is the slowest one?
2
votes
4answers
1k views
Which sorting algorithms have a different worst case complexity than their average case?
I'v been working on sorting for a while now but I can't figure these two questions apart, I'm kind of getting mixed up somewhere ... Somebody help
a) Which sorting algorithms have a different worst ...
8
votes
3answers
2k views
Why isn't Radix Sort used more often?
It's stable and has a time complexity of O(n). It should be faster than algorithms like Quicksort and Mergesort, yet I hardly ever see it used.
2
votes
7answers
913 views
What is the easiest non-quadratic sorting algorithm?
If you had to teach one sorting algorithm that is faster than O(n²), which one would you pick?
It should be relatively easy to understand and implement, and it should require little theoretical ...
8
votes
6answers
442 views
Quicksort and don't bother?
Especially when writing 'standard' (non-HPC) applications, do you consider what sorting algorithm to pick, or just settle with quicksort (which is what most libraries just call sort)? To some extent ...
