Search Results

Search found 5655 results on 227 pages for 'stl algorithm'.

Page 18/227 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Need some clarification on Bankers Algorithm

    - by Moonshield
    Hi, just a quick query about safe/unsafe states in Dijkstra's Banker's algorithm... If one of the processes in the snapshot of the system (for example the one below) already has all of its needs fulfilled and there are not sufficient resources available to fulfil the needs of any of the other processes, is the system in a safe state? I know normally we assume that once a process receives its required resources it will terminate soon after and return all resources, but is this assumption factored in when we calculate the state of the system? Allocated Maximum Available | A | B | A | B A | B ---+---+--- ---+---+--- ---+--- P1 | 1 | 2 P1 | 1 | 2 1 | 3 P2 | 5 | 3 P2 | 7 | 8

    Read the article

  • Algorithm to generate a list of unique combinations based on a list of numbers

    - by ross
    I would like to efficiently generate a unique list of combinations of numbers based on a starting list of numbers. example start list = [1,2,3,4,5] but the algorithm should work for [1,2,3...n] result = [1],[2],[3],[4],[5] [1,2],[1,3],[1,4],[1,5] [1,2,3],[1,2,4],[1,2,5] [1,3,4],[1,3,5],[1,4,5] [2,3],[2,4],[2,5] [2,3,4],[2,3,5] [3,4],[3,5] [3,4,5] [4,5] Note. I don't want duplicate combinations, although I could live with them, eg in the above example I don't really need the combination [1,3,2] because it already present as [1,2,3]

    Read the article

  • Machine Learning Algorithm for Parallel Nodes

    - by FreshCode
    I want to apply machine learning to a classification problem in a parallel environment. Several independent nodes, each with multiple on/off sensors, can communicate their sensor data with the goal of classifying an event defined by a heuristic, training data or both. Each peer will be measuring the same data from their unique perspective and will attempt to classify the result while taking into account that any neighbouring node (or its sensors or just the connection to the node) could be faulty. Nodes should function as equal peers and determine the most likely classification by communicating their results. Ultimately each node should make a decision based on their own sensor data and their peers' data. If it matters, false positives are OK (albeit undesirable) but false negatives are totally unacceptable. Given that each final classification will receive good or bad feedback, what would be an appropriate machine learning algorithm to approach this problem with if the nodes could communicate with each other to determine the most likely classification?

    Read the article

  • Algorithm - Pick the best combination of Armor (for a game)

    - by Chu
    I'm designing a piece of a game where the AI needs to determine which combination of armor will give the best overall stat bonus to the character. Each character will have about 10 stats, of which only 3-4 are important, and of those important ones, a few will be more important than the others. Armor will also give a boost to 1 or all stats. For example, a shirt might give +4 to the character's int and +2 stamina while at the same time, a pair of pants may have +7 strength and nothing else. So let's say that a character has a healthy choice of armor to use (5 pairs of pants, 5 pairs of gloves, etc.) We've designated that Int and Perception are the most important stats for this character. How could I write an algorithm that would determine which combination of armor and items would result in the highest of any given stat (say in this example Int and Perception)?

    Read the article

  • Algorithm to aggregate values from child tree nodes

    - by user222164
    I have objects in a tree structure, I would like to aggregate status information from children nodes and update parent node with aggregated status. Lets say node A has children B1, B2, and B1 has C1, C2, C3 as children. Each of the nodes have a status attribute. Now if C1, C2, C3 are all complete then I would like to mark B1 as completed. And if C4, C5,C6,C7 are complete make B2 as complete. When B1 and B2 are both complete mark A as complete. I can go through these nodes in brute force method and make updates, could someone suggest an efficient algorithm to do it. A { B1 { C1, C2, C3}, B2 { C4, C5, C6, C7} }

    Read the article

  • Matrix Comparison algorithm

    - by SysAdmin
    If you have 2 Matrices of dimensions N*M. what is the best way to get the difference Rect? Example: 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 4 5 4 3 2 3 <---> 2 3 2 3 2 3 2 3 2 3 4 5 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 | | \ / Rect([2,2] , [3,4]) 4 5 4 4 5 2-> A (2 x 3 Matrix) The best I could think of is to scan from Top-Left hit the point where there is difference. Then scan from Bottom Right and hit the point where there is a difference. But In worst case, this is O(N*M). is there a better efficient algorithm?

    Read the article

  • Redundancy algorithm for reading noisy bitstream

    - by Tedd Hansen
    I'm reading a lossy bit stream and I need a way to recover as much usable data as possible. There can be 1's in place of 0's and 0's in palce of 1's, but accuracy is probably over 80%. A bonus would be if the algorithm could compensate for missing/too many bits as well. The source I'm reading from is analogue with noise (microphone via FFT), and the read timing could vary depending on computer speed. I remember reading about algorithms used in CD-ROM's doing this in 3? layers, so I'm guessing using several layers is a good option. I don't remember the details though, so if anyone can share some ideas that would be great! :) Edit: Added sample data Best case data: in: 0000010101000010110100101101100111000000100100101101100111000000100100001100000010000101110101001101100111000101110000001001111011001100110000001001100111011110110101011100111011000100110000001000010111 out: 0010101000010110100101101100111000000100100101101100111000000100100001100000010000101110101001101100111000101110000001001111011001100110000001001100111011110110101011100111011000100110000001000010111011 Bade case (timing is off, samples are missing): out: 00101010000101101001011011001110000001001001011011001110000001001000011000000100001011101010011011001 in: 00111101001011111110010010111111011110000010010000111000011101001101111110000110111011110111111111101 Edit2: I am able to controll the data being sent. Currently attempting to implement simple XOR checking (though it won't be enough).

    Read the article

  • Algorithm to classify a list of products?

    - by Martin
    I have a list representing products which are more or less the same. For instance, in the list below, they are all Seagate hard drives. Seagate Hard Drive 500Go Seagate Hard Drive 120Go for laptop Seagate Barracuda 7200.12 ST3500418AS 500GB 7200 RPM SATA 3.0Gb/s Hard Drive New and shinny 500Go hard drive from Seagate Seagate Barracuda 7200.12 Seagate FreeAgent Desk 500GB External Hard Drive Silver 7200RPM USB2.0 Retail For a human being, the hard drives 3 and 5 are the same. We could go a little bit further and suppose that the products 1, 3, 4 and 5 are the same and put in other categories the product 2 and 6. We have a huge list of products that I would like to classify. Does anybody have an idea of what would be the best algorithm to do such thing. Any suggestions? I though of a Bayesian classifier but I am not sure if it is the best choice. Any help would be appreciated! Thanks.

    Read the article

  • Optimal sorting algorithm with modified cost... [closed]

    - by David
    The numbers are in a list that is not sorted and supports only one type of operation. The operation is defined as follows: Given a position i and a position j the operation moves the number at position i to position j without altering the relative order of the other numbers. If i j, the positions of the numbers between positions j and i - 1 increment by 1, otherwise if i < j the positions of the numbers between positions i+1 and j decreases by 1. This operation requires i steps to find a number to move and j steps to locate the position to which you want to move it. Then the number of steps required to move a number of position i to position j is i+j. Design an algorithm that given a list of numbers, determine the optimal(in terms of cost) sequence of moves to rearrange the sequence.

    Read the article

  • Algorithm to match natural text in mail

    - by snøreven
    I need to separate natural, coherent text/sentences in emails from lists, signatures, greetings and so on before further processing. example: Hi tom, last monday we did bla bla, lore Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. list item 2 list item 3 list item 3 Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid x ea commodi consequat. Quis aute iure reprehenderit in voluptate velit regards, K. ---line-of-funny-characters-####### example inc. 33 evil street, london mobile: 00 234534/234345 Ideally the algorithm would match only the bold parts. Is there any recommended approach - or are there even existing algorithms for that problem? Should I try approximate regular expressions or more statistical stuff based on number of punctation marks, length and so on?

    Read the article

  • Algorithm for redirecting the traffic

    - by TechGeeky
    I was going through the interview questions and found out the below question which I am not able to answer it. Can anyone provide some sort of algorithm for this problem how can I solve it? There are a cluster of stateless servers all serving the same pages. The servers are hosting 5 web pages- p1.html, p2.html, p3.html, p4.html and p5.html p1.html just redirects users to the other 4 pages Requests to p1.html should result in 10% of users being redirected to p2.html, 5% of users redirected to p3.html, 20% of users redirected to p4.html, and 65% of users redirected to p5.html. Users do not need to stick to the page they are first redirected to. They could end up on a different page with every request to p1.html Write a function/pseudocode that would be invoked with every request to p1.html and redirect the correct percentage of users to the correct page. Any suggestions will be of great help.

    Read the article

  • Correct formulation of the A* algorithm

    - by Eli Bendersky
    Hello, I'm looking at definitions of the A* path-finding algorithm, and it seems to be defined somewhat differently in different places. The difference is in the action performed when going through the successors of a node, and finding that a successor is on the closed list. One approach (suggested by Wikipedia, and this article) says: if the successor is on the closed list, just ignore it Another approach (suggested here and here, for example) says: if the successor is on the closed list, examine its cost. If it's higher than the currently computed score, remove the item from the closed list for future examination. I'm confused - which method is correct ? Intuitively, the first makes more sense to me, but I wonder about the difference in definition. Is one of the definitions wrong, or are they somehow isomorphic ?

    Read the article

  • Algorithm for condensing/consolidating number combinations

    - by user1404383
    Using a horse race betting scenario, say I have a number of separate bets for predicting the first 4 finishers of the race (superfecta). The bets are as follows... 1/2/3/4 1/2/3/5 1/2/4/3 1/2/4/5 1/2/5/3 1/2/5/4 What I want to do is combine or condense these separate combinations as much as possible. For the bets above, they can be all condensed into 1 line... 1/2/3,4,5/3,4,5 What would algorithm look like for this?

    Read the article

  • Neural Network Basics

    - by Stat Onetwothree
    I'm a computer science student and for this years project, I need to create and apply a Genetic Algorithm to something. I think Neural Networks would be a good thing to apply it to, but I'm having trouble understanding them. I fully understand the concepts but none of the websites out there really explain the following which is blocking my understanding: How the decision is made for how many nodes there are. What the nodes actually represent and do. What part the weights and bias actually play in classification. Could someone please shed some light on this for me? Also, I'd really appreciate it if you have any similar ideas for what I could apply a GA to. Thanks very much! :)

    Read the article

  • Explain this O(n log n) algorithm for the Cat/Egg Throwing Problem

    - by ripper234
    This problem (How many cats you need to throw out of a building in order to determine the maximal floor where such a cat will survive. Quite cruel, actually), has an accepted answer with O(n^3) complexity. The problem is equivalent to this Google Code Jam, which should be solvable for N=2000000000. It seems that the O(n^3) solution is not good enough to solve it. From looking in the solutions page, jdmetz's solution (#2) seems to be O(n log n). I don't quite understand the algorithm. Can someone explain it? Edit

    Read the article

  • Parallelizing a serial algorithm

    - by user643813
    Hej folks, I am working on porting a Text mining/Natural language application from single-core to a Map-Reduce style system. One of the steps involves a while loop similar to this: Queue<Element>; while (!queue.empty()) { Element e = queue.next(); Set<Element> result = calculateResultSet(e); if (!result.empty()) { queue.addAll(result); } } Each iteration depends on the result of the one before (kind of). There is no way of determining the number of iterations this loop will have to perform. Is there a way of parallelizing a serial algorithm such as this one? I am trying to think of a feedback mechanism, that is able to provide its own input, but how would one go about parallelizing it? Thanks for any help/remarks

    Read the article

  • elastic / snaking line algorithm

    - by vhdirk
    Hi everyone I am making a graphics application in which I can edit a polyline by dragging the control point of it. However, I'd like to make it a bit easier to use by making it elastic; When dragging a control point, instead of moving a single point, I'd like the points within a certain distance of that point to be moved as well, depending on how hard the control point is 'pulled'. Does anyone know a simple algorithm for this? It may be quite rudimentary, as the primary requirement is speed. Actually, knowing how to call such behaviour would also be nice, so I can look it up on google. I tried 'snaking' line, but that seems to refer to active contours, which isn't what I'm looking for. Thanks

    Read the article

  • algorithm to combine data for linear fit?

    - by BoldlyBold
    I'm not sure if this is the best place to ask this, but you guys have been helpful with plenty of my CS homework in the past so I figure I'll give it a shot. I'm looking for an algorithm to blindly combine several dependent variables into an index that produces the best linear fit with an external variable. Basically, it would combine the dependent variables using different mathematical operators, include or not include each one, etc. until an index is developed that best correlates with my external variable. Has anyone seen/heard of something like this before? Even if you could point me in the right direction or to the right place to ask, I would appreciate it. Thanks.

    Read the article

  • Algorithm of JavaScript "sort()" Function

    - by Knowledge Craving
    Recently when I was working with JavaScript "sort()" function, I found in one of the tutorials that this function does not sort the numbers properly. Instead to sort numbers, a function must be added that compares numbers, like the following code:- <script type="text/javascript"> function sortNumber(a,b) { return a - b; } var n = ["10", "5", "40", "25", "100", "1"]; document.write(n.sort(sortNumber)); </script> The output then comes as:- 1,5,10,25,40,100 Now what I didn't understand is that why is this occurring & can anybody please tell in details as to what type of algorithm is being used in this "sort()" function? This is because for any other language, I didn't find this problem where the function didn't sort the numbers correctly. Any help is greatly appreciated.

    Read the article

  • Render rivers in a grid.

    - by Gabriel A. Zorrilla
    I have created a random height map and now i want to create rivers. I've made an algorithm based on a* to make rivers flow from peaks to sea and now i'm in the quest of figuring out an elegant algorithm to render them. It's a 2D, square, mapgrid. The cells which the river pases has a simple integer value with this form :rivernumber && pointOrder. Ie: 10, 11, 12, 13, 14, 15, 16...1+N for the first river, 20,21,22,23...2+N for the second, etc. This is created in the map grid generation time and it's executed just once, when the world is generated. I wanted to treat each river as a vector, but there is a problem, if the same river has branches (because i put some noise to generate branches), i can not just connect the points in order. The second alternative is to generate a complex algorithm where analizes each point, checks if the next is not a branch, if so trigger another algorithm that take care of the branch then returns to the main river, etc. Very complex and inelegant. Perhaps there is a solution in the world generation algorithm or in the river rendering algorithm that is commonly used in these cases and i'm not aware of. Any tips? Thanks!!

    Read the article

  • Resultant Vector Algorithm for 2D Collisions

    - by John
    I am making a Pong based game where a puck hits a paddle and bounces off. Both the puck and the paddles are Circles. I came up with an algorithm to calculate the resultant vector of the puck once it meets a paddle. The game seems to function correctly but I'm not entirely sure my algorithm is correct. Here are my variables for the algorithm: Given: velocity = the magnitude of the initial velocity of the puck before the collision x = the x coordinate of the puck y = the y coordinate of the puck moveX = the horizontal speed of the puck moveY = the vertical speed of the puck otherX = the x coordinate of the paddle otherY = the y coordinate of the paddle piece.horizontalMomentum = the horizontal speed of the paddle before it hits the puck piece.verticalMomentum = the vertical speed of the paddle before it hits the puck slope = the direction, in radians, of the puck's velocity distX = the horizontal distance between the center of the puck and the center of the paddle distY = the vertical distance between the center of the puck and the center of the paddle Algorithm solves for: impactAngle = the angle, in radians, of the angle of impact. newSpeedX = the speed of the resultant vector in the X direction newSpeedY = the speed of the resultant vector in the Y direction Here is the code for my algorithm: int otherX = piece.x; int otherY = piece.y; double velocity = Math.sqrt((moveX * moveX) + (moveY * moveY)); double slope = Math.atan(moveX / moveY); int distX = x - otherX; int distY = y - otherY; double impactAngle = Math.atan(distX / distY); double newAngle = impactAngle + slope; int newSpeedX = (int)(velocity * Math.sin(newAngle)) + piece.horizontalMomentum; int newSpeedY = (int)(velocity * Math.cos(newAngle)) + piece.verticalMomentum; for those who are not program savvy here is it simplified: velocity = v(moveX² + moveY²) slope = arctan(moveX / moveY) distX = x - otherX distY = y - otherY impactAngle = arctan(distX / distY) newAngle = impactAngle + slope newSpeedX = velocity * sin(newAngle) + piece.horizontalMomentum newSpeedY = velocity * cos(newAngle) + piece.verticalMomentum My Question: Is this algorithm correct? Is there an easier/simpler way to do what I'm trying to do?

    Read the article

  • compare function for upper_bound / lower_bound

    - by Martin Beckett
    I want to find the first item in a sorted vector that has a field less than some value x. I need to supply a compare function that compares 'x' with the internal value in MyClass but I can't work out the function declaration. Can't I simply overload '<' but how do I do this when the args are '&MyClass' and 'float' ? float x; std::vector< MyClass >::iterator last = std::upper_bound(myClass.begin(),myClass.end(),x);

    Read the article

  • algorithms that destruct and copy_construct

    - by FredOverflow
    I am currently building my own toy vector for fun, and I was wondering if there is something like the following in the current or next standard or in Boost? template<class T> void destruct(T* begin, T* end) { while (begin != end) { begin -> ~T(); ++begin; } } template<class T> T* copy_construct(T* begin, T* end, T* dst) { while (begin != end) { new(dst) T(*begin); ++begin; ++dst; } return dst; }

    Read the article

  • Is there a perfect algorithm for chess?

    - by Overflown
    Dear Stack Overflow community, I was recently in a discussion with a non-coder person on the possibilities of chess computers. I'm not well versed in theory, but think I know enough. I argued that there could not exist a deterministic Turing machine that always won or stalemated at chess. I think that, even if you search the entire space of all combinations of player1/2 moves, the single move that the computer decides upon at each step is based on a heuristic. Being based on a heuristic, it does not necessarily beat ALL of the moves that the opponent could do. My friend thought, to the contrary, that a computer would always win or tie if it never made a "mistake" move (however do you define that?). However, being a programmer who has taken CS, I know that even your good choices - given a wise opponent - can force you to make "mistake" moves in the end. Even if you know everything, your next move is greedy in matching a heuristic. Most chess computers try to match a possible end game to the game in progress, which is essentially a dynamic programming traceback. Again, the endgame in question is avoidable though. -- thanks, Allan Edit: Hmm... looks like I ruffled some feathers here. That's good. Thinking about it again, it seems like there is no theoretical problem with solving a finite game like chess. I would argue that chess is a bit more complicated than checkers in that a win is not necessarily by numerical exhaustion of pieces, but by a mate. My original assertion is probably wrong, but then again I think I've pointed out something that is not yet satisfactorily proven (formally). I guess my thought experiment was that whenever a branch in the tree is taken, then the algorithm (or memorized paths) must find a path to a mate (without getting mated) for any possible branch on the opponent moves. After the discussion, I will buy that given more memory than we can possibly dream of, all these paths could be found.

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >