This little project / problem came out of left field for me. Hoping someone can help me here. I have some rough ideas but I am sure (or at least I hope) a simple, fairly efficient solution exists.
Thanks in advance.... pseudo code is fine. I generally work in .NET / C# if that sheds any light on your solution.
Given:
A pool of n indiv...
FYI: no boost, yes it has this, I want to reinvent the wheel ;)
Is there some form of a selective iterator (possible) in C++? What I want is to seperate strings like this:
some:word{or other
to a form like this:
some : word { or other
I can do that with two loops and find_first_of(":") and ("{") but this seems (very) inefficient t...
Not a real question because I already found out the answer, but still interesting thing.
I always thought that hash table is the fastest associative container if you hash properly.
However, the following code is terribly slow. It executes only about 1 million iterations and takes more than 2 minutes of time on a Core 2 CPU.
The code ...
Hi, I'm trying to search the parent of a node with Kruskal's algorithm. My program works just fine, but I think I have heard of a method to improve the speed of the algorithm by reconstructing the tree while searching for the parent node and connecting it to the parent node. I'm pretty sure that I've heard of this somewhere, maybe in a l...
I am looking for an algorithm to wrap text within a non-rectangular shape, preferably based on the Knuth and Plass algorithm. The hardest part of this is that the lines may have different heights due to differing font sizes in the text. The image below is an example of what the algorithm should be able to generate.
Thanks for any hel...
I have made this function to calculate color differences in the CIE Lab colorspace, but it lacks speed. Since I'm not a Java expert, I wonder if any Java guru around has some tips that can improve the speed here.
The code is based on the matlab function mentioned in the comment block.
/**
* Compute the CIEDE2000 color-difference betwe...
how can i create method which return sqrt of given nunber? for example sqrt(16) returns 4
and sqrt(5) returns 2.3... please help i am using java and know Math.sqrt() API function but i need method itself
...
Hi,
I have a grid of data that I want to export to RTF, PDF etc. using various (and not perfect) PHP converters/generators.
What I am missing most is the HTML table automatic adjustment of column widths based on the lengths of strings in the cells (strings contain line breaks which complicate things a bit, as they should be preserved)....
I would like to create a game with an endless (in reality an extremely large) world in which the player can move about. Whether or not I will ever get around to implement the game is one matter, but I find the idea interesting and would like some input on how to do it.
The point is to have a world where all data is generated randomly o...
we know algorithm how reverse array of n integers
for (int i=0;i<n/2;i++){
swap(a[i],a[n-1-i]):
}
is this method better according the speed of algorithm or not because swap using xor is more fast then in other method
here is code
public class swap {
public static void main(String[]args){
int a[]=new int[]{2,4,5,...
For a map where the key represents a number of a sequence and the value the count how often this number appeared in the squence, how would an implementation of an algorithm in java look like to calculate the median?
For example:
1,1,2,2,2,2,3,3,3,4,5,6,6,6,7,7
in a map:
Map<Int,Int> map = ...
map.put(1,2)
map.put(2,4)
map.put(3,3)
m...
Given a free text, I need to analyse this this text and suggest a list of tags from a pre existing list.
What algorithms are out there in the market?
Can they handle a case where, for example, the text have a word like
high cholesterol
and I would like it so suggest
heart disease
although "high cholesterol" might not exists...
Hi
I have a collection of points which describe the surface of a shape that should be roughly spherical, and I need a method with which to determine if any other given point lies within this shape. I've previously been approximating the shape as an exact sphere, but this has proven too inaccurate and I need a more accurate method. Simpl...
Hello,
I have a very large database of articles, of varying lengths. The articles have HTML elements in them. I have to insert some ads (simple <script> elements) in the body of each article when it is displayed (I know, I hate ads that interrupt my reading too).
Now, the problem is that each ad must be inserted at about the same posit...
I was going though problems on graph theory posted by Prof. Ericksson from my alma-mater and came across this rather unique question about pigeons and their innate tendency to form pecking orders. The question goes as follows:
Whenever groups of pigeons gather,
they instinctively establish a pecking
order. For any pair of pigeons...
I'm studying for upcoming interviews and have encountered this question several times (written verbatim)
Find or determine non existence of a number in a sorted list of N numbers where the numbers range over M, M >> N and N large enough to span multiple disks. Algorithm to beat O(log n); bonus points for constant time algorithm.
F...
I have a data structure containing a list of objects, like this:
class A {
private List<Object> list;
}
How to properly define a hash function for the list, assuming each element of the list has correct hashCode()?
(It's strange that I couldn't easily find the solution via Google.)
...
A system has a notation that would require writing an expression like (A+B)*C as #MUL(#ADD(A,B),C). Is there already an algorithm to do this kind of notation conversion so users can enter in a more conventional way?
In other words an algorithm to convert from infix -> my notation. First issue is I don't know an exact name for my notation...
I understand that Gang scheduling is a scheduling algorithm for parallel systems that schedules related threads or processes to run simultaneously on different processors.
Gang scheduling is used so that if two or more threads or processes communicate with each other, they will all be ready to communicate at the same time. However, how...
It's a pretty normal binary tree, except for the fact that one of the nodes may be empty.
I'd like to find a way to output it in a horizontal way (that is, the root node is on the left and expands to the right).
I've had some experience expanding trees vertically (root node at the top, expanding downwards), but I'm not sure where to st...