An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to algorithm design.
3
votes
2answers
33 views
How to obtain the index permutation after the sorting
Given an array arr = {5, 16, 4, 7}, we can sort it through sort(arr, arr+sizeof(arr)/sizeof(arr[0])).
so now the array arr = {4, 5, 7, 16} and the permutation index for the sorted array is {2, 0, 3, ...
4
votes
3answers
46 views
size efficient dictionary(associative array) implementation
What algorithms are available for size efficient A dictionary or associative array?
For example, with this key/value set, how can one avoid duplication "Alice" in values?
{
"Pride and ...
-4
votes
0answers
27 views
Best algorithm to sort words in lexicographic order [on hold]
Given n words having arbitrary lengths, is it possible to sort them in lexicographic order with o(kn) time complexity?? If not could anyone suggest the best algorithm to do so ?
0
votes
3answers
91 views
Selection Rank Algorithm
Below is an implementation of the selection rank algorithm, which is used to find the elements before the Kth smallest elements in an array. Sometimes this program works well, but it sometimes fails ...
-3
votes
4answers
91 views
Sorting algorithm in general [on hold]
Which is the best sorting algorithm in general?
Without any constraints and without any special conditions. I want to use it to sort a random list of around a million integers and the list is ...
1
vote
2answers
80 views
find center of cirle when three points are given
I studied this link and coded accordingly but getting Wrong Answer for the example explained in the link,
During solving the equation, I subtracted equation 2 from equation 1 and equation 3 from ...
0
votes
1answer
20 views
A fast and accurate method for comparing similarity between text documents
I need to compare two groups of documents (e.g. one group might have 1000 documents) and determine which document of the second group is the most similar to the certain document in the first group. ...
0
votes
0answers
42 views
Calculate maxium average block points
I have an array with 30.000 integer values, and I need to calculate the biggest 60 consecutive elements block. I've done this, it works but I don't know if there is a better way to do that. Now it ...
1
vote
1answer
14 views
How to represent crosstab data in java memory to provide category movements?
I have a problem with both the loading and performing operations with crosstab(contingency table).
I would like to load the data from a flat txt file (from crosstab) and store this in memory to print ...
3
votes
5answers
171 views
Metric Convertions Algorithm without “if-else” or “switch-case”
I want to write a program which can converts one unit to another unit. Let's say I have 2 methods.First method can do metric conversions, second method can do weight conversitons. For example;
1. ...
-3
votes
0answers
63 views
Efficient algorithm for counting distinct prime factors of an integer [on hold]
Looking for an efficient algorithm to count the number of prime factors of an integer .
Integers<=100000
not a problem as integers are not big but need to find out for all of the integers till ...
1
vote
2answers
31 views
Weiszfeld algo for “highway” distance?
The problem is to find the point minimizing the travel distance for around 100 persons in different regions who want to meet in the same place. Travel is by car not by plane.
Assuming that I get ...
1
vote
3answers
51 views
Why is performance of bubble sort and insertion sort same i.e O(n^2)
I did the below code to check the number of iteration and swaps required for bubble sort and insertion sort. Even though (referring to below code) insertion sort did literally half iterations and same ...
1
vote
3answers
70 views
Generate n colors between two colors
I'm trying to write function, which can generate colors between two colors based on a given value. An example would explain it better..
Input ..
X : 1
Y : 0.5
Z : 0
The user gives any set of ...
7
votes
5answers
142 views
Find the first element that occurs only once [duplicate]
This was a Google interview puzzle.
The problem is to find the first element in an array that occurs only once.
For example, abaaacdgadgf is given. We need to output b.
The simple solution seems to ...