Search Results

Search found 5070 results on 203 pages for 'algorithm'.

Page 80/203 | < Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >

  • Base X string encoding

    - by Paul Stone
    I'm looking for a routine that will encode a string (stream of bytes) into an arbitrary base/alphabet (like base64 encoding but I get to choose the alphabet). I've seen a few routines that do base X encoding for a number, but not for a string.

    Read the article

  • How to generate a number in arbitrary range using random()={0..1} preserving uniformness and density?

    - by psihodelia
    Generate a random number in range [x..y] where x and y are any arbitrary floating point numbers. Use function random(), which returns a random floating point number in range [0..1] from P uniformly distributed numbers (call it "density"). Uniform distribution must be preserved and P must be scaled as well. I think, there is no easy solution for such problem. To simplify it a bit, I ask you how to generate a number in interval [-0.5 .. 0.5], then in [0 .. 2], then in [-2 .. 0], preserving uniformness and density? Thus, for [0 .. 2] it must generate a random number from P*2 uniformly distributed numbers. The obvious simple solution random() * (x - y) + y will generate not all possible numbers because of the lower density for all abs(x-y)>1.0 cases. Many possible values will be missed. Remember, that random() returns only a number from P possible numbers. Then, if you multiply such number by Q, it will give you only one of P possible values, scaled by Q, but you have to scale density P by Q as well.

    Read the article

  • question about api functions

    - by davit-datuashvili
    i have question we have API functions in java can user create it's own function and add to his java IDE? for example i am using netbeans can i create my own function add to netbean IDE?let say create binary function or something else thanks

    Read the article

  • Express any number as the sum of 4 prime numbers [Doubts]

    - by WarDoGG
    I was give a problem to express any number as sum of 4 prime numbers. Conditions: Not allowed to use any kind of database. Maximum execution time : 3 seconds Numbers only till 100,000 If the splitting is NOT possible, then return -1 What i did : using the sieve of eratosthenes, i calculated all prime numbers till the specified number. looked up a concept called goldbach conjecture which expresses an even number as the summation of 2 primes. However, i am stuck beyond that. Can anyone help me on this one as to what approach u might take ? The sieve of eratosthenes is taking 2 seconds to count primes till 100,000 :(((

    Read the article

  • how to find distinct digit set numbers over a range of integers?

    - by evil.coder
    Suppose i have a unsigned integer, call it low and one another call it high such that highlow. The problem is to find distinct digit set numbers over this range. For example, suppose low is 1 and high is 20 then the answer is 20, because all the numbers in this range are of distinct digit sets. If suppose low is 1 and high is 21, then the answer is 20, because 12 and 21 have same digit set i.e.1, 2. I am not looking for a bruteforce algo., if anyone has a better solution then a usual bruteforce approach, please tell..

    Read the article

  • Generate 2D cross-section polygon from 3D mesh

    - by nornagon
    I'm writing a game which uses 3D models to draw a scene (top-down orthographic projection), but a 2D physics engine to calculate response to collisions, etc. I have a few 3D assets for which I'd like to be able to automatically generate a hitbox by 'slicing' the 3D mesh with the X-Y plane and creating a polygon from the resultant edges. Google is failing me on this one (and not much helpful material on SO either). Suggestions?

    Read the article

  • Orbital equations, and power required to run them

    - by Adam Davis
    Due to a discussion on the SO IRC today, I'm curious about orbital mechanics, and The equations needed to solve orbital problems The computing power required to solve complex problems The question in particular is calculating when the Earth will plow into the Sun (or vice versa, depending on the frame of reference). I suspect that all the gravitational pulls within our solar system may need to be calculated, which makes me wonder what type of computer cluster is required, or can this be done on a single box? I don't have the experience to do a back of the napkin test here, but perhaps you do? Also, much thx to Gortok for the original inspiration (see comments).

    Read the article

  • Pecking order of pigeons?

    - by sc_ray
    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, one pigeon always pecks the other, driving it away from food or potential mates. The same pair of pigeons always chooses the same pecking order, even after years of separation, no matter what other pigeons are around. Surprisingly, the overall pecking order can contain cycles—for example, pigeon A pecks pigeon B, which pecks pigeon C, which pecks pigeon A. Prove that any finite set of pigeons can be arranged in a row from left to right so that every pigeon pecks the pigeon immediately to its left. Since this is a question on Graph theory, the first things that crossed my mind that is this just asking for a topological sort of a graphs of relationships(relationships being the pecking order). What made this a little more complex was the fact that there can be cyclic relationships between the pigeons. If we have a cyclic dependency as follows: A-B-C-A where A pecks on B,B pecks on C and C goes back and pecks on A If we represent it in the way suggested by the problem, we have something as follows: C B A But the above given row ordering does not factor in the pecking order between C and A. I had another idea of solving it by mathematical induction where the base case is for two pigeons arranged according to their pecking order, assuming the pecking order arrangement is valid for n pigeons and then proving it to be true for n+1 pigeons. I am not sure if I am going down the wrong track here. Some insights into how I should be analyzing this problem will be helpful. Thanks

    Read the article

  • Genetic programming in c++, library suggestions?

    - by shuttle87
    I'm looking to add some genetic algorithms to an Operations research project I have been involved in. Currently we have a program that aids in optimizing some scheduling and we want to add in some heuristics in the form of genetic algorithms. Are there any good libraries for generic genetic programming/algorithms in c++? Or would you recommend I just code my own? I should add that while I am not new to c++ I am fairly new to doing this sort of mathematical optimization work in c++ as the group I worked with previously had tended to use a proprietary optimization package. We have a fitness function that is fairly computationally intensive to evaluate and we have a cluster to run this on so parallelized code is highly desirable. So is c++ a good language for this? If not please recommend some other ones as I am willing to learn another language if it makes life easier. thanks!

    Read the article

  • Byte-Pairing for data compression

    - by user1669533
    Question about Byte-Pairing for data compression. If byte pairing converts two byte values to a single byte value, splitting the file in half, then taking a gig file and recusing it 16 times shrinks it to 62,500,000. My question is, is byte-pairing really efficient? Is the creation of a 5,000,000 iteration loop, to be conservative, efficient? I would like some feed back on and some incisive opinions please. Dave, what I read was: "The US patent office no longer grants patents on perpetual motion machines, but has recently granted at least two patents on a mathematically impossible process: compression of truly random data." I was not inferring the Patent Office was actually considering what I am inquiring about. I was merely commenting on the notion of a "mathematically impossible process." If someone has, in some way created a method of having a "single" data byte as a placeholder of 8 individual bytes of data, that would be a consideration for a patent. Now, about the mathematically impossibility of an 8 to 1 compression method, it is not so much a mathematically impossibility, but a series of rules and conditions that can be created. As long as there is the rule of 8 or 16 bit representation of storing data on a medium, there are ways to manipulate data that mirrors current methods, or creation by a new way of thinking.

    Read the article

  • Encoding arbitrary data into numbers?

    - by Pekka
    Is there a common method to encode and decode arbitrary data so the encoded end result consists of numbers only - like base64_encode but without the letters? Fictitious example: $encoded = numbers_encode("Mary had a little lamb"); echo $encoded; // outputs e.g. 122384337422394237423 (fictitious result) $decoded = numbers_decode("122384337422394237423"); echo $decoded; // outputs "Mary had a little lamb"

    Read the article

  • question about mergesort

    - by davit-datuashvili
    i have write code on mergesort here is code public class mergesort{ public static int a[]; public static void merges(int work[],int low,int high){ if (low==high) return ; else{ int mid=(low+high)/2; merges(work,low,mid); merges(work,mid+1,high); merge(work,low,mid+1,high); } } public static void main(String[]args){ int a[]=new int[]{64,21,33,70,12,85,44,99,36,108}; merges(a,0,a.length-1); for (int i=0;i<a.length;i++){ System.out.println(a[i]); } } public static void merge(int work[],int low,int high,int upper){ int j=0; int l=low; int mid=high-1; int n=upper-l+1; while(low<=mid && high<=upper) if ( a[low]<a[high]) work[j++]=a[low++]; else work[j++]=a[high++]; while(low<=mid) work[j++]=a[low++]; while(high<=upper) work[j++]=a[high++]; for (j=0;j<n;j++) a[l+j]=work[j]; } } but it does nort work after compile this code here is mistake java.lang.NullPointerException at mergesort.merge(mergesort.java:45) at mergesort.merges(mergesort.java:12) at mergesort.merges(mergesort.java:10) at mergesort.merges(mergesort.java:10) at mergesort.merges(mergesort.java:10) at mergesort.main(mergesort.java:27)

    Read the article

  • All Permutations of a string when corresponding characters are not in the same place

    - by r20rock
    I need all possible permutations of a given string such that no character should remain at the same place as in the input string. Eg. : for input "ask" Output: all possible permutaions like "ksa", "kas"... such that 'a' is not in the 1st position , 's' is not in the 2nd positions and so on... in any permutation. I only need the count of such possible permutations I can do this by generating all permutations and filtering them but I need a very efficient way of doing this. All characters in the string are "UNIQUE" Preferred language C++.

    Read the article

  • Why does Java's hashCode() in String use 31 as a multiplier?

    - by jacobko
    In Java, the hash code for a String object is computed as s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] using int arithmetic, where s[i] is the ith character of the string, n is the length of the string, and ^ indicates exponentiation. Why is 31 used as a multiplier? I understand that the multiplier should be a relatively large prime number. So why not 29, or 37, or even 97?

    Read the article

  • Find a repeated numbers out of 3 boxes

    - by james1
    I have 3 boxes, each box contain 10 piece of numbered paper (1 - 10) but there is a number the same in all 3 boxes eg: box1 has number 4 and box2 has number 4 and box3 also has number 4. How to find that repeated number in java with an efficient/fastest way possible?

    Read the article

  • Finding the largest subtree in a BST

    - by rakeshr
    Given a binary tree, I want to find out the largest subtree which is a BST in it. Naive approach: I have a naive approach in mind where I visit every node of the tree and pass this node to a isBST function. I will also keep track of the number of nodes in a sub-tree if it is a BST. Is there a better approach than this ?

    Read the article

  • Find the shortest path in a graph which visits certain nodes.

    - by dmd
    I have a undirected graph with about 100 nodes and about 200 edges. One node is labelled 'start', one is 'end', and there's about a dozen labelled 'mustpass'. I need to find the shortest path through this graph that starts at 'start', ends at 'end', and passes through all of the 'mustpass' nodes (in any order). ( http://3e.org/local/maize-graph.png / http://3e.org/local/maize-graph.dot.txt is the graph in question - it represents a corn maze in Lancaster, PA)

    Read the article

  • Dot Game and Dynamic Programming

    - by Albert Diego
    I'm trying to solve a variant of the dot game with dynamic programming. The regular dot game is played with a line of dots. Each player takes either one or two dots at their respective end of the line and the person who is left with no dots to take wins. In this version of the game, each dot has a different value. Each player takes alternate turns and takes either dot at either end of the line. I want to come up with a way to use dynamic programming to find the max amount that the first player is guaranteed to win. I'm having problems grasping my head around this and trying to write a recurrence for the solution. Any help is appreciated, thanks!

    Read the article

  • Finding the maximum weight subsequence of an array of positive integers?

    - by BeeBand
    I'm tring to find the maximum weight subsequence of an array of positive integers - the catch is that no adjacent members are allowed in the final subsequence. The exact same question was asked here, and a recursive solution was given by MarkusQ. He provides an explanation, but can anyone help me understand how he has expanded the function? How does this solution take into consideration non-adjacent members?

    Read the article

  • Data Structure for a particular problem??

    - by AGeek
    Hi, Which data structure can perform insertion, deletion and searching operation in O(1) time in the worst case. We may assume the set of elements are integers drawn from a finite set 1,2,...,n, and initialization can take O(n) time. I can only think of implementing a hash table. Implementing it with Trees will not give O(1) time complexity for any of the operation. Or is it possible?? Kindly share your views on this, or any other data structure apart from these.. Thanks..

    Read the article

< Previous Page | 76 77 78 79 80 81 82 83 84 85 86 87  | Next Page >