I'm building a heatmap-like rectangular array interface and I want the 'hot' location to be at the top left of the array, and the 'cold' location to be at the bottom right. Therefore, I need an array to be filled diagonally like this:
0 1 2 3
|----|----|----|----|
0 | 0 | 2 | 5 | 8 |
|----|----|----|----|
1 | 1 | 4...
It was kinda hard to go through Gecko's documentation to see how it renders a web page.
I'm doing some performance analysis for my projects across the leading browsers to see how to improve response time. I am aware of optimization techniques out there but I don't really understand their basis--which I believe would be resolved if I kne...
Many of the location based services provide APIs for finding places/venues/spots around a given latitude longitude pair. I'm looking into how I can search for these places across an entire city.
I can build a grid for a city by getting its bounds from the Google Maps Geocoder and then incrementing the lat/longs to lay down points to fo...
I'm facing an interesting problem:
I have several date ranges that can overlap
each of them has a name
Is it possible to "des-overlap" theses ranges? That is, to generate:
a new set of ranges where none overlaps the others
each of this new range has a list of corresponding names
Maybe I can make this a bit more graphical. This i...
Given is an array of 320 elements (int16), which represent an audio signal (16-bit LPCM) of 20 ms duration. I am looking for a most simple and very fast method which should decide whether this array contains active audio (like speech or music), but not noise or silence. I don't need a very high quality of the decision, but it must be v...
Hi!
Assume we have an array of length N where the subarrays from 0 to N/2 and N/2 to N elements are sorted. Is it possible to sort the whole array using constant memory in O(N) time?
Example of an array:
10, 20, 30, 40, 1, 2, 35, 60
...
I need to test some communication libraries and need to keep the server busy so that I can test timeouts, but I am unable to use sleep() as it causes problems during testing.
Is there a common algorithm I can use to keep a process busy? I'm not concerned with running the CPU hot, simply keeping the process from returning for a number of...
I've been studying Visibility issue in PHP (public, private, protected) and wondered how is this sort of "dom-building" is implemented in PHP? I mean there should be some kind of algorithm that PHP uses to go through all your classes and establish relations between them. Not sure if it is called "dom-building" though, but I think the sam...
template<typename T>
void traverse_binary_tree(BinaryTreeNode<T>* root,int order = 0)// 0:pre, 1:in , 2:post
{
if( root == NULL ) return;
if(order == 0) cout << root->data << " ";
traverse_binary_tree(root->left,order);
if(order == 1) cout << root->data << " ";
traverse_binary_tree(root->right,order);
if(orde...
This is not a homework. Just an interesting task :)
Given a complete binary search three represensted by array. Sort the array in O(n) using constant memory.
Example:
Tree:
8
/ \
4 12
/\ / \
2 6 10 14
/\ /\ /\ /\
1 3 5 7 9 11 13 15
Array:...
I want to implement a 5 star rating system on my site, and i have been trying use the bayesian rating algorithm explained here and here with no success. This is my scenario;
I have three items (A, B and C) that need to be rated by a vote of 1 for an UP vote and a 0 for DOWN vote. In the database i have the following;
Sum(A) = 500 UP ou...
Say you have an API that is not accessible to change:
List<LegacyObject> getImportantThingFromDatabase(Criteria c);
Imaging Legacy Object has a ton of fields and you want to extend it to make getting at certain information easier:
class ImprovedLegacyObject extends LegacyObject {
String getSomeFieldThatUsuallyRequiresIteratorsAndA...
Hi,
I have been tasked with coming up with a routine that will suggest alternative domain names to register if the customers original requested domain name is already registered.
The first step I think would be to split the requested domain back in to bits so that I could work out alternatives to try.
eg. mybigredtruck.com would be b...
I'm looking for an innovative way to check if a number has only one on bit in a signed int.
I am well aware that I can simply do a loop with a counter, some modular division, and a bit shift. But I'm curious if there is a better way since we are only looking for ONE bit to be on.
bool HasOnlyOneBit (int numb)
{
//return true if num...
Suppose there is a given number we should test if it is product of four consecutive numbers?
So if y is our given number we should test if y=x(x+1)(x+2)(x+3) for any arbitrary x?
How to design an algorithm for this problem?
I have done it like this:
import java.util.*;
public class _product
{
public static int product(int i)
...
High-level: Can I do this order by, group by based on sum
any faster? (PG 8.4, fwiw., on a non-tiny table .... think O(millions of rows) )
Suppose I had a table like this:
Table "public.summary"
Column | Type | Modifiers
-------------+-------------------+-----...
Hi all,
Im need to implement a Roulette Prediction System (Roulette Calculator).
The scenario is:
The player put on the system the values from roulette, and the system tip to him the best bet and the amount.
The system need to be able to tip the best bet, or the possible best bets.
What's the algorithm to solve that problem?
I'm reading...
I have a large graph that I am processing using JUNG. I was wondering if there JUNG provides a way to extract say a 2-hop neighborhood of a vertex (complete with all edges amongst themselves) into a separate graph?
...
What is the algorithm to convert a quadratic bezier (with 3 points) to a cubic one (with 4 points)
Thanks
...
I feel like my implementation is a bit naive. Take notice of the variables min in max which have a rather small precision of +/- 0.0001. If I raise the precision any further the code is just too slow.
Algorithm
Code
private IDynamic ToExponential(Engine engine, Args args)
{
var x = engine.Context.ThisBinding.ToNumberPrimitive()...