According to Marcin Ciura's Optimal (best known) sequence of increments for shell sort algorithm,
the best sequence for shellsort is 1, 4, 10, 23, 57, 132, 301, 701...,
but how can I generate such a sequence?
In Marcin Ciura's paper, he said:
Both Knuth’s and Hibbard’s sequences
are relatively bad, because they are
defined by sim...
I have 2 independent but contiguous date ranges. The first range is the start and end date for a project. Lets say start = 3/21/10 and end = 5/16/10. The second range is a month boundary (say 3/1/10 to 3/31/10, 4/1/10 to 4/30/10, etc.) I need to figure out how many days in each month fall into the first range.
The answer to my example a...
I'm working on a project to recognize simple audio patterns. I have two data sets, each made up of between 4 and 32 note/duration pairs. One set is predefined, the other is from an incoming data stream. The length of the two strongly correlated data sets is often different, but roughly the same "shape". My goal is to come up with some s...
Hi there .
I have a A=set of strings and a B=seperate string. I want to count the number of occurences in from B in A.
Example :
A:
10001
10011
11000
10010
10101
B:
10001
result would be 3.(10001 is a subset of 10001,10011,10101)
So i need a function that takes a set and string and returns an int.
int myfunc(set<string> , string...
I have a flat area with nodes randomly placed on this flat surface. I need techniques which are able to take a starting point, move in a certain way (the algorithm), find nodes and continue searching. I do not have an overall view of the surface (i.e. I cannot see everything), only a limited view (i.e. 4 cells in any direction). Ideally,...
The idea I'm playing with right now is having a multi-leveled "tier" system of analytical objects which perform a certain computation on a common object and then create a new set of analytical objects depending on their outcome. The newly created analytical objects will then get their own turn to run and optionally create more analytical...
string Haystack[] = { "Alabama", "Alaska", "American Samoa", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia",
"Florida", "Georgia", "Guam", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky",
"Louisiana", "Maine", "Maryland", "Massa...
So given x, and power, n, solve for X^n.
There's the easy way that's O(n)...
I can get it down to O(n/2), by doing
numSquares = n/2;
numOnes = n%2;
return (numSquares * x * x + numOnes * x);
Now there's a O(log(n)) solution, does anyone know how to do it? It can be done recursively.
...
Given a Range of numbers say 1 to 10,000, Input is in random order.
Constraint:
At any point only 1000 numbers can be loaded to memory.
Assumption:
Assuming unique numbers.
I propose the following efficient , "When-Required-sort Algorithm".
We write the numbers into files which are designated to hold particular range of numbers. Fo...
What is the best way to check collision of huge number of circles?
It's very easy to detect collision between two circles, but if we check every combination then it is O(n2) which definitely not an optimal solution.
We can assume that circle object has following properties:
Coordinates
Radius
Velocity
Direction
Velocity is c...
Does anybody have a PHP (or other language) script for drawing a spiral. A simple (Archimedean spiral) would be just fine. Of course the principle is simple but coding it in SVG or GD would take some time, so I wonder if somebody has one ready :-)
...
hey guys i have a textfile i have divided it into 4 parts. i want to search each part for the words that appear in each part and score that word
exmaple
welcome to the national basketball finals,the basketball teams here today have come a long way. without much delay lets play basketball.
i will want to return national = 1 as it appe...
Let's say you wanted to implement a breadth-first search of a binary tree recursively. How would you go about it?
Is it possible using only the call-stack as auxiliary storage?
...
Given an STL vector, output only the duplicates in sorted order, e.g.,
INPUT : { 4, 4, 1, 2, 3, 2, 3 }
OUTPUT: { 2, 3, 4 }
The algorithm is trivial, but the goal is to make it as efficient as std::unique(). My naive implementation modifies the container in-place:
My naive implementation:
void not_unique(vector<int>* pv)
{
if (!...
One of my friend been asked with a question, Retrieving the max top 100 numbers from one hundred million of numbers, in a recent job interview. Do you have any idea to come up with an efficient way to solve it?
regards!
...
Hi,
I've implemented this search algorithm for an ordered array of integers. It works fine for the first data set I feed it (500 integers), but fails on longer searches. However, all of the sets work perfectly with the other four search algorithms I've implemented for the assignment.
This is the function that returns a seg fault on lin...
I need help designing an algorithm for recommendations on movies.
Every user in the system grades movies on a score between 1-100.
Tables consist of:
Table Movies
ID Name Year Rating Runtime
Table Con_MoviesToGenres
MovieID GenreID
Table Con_MovieToUser
MovieID UserID Grade
I'm trying to build a SELECT query t...
Hi, I am unsure how to put this and my math skills aren't that strong. But here's what I need.
I want to generate a list of all the 16bit integers (0-65535). But everytime I do so I want to seed the algorithm randomly that each time the list starts with a different integer and all the subsequent integers will be generated once but also ...
Does anyone know good scalable implementation of SVD on C# for very big matrix?
...
Hi,
When I have implemented binary trees , one of the first utilities one writes is a visualization function that given a tree prints it to the screen.
using cout function to print it every time like a stack is probleme to me , I can't represent the value of my job .
Printing trees properly in ASCII is quite difficult to understand.Mea...