Hi
There are thousands of rays and triangles. We need get all the intersection points. If we use the normal two level loops,we need O(m*n) time complexity.Is there any way to low the time complexity fronm O(m*n) to O(m* logn) or O(logm*n)?
Best Regards,
...
Hi guys i am trying to compare 2 algorithms and thought i may try and write a proof for them !!! (my maths sucks so hence the question)
Normally in our math lesson last year we would be given a question like
prove: (2r + 3) = n (n + 4)
then i would do the needed 4 stages and get the answer at the end
Where i am stuck is proving prim...
As the title...
What is the best way to find all combinations of items in an array in c#?
...
When copying data from one range to another, you have to be careful if there's partial overlap between the source and destination ranges. If the beginning of the destination range overlaps the tail of the source range, a plain sequential copy will garble the data. The C run-time library has memmove in addition to memcopy to handle such...
Hi, so I need to write an efficient algorithm for looking up words with missing letters in a dictionary and I want the set of possible words.
For example, if I have th??e, I might get back these, those, theme, there.etc.
I was wondering if anyone can suggest some data structures or algorithm I should use.
Thanks!
EDIT: A Trie is too ...
I've found a number of different questions on generating UIDs, but as far as I can tell, my requirements here are somewhat unique (ha).
To summarize: I need to generate a very short ID that's "locally" unique, but does not have to be "globally" or "universally" unique. The constraints are not simply based on aesthetic or space concerns...
I am applying the all-pairs shortest path algorithm (Floyd-Warshall) to this directed graph:
The graph is represented by its adjacency matrix. The simple code looks like this:
public class ShortestPath {
public static void main(String[] args) {
int x = Integer.MAX_VALUE;
int [][] adj= {
{0, 6, x, 6, 7},
...
I'm trying to build an A* solver for a 15-square puzzle.
The goal is to re-arrange the tiles so that they appear in their natural positions. You can only slide one tile at a time. Each possible state of the puzzle is a node in the search graph.
For the h(x) function, I am using an aggregate sum, across all tiles, of the tile's dis...
I am currently reading "programming principles and practice using c++" in chapter 4 there is an exercise in which i need to make a program to calculate prime numbers between 1 and 100.
This is the program i came up with.
#include <vector>
#include <iostream>
using namespace std;
//finds prime numbers using Sieve of Eratosthenes algor...
I'm using the Perl client of beanstalkd. I need a simple way to not enqueue the same work twice.
I need something that needs to basically wait until there are K elements, and then groups them together. To accomplish this, I have the producer:
insert item(s) into DB
insert a queue item into beanstalkd
And the consumer:
while ( 1 ) ...
Using STL, I want to find the last instance of a certain value in a sequence.
This example will find the first instance of 0 in a vector of ints.
#include <algorithm>
#include <iterator>
#include <vector>
typedef std::vector<int> intvec;
intvec values;
// ... ints are added to values
intvec::const_iterator split = std::find(values.beg...
I have a HTML document, a list of common spelling mistakes, and the correct spelling for each case.
The HTML documents will be up to ~50 pages and there are ~30K spelling correction entries.
What is an efficient way to correct all spelling mistakes in this HTML document?
(Note: my implementation will be in Python, in case you know of an...
Is there someplace where I can get a Big-O style analysis / comparison of traditional data structures such as linked lists, various trees, hashes, etc vs. cache aware data structures such as Judy trees and others?
...
hi all,
i am new to iPhone.
i want to know which Encryption /decryption algorithm is supported by iPhone ?
please suggest or provide me some helpful link
...
hello !!
i try to program radix sort , but i have NullPointerException when i run this code
public class ThreeRadixSort {
public Queue getSortedData(Queue queue){
Queue array[] = new Queue[10];
for(int i=1;i<=3;i++){
while(queue.front != null){
Student student = queue.dequeue();
if( i == 1)
...
I'm interested in writing a small piece of sample code that communications via standard TCP/IP means to an application server. The idea here is that the client can speak to the application server and be authenticated by simply speaking in a specific text based protocol. The traffic will be encrypted, no username/password. If another app ...
I am learning algorithm analysis. I am having trouble understanding the difference between O, Ω, and Θ.
The way they're defined is as follows:
f(n) = O(g(n)) means c · g(n) is an
upper bound on f(n). Thus there exists
some constant c such that f(n) is
always ≤ c · g(n), for large enough n
(i.e., n ≥ n0 for some constant n...
I'v always wondered this. In a game like GTA where there are 10s of thousands of objects, how does the game know as soon as you're on a health pack?
There can't possibly be an event listener for each object? Iterating isn't good either? I'm just wondering how it's actually done.
...
Lets say I have 4 different values A,B,C,D with sets of identifiers attached.
A={1,2,3,4,5}
B={8,9,4}
C={3,4,5}
D={12,8}
And given set S of identifiers {1,30,3,4,5,12,8} I want it to return C and D. i.e. retrieve all sets from a group of sets for which S is a superset.
Is there any algorithms to perform this task efficiently (Prefer...
While studying the book "Introduction to Algorithms by Cormen", I found a strange thing. Everywhere if it refers to an increasing order, the book refers it as "non-decreasing" order.. I mean, if a series (2,5,6,3) is to be arranged in "non-decreasing" order.. is'nt it already right?? or "increasing" and "non-decreasing" words mean one an...