Search Results

Search found 5298 results on 212 pages for 'marching cubes algorithm'.

Page 12/212 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Time complexity of Sieve of Eratosthenes algorithm

    - by eSKay
    From Wikipedia: The complexity of the algorithm is O(n(logn)(loglogn)) bit operations. How do you arrive at that? That the complexity includes the loglogn term tells me that there is a sqrt(n) somewhere. Suppose I am running the sieve on the first 100 numbers (n = 100), assuming that marking the numbers as composite takes constant time (array implementation), the number of times we use mark_composite() would be something like n/2 + n/3 + n/5 + n/7 + ... + n/97 = O(n) And to find the next prime number (for example to jump to 7 after crossing out all the numbers that are multiples of 5), the number of operations would be O(n). So, the complexity would be O(n^2). Do you agree?

    Read the article

  • Algorithm for analyzing text of words

    - by Click Upvote
    I want an algorithm which would create all possible phrases in a block of text. For example, in the text: "My username is click upvote. I have 4k rep on stackoverflow" It would create the following combinations: "My username" "My Username is" "username is click" "is click" "is click upvote" "click upvote" "i have" "i have 4k" "have 4k" .. You get the idea. Basically the point is to get all possible combinations of 'phrases' out of a sentence. Any thoughts for how to best implement this?

    Read the article

  • Robust and fast checksum algorithm?

    - by bene
    Which checksum algorithm can you recommend in the following use case? I want to generate checksums of small JPEG files (~8 kB each) to check if the content changed. Using the filesystem's date modified is unfortunately not an option. The checksum need not be cryptographically strong but it should robustly indicate changes of any size. The second criterion is speed since it should be possible to process at least hundreds of images per second (on a modern CPU). The calculation will be done on a server with several clients. The clients send the images over Gigabit TCP to the server. So there's no disk I/O as bottleneck.

    Read the article

  • Modifying Bresenham's line algorithm

    - by sphennings
    I'm trying to use Bresenham's line algorithm to compute Field of View on a grid. The code I'm using calculates the lines without a problem but I'm having problems getting it to always return the line running from start point to endpoint. What do I need to do so that all lines returned run from (x0,y0) to (x1,y1) def bresenham_line(self, x0, y0, x1, y1): steep = abs(y1 - y0) > abs(x1 - x0) if steep: x0, y0 = y0, x0 x1, y1 = y1, x1 if x0 > x1: x0, x1 = x1, x0 y0, y1 = y1, y0 if y0 < y1: ystep = 1 else: ystep = -1 deltax = x1 - x0 deltay = abs(y1 - y0) error = -deltax / 2 y = y0 line = [] for x in range(x0, x1 + 1): if steep: line.append((y,x)) else: line.append((x,y)) error = error + deltay if error > 0: y = y + ystep error = error - deltax return line

    Read the article

  • How to generate a unique hash for a URL ?

    - by Jacques René Mesrine
    Given these two images from twitter. http://a3.twimg.com/profile_images/130500759/lowres_profilepic.jpg http://a1.twimg.com/profile_images/58079916/lowres_profilepic.jpg I want to download them to local filesystem & store them in a single directory. How shall I overcome name conflicts ? In the example above, I cannot store them as *lowres_profilepic.jpg*. My design idea is treat the URLs as opaque strings except for the last segment. What algorithms (implemented as f) can I use to hash the prefixes into unique strings. f( "http://a3.twimg.com/profile_images/130500759/" ) = 6tgjsdjfjdhgf f( "http://a1.twimg.com/profile_images/58079916/" ) = iuhd87ysdfhdk That way, I can save the files as:- 6tgjsdjfjdhgf_lowres_profilepic.jpg iuhd87ysdfhdk_lowres_profilepic.jpg I don't want a cryptographic algorithm as it this needs to be a performant operation.

    Read the article

  • Computational geometry: find where the triangle is after rotation, translation or reflection on a mi

    - by newba
    I have a small contest problem in which is given a set of points, in 2D, that form a triangle. This triangle may be subject to an arbitrary rotation, may be subject to an arbitrary translation (both in the 2D plane) and may be subject to a reflection on a mirror, but its dimensions were kept unchanged. Then, they give me a set of points in the plane, and I have to find 3 points that form my triangle after one or more of those geometric operations. Example: 5 15 8 5 20 10 6 5 17 5 20 20 5 10 5 15 20 15 10 I bet that have to apply some known algorithm, but I don't know which. The most common are: convex hull, sweep plane, triangulation, etc. Can someone give a tip? I don't need the code, only a push, please!

    Read the article

  • which is best algorithm?

    - by Lopa
    Consider two algorithms A and B which solve the same problem, and have time complexities (in terms of the number of elementary operations they perform) given respectively by a(n) = 9n+6 b(n) = 2(n^2)+1 (i) Which algorithm is the best asymptotically? (ii) Which is the best for small input sizes n, and for what values of n is this the case? (You may assume where necessary that n0.) i think its 9n+6. guys could you please help me with whether its right or wrong?? and whats the answer for part b. what exactly do they want?

    Read the article

  • jump search algorithm

    - by davit-datuashvili
    i am doing jump search algorithm but it show me that element is not in array while it is here is code import java.math.*; public class jamp { public static int min(int a,int b){ return a } public static void main(String[]args){ int a[]=new int[]{3,7,9,12,14,15,16,17,18}; int l=14; System.out.println(jumpsearch(a,a.length,l)); } public static int jumpsearch(int a[],int n, int l ){ int t=0; int b=(int)Math.sqrt(n); while (a[min(b,n)-1]=n) return -1 ; } while (a[t] return -1 ; if ( a[t]==l) { return t; } } return -1; } } please help

    Read the article

  • fast algorithm to sort very small set

    - by aaa
    hello. This is the problem I ran into long time ago. I thought I may ask your for your ideas. assume I have very small set of numbers (integers), 4 or 8 elements, that need to be sorted, fast. what would be the best approach/algorithm? my approach was to use the max/min functions only. At this point it becomes somewhat hardware dependent , so let us assume Intel 64-bit processor with SSE3 . Thanks

    Read the article

  • Tail-recursive pow() algorithm with memoization?

    - by Dan
    I'm looking for an algorithm to compute pow() that's tail-recursive and uses memoization to speed up repeated calculations. Performance isn't an issue; this is mostly an intellectual exercise - I spent a train ride coming up with all the different pow() implementations I could, but was unable to come up with one that I was happy with that had these two properties. My best shot was the following: def calc_tailrec_mem(base, exp, cache_line={}, acc=1, ctr=0): if exp == 0: return 1 elif exp == 1: return acc * base elif exp in cache_line: val = acc * cache_line[exp] cache_line[exp + ctr] = val return val else: cache_line[ctr] = acc return calc_tailrec_mem(base, exp-1, cache_line, acc * base, ctr + 1) It works, but it doesn't memorize the results of all calculations - only those with exponents 1..exp/2 and exp.

    Read the article

  • algorithm diagram

    - by tunl
    This is the max searching algorithm diagram: So, I wonder how can draw diagram for Recursion in HaNoi Tower program: package tunl; public class TowersApp { static int n = 3; public static void main(String[] args) { TowersApp.doTowers(3, 'A', 'B', 'C'); } public static void doTowers(int n, char from, char inter, char to) { if (n == 1) { System.out.println("disk 1 from "+ from + " to " + to); } else { doTowers(n-1, from, to, inter); System.out.println("disk " + n + " from " + from + " to " + to); doTowers(n-1, inter, from, to); } } } I can't draw it. Anyone can help me !!!

    Read the article

  • Looking for evolutionary music example code

    - by Dan Dyer
    I would like to implement an interactive evolutionary algorithm for generating music (probably just simple melodies to start with). I'd like to use JFugue for this. Its website claims that it is well-suited to evolutionary music, but I can't find any evolutionary examples. I already have a framework to provide the evolutonary machinery. What I am looking for is some simple, working code that demonstrates viable approaches for the musical part (e.g. suitable encodings and evolutionary operators for the evolved tunes). I have some ideas how it might be achieved, but I'm not particularly knowledgeable about music theory, so to start with I'd like to just reimplement something that is known to work. So does anybody have, or know of, any freely available code (any language is fine) that demonstrates one or more approaches to evolutionary music? EDIT: I'm specifically looking for evolutionary code rather than other techniques that could be used for music synthesis.

    Read the article

  • Heuristic algorithm for load balancing among threads.

    - by Il-Bhima
    I'm working on a multithreaded program where I have a number of worker threads performing tasks of unequal length. I want to load-balance the tasks to ensure that they do roughly the same amount of work. For task T_i I have a number c_i which provides a good approximation to the amount of work that is required for that task. I'm looking for an efficient (O(N) N = num tasks or better) algorithm which will give me "roughly" a good load balance given the values of c_i. It doesn't have to be optimal, but I would like to be able to have some theoretical bounds on how bad the resulting allocations are. Any ideas?

    Read the article

  • Algorithm: Build a recommendation for movies you might like

    - by Faruz
    I need help designing an algorithm for recommendations on movies. Every user in the system grades movies on a score between 1-100. Tables consist of: Table Movies ID Name Year Rating Runtime Table Con_MoviesToGenres MovieID GenreID Table Con_MovieToUser MovieID UserID Grade I'm trying to build a SELECT query to return 5 most recommended movies for a specific movie. Bearing in mind, I want to integrate in some way, similar genres, highest grades & movie Rating (so you want be recommended an R rated movie for a PG rated movie, unless it's really recommended in every other aspect). Also, if movie matches more than one genre, it will increase its recommendation ratio. Bonus: If a user gives a low grade to a movie - it will lose recommendation ratio.

    Read the article

  • An approximate algorithm for finding Steiner Forest.

    - by Tadeusz A. Kadlubowski
    Hello. Consider a weighted graph G=(V,E,w). We are given a family of subsets of vertices V_i. Those sets of vertices are not necessarily disjoint. A Steiner Forest is a forest that for each subset of vertices V_i connects all of the vertices in this subset with a tree. Example: only one subset V_1 = V. In this case a Steiner forest is a spanning tree of the whole graph. Enough theory. Finding such a forest with minimal weight is difficult (NP-complete). Do you know any quicker approximate algorithm to find such a forest with non-optimal weight?

    Read the article

  • Algorithm question.

    - by Lukasz Lew
    I can't solve it: You are given 8 integers: A, B, C representing a line on a plane with equation A*x + B*y = C a, b, c representing another line x, y representing a point on a plane The two lines are not parallel therefore divide plane into 4 pieces. Point (x, y) lies inside of one these pieces. Problem: Write a fast algorithm that will find a point with integer coordinates in the same piece as (x,y) that is closest to the cross point of the two given lines. Note: This is not a homework, this is old Euler-type task that I have absolutely no idea how to approach.

    Read the article

  • Algorithm to determine thread "hotness"

    - by nickf
    I'm trying to come up with a way to determine how "hot" certain threads are in a forum. What criteria would you use and why? How would these come together to give a hotness score? The criteria I'm thinking of include: how many replies how long since the last reply average time between replies The problems this algorithm must solve: A thread which has 500 replies is clearly hot, unless the last reply was over a year ago. A thread with 500 replies that was replied to a second ago is clearly hot, unless it's taken 4 years to reach 500 replies. A thread with 15 replies in the last 4 minutes is really hot! Any ideas, thoughts or complete solutions out there?

    Read the article

  • Algorithm for disordered sequences of strings

    - by Kinopiko
    The Levenshtein distance gives us a way to calculate the distance between two similar strings in terms of disordered individual characters: quick brown fox quikc brown fax The Levenshtein distance = 3. What is a similar algorithm for the distance between two strings with similar subsequences? For example, in quickbrownfox brownquickfox the Levenshtein distance is 10, but this takes no account of the fact that the strings have two similar subsequences, which makes them more "similar" than completely disordered words like quickbrownfox qburiocwknfox and yet the completely disordered version has a Levenshtein distance of eight. What distance measures exist which take the length of subsequences into account, without assuming that the subsequences can be easily broken into distinct words?

    Read the article

  • Correct permutation cycle for Verhoeff algorithm

    - by James
    Hello, I'm implementing the Verhoeff algorithm for a check digit scheme, but there seems to be some disagreement in web sources as to which permutation cycle should form the basis of the permutation table. Wikipedia uses: (36)(01589427) while apparently, Numerical Recipies uses a different cycle and this book uses: (0)(14)(23)(56789), quoted from a 1990 article by Winters. It also notes that Verhoeff used the one Wikipedia quotes. Now, my number theory is a little rusty, but the Wikipedia cycle clearly will repeat after the 8th power, while the book one will take 10, despite it saying that s^8=s. Table 2.14(b) has other errors in the 2-cycles, so this is dubious anyway. Unfortunately, I don't have copies of the original articles (and am too tight to pay/disgusted that 40-year old knowledge is still being held to ransom by publishers), nor a copy of Numerical Recipes to check (and am loath to install their paranoia-induced copy protection plug-in to view online). So does any one know which is correct? Are they both correct?

    Read the article

  • How to structure a Genetic Algorithm class hierarchy?

    - by MahlerFive
    I'm doing some work with Genetic Algorithms and want to write my own GA classes. Since a GA can have different ways of doing selection, mutation, cross-over, generating an initial population, calculating fitness, and terminating the algorithm, I need a way to plug in different combinations of these. My initial approach was to have an abstract class that had all of these methods defined as pure virtual, and any concrete class would have to implement them. If I want to try out two GAs that are the same but with different cross-over methods for example, I would have to make an abstract class that inherits from GeneticAlgorithm and implements all the methods except the cross-over method, then two concrete classes that inherit from this class and only implement the cross-over method. The downside to this is that every time I want to swap out a method or two to try out something new I have to make one or more new classes. Is there another approach that might apply better to this problem?

    Read the article

  • Search algorithm for a sorted double linked list

    - by SalamiArmi
    As a learning excercise, I've just had an attempt at implementing my own 'merge sort' algorithm. I did this on an std::list, which apparently already had the functions sort() and merge() built in. However, I'm planning on moving this over to a linked list of my own making, so the implementation is not particuarly important. The problem lies with the fact that a std::list doesnt have facilities for accessing random nodes, only accessing the front/back and stepping through. I was originally planning on somehow performing a simple binary search through this list, and finding my answer in a few steps. The fact that there are already built in functions in an std::list for performing these kinds of ordering leads me to believe that there is an equally easy way to access the list in the way I want. Anyway, thanks for your help in advance!

    Read the article

  • Algorithm for measuring distance between disordered sequences

    - by Kinopiko
    The Levenshtein distance gives us a way to calculate the distance between two similar strings in terms of disordered individual characters: quick brown fox quikc brown fax The Levenshtein distance = 3. What is a similar algorithm for the distance between two strings with similar subsequences? For example, in quickbrownfox brownquickfox the Levenshtein distance is 10, but this takes no account of the fact that the strings have two similar subsequences, which makes them more "similar" than completely disordered words like quickbrownfox qburiocwknfox and yet this completely disordered version has a Levenshtein distance of eight. What distance measures exist which take the length of subsequences into account, without assuming that the subsequences can be easily broken into distinct words?

    Read the article

  • Graph coloring Algorithm

    - by Amitd
    From wiki In its simplest form, it is a way of coloring the vertices of a graph such that no two adjacent vertices share the same color; this is called a vertex coloring. Similarly, an edge coloring assigns a color to each edge so that no two adjacent edges share the same color, and a face coloring of a planar graph assigns a color to each face or region so that no two faces that share a boundary have the same color. Given 'n' colors and m vertices, how easily can a graph coloring algorithm be implemented? Lan

    Read the article

  • Fast modulo 3 or division algorithm?

    - by aaa
    Hello is there a fast algorithm, similar to power of 2, which can be used with 3, i.e. n%3. Perhaps something that uses the fact that if sum of digits is divisible by three, then the number is also divisible. This leads to a next question. What is the fast way to add digits in a number? I.e. 37 - 3 +7 - 10 I am looking for something that does not have conditionals as those tend to inhibit vectorization thanks

    Read the article

  • Graph Algorithm To Find All Paths Between N Arbitrary Vertices

    - by russtbarnacle
    I have an graph with the following attributes: Undirected Not weighted Each vertex has a minimum of 2 and maximum of 6 edges connected to it. Vertex count will be < 100 I'm looking for paths between a random subset of the vertices (at least 2). The paths should simple paths that only go through any vertex once. My end goal is to have a set of routes so that you can start at one of the subset vertices and reach any of the other subset vertices. Its not necessary to pass through all the subset nodes when following a route. All of the algorithms I've found (Dijkstra,Depth first search etc.) seem to be dealing with paths between two vertices and shortest paths. Is there a known algorithm that will give me all the paths (I suppose these are subgraphs) that connect these subset of vertices?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >