breadth first or depth first search
I know how this algorithm works, but cant decide when to use which algorithm ? Are there some guidelines, where one better perform than other or any considerations ? Thanks very much. ...
I know how this algorithm works, but cant decide when to use which algorithm ? Are there some guidelines, where one better perform than other or any considerations ? Thanks very much. ...
I have a semicolon-separated list of values, for example: strins s = "param1=true;param2=4;param3=2.0f;param4=sometext;"; I need a functions: public bool ExtractBool(string parameterName, string @params); public int ExtractInt(string parameterName, string @params); public float ExtractFloat(string parameterName, string @params); publ...
Given a vector X of size L, where every scalar element of X is from a binary set {0,1}, it is to find a dot product z=dot(X,Y) if vector Y of size L consists of the integer-valued elements. I suggest, there must exist a very fast way to do it. Let's say we have L=4; X[L]={1, 0, 0, 1}; Y[L]={-4, 2, 1, 0} and we have to find z=X[0]*Y[0] +...
Dear ladies and sirs. The standard string representation of GUID takes about 36 characters. Which is very nice, but also really wasteful. I am wondering, how to encode it in the shortest possible way using all the ASCII characters in the range 33-127. The naive implementation produces 22 characters, simply because 128 bits / 6 bits yiel...
Hi guys, I am implementing Naive Bayesian classifier for spam filtering. I have doubt on some calculation. Please clarify me what to do. Here is my question. In this method, you have to calculate P(S|W) -> Probability that Message is spam given word W occurs in it. P(W|S) -> Probability that word W occurs in a spam message. P(W...
I've got an interresting problem: Given an IEnumerable<string>, is it possible to yield a sequence of IEnumerable<string> that groups identical adjacent strings in one pass? Let me explain. 1. Basic illustrative sample : Considering the following IEnumerable<string> (pseudo representation): {"a","b","b","b","c","c","d"} How to get...
What algorithms (brute force or not) would I use to put in as many cars (assume all cars are the same size) in a parking lot so that there is at least one exit (from the container) and a car cannot be blocked. Or can someone show me an example of this problem solved programmatically. The parking lot varies in shape would be nice but if ...
I have a set of trajectories, made up of points along the trajectory, and with the coordinates associated with each point. I store these in a 3d array ( trajectory, point, param). I want to find the set of r trajectories that have the maximum accumulated distance between the possible pairwise combinations of these trajectories. My first ...
Hey, Does anyone know a fast algorithm for evaluating 7 card poker hands? Something which is more efficient than simply brute-force checking a every 21 5-card combination of hands from a set of 7. Cheers, Pete ...
I'm implementing a stack-based VM and I've been trying to read up on literature that explains or outlines algorithms for dealing with stacks no no avail. Here's an example: int i = 3 int j = 4 int k = 5 Lets assume i, j, and k are local variables so they would be traditionally stored on the stack. The assembly/bytecode translation wou...
I spent quite a long time searching for a solution to this problem. I drew tons of cross-hatched triangles, counted the triangles in simple cases, and searched for some sort of pattern. Unfortunately, I hit the wall. I'm pretty sure my programming/math skills did not meet the prereq for this problem. So I found a solution online in ord...
Hi all, I'm working on an information system (in C#) that (while my users use it) gathers statistical data on what pieces of information (tables & records) each user is requesting the most, and what parts of the interface he/she uses most. I'm using this statistical data to make the application adaptive to the user's needs, both in the...
Hi; I'm sure you've all heard of the "Word game", where you try to change one word to another by changing one letter at a time, and only going through valid English words. I'm trying to implement an A* Algorithm to solve it (just to flesh out my understanding of A*) and one of the things that is needed is a minimum-distance heuristic. ...
I could understand the following search algorithms: Constraint Satisfaction with Arc Consistency, Uninformed search A* Search MinMax I would understand the definition and working principles of the above algorithm,but could you please give me some real world examples that the above algorithms will be suitable?My idea would be: For CSP...
hello. just out of curiosity I tried to do the following, which turned out to be not so obvious to me; Suppose I have nested loops with runtime bounds, for example: t = 0 // trip count for l in 0:N for k in 0:N for j in max(l,k):N for i in k:j+1 t += 1 t is loop trip count is there a general algorithm/...
What is wrong here? I want delete an item from an array, but it shows me error ArrayIndexOutBound exception public class delete { public static void main(String[]args) { int i; //delete item from array int k[] = new int[]{77,99,44,11,00,55,66,33,10}; //delete 55 int searchkey=55; ...
Hi, I know how to find the centroid (center of mass) of a regular polygon. This assumes that every part of the polygon weighs the same. But how do I calculate the centroid of a weightless polygon (made from aerogel perhaps :), where each vertex has a weight? Simplified illustration of what I mean using straight line: 5kg-------------...
Hi, I need a solution for quite complex problem. Exactly, I need to calculate the number of rectangles that can be placed inside letter/character with given size, considering that all rectangles are the same size, but it(the size) and the letter/character(of some regular specific font) itself can be changed by user(this will be used as w...
R= repeats allowed -> 2 A= alphabet (1-10) S= space = 4; So we want example: [1][1][4][5] [1][7][4][5] [5][1][4][5] But need a fancy math formula to calculate this and all combinations ? ...
Hey, I have a need to mirror a byte's value around the centre of 128. So, example outputs of this function include: In 0 Out 255 In 255 Out 0 In 128 Out 128 In 127 Out 129 In 30 Out 225 In 225 Out 30 I'm driving myself nuts with this, I'm sure I'll kick myself when I read the answers. Cheers ...