Search Results

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

Page 145/203 | < Previous Page | 141 142 143 144 145 146 147 148 149 150 151 152  | Next Page >

  • String Compression using Lempel-Ziv

    - by roybot
    Im looking for a way of compressing a given string using the Lempel-Ziv Algorithm. Preferably there would only be a set of two functions, encoder and decoder. The encoder takes the string and returns an integer. The decoder takes the integer and returns the original string. Time complexity is not important. How would you implement this?

    Read the article

  • Sorted sets and comparators

    - by Jack
    Hello, I'm working with a TreeSetthat is meant to store pathfind locations used during the execution of a A* algorithm. Basically until there are "open" elements (still to be exhaustively visited) the neighbours of every open element are taken into consideration and added to a SortedSetthat keeps them ordered by their cost and heuristic cost. This means that I have a class like: public class PathTileInfo implements Comparable<PathTileInfo> { int cost; int hCost; final int x, y; @Override public int compareTo(PathTileInfo t2) { int c = cost + hCost; int c2 = t2.cost + t2.hCost; int costComp = c < c2 ? -1 : (c > c2 ? 1: 0); return costComp != 0 ? costComp : (x < t2.x || y < t2.y ? -1 : (x > t2.x || y > t2.y ? 1 : 0)); } @Override public boolean equals(Object o2) { if (o2 instanceof PathTileInfo) { PathTileInfo i = (PathTileInfo)o2; return i.cost + i.hCost == cost + hCost && x == i.x && y == i.y; } return false; } } In this way first the total cost is considered, then, since a total ordering is needed (consistency with equals) a ordering according to the x,y coordinate is taken into account. This should work but simply it doesn't, if I iterate over the TreeSet during the algorithm execution like in for (PathTileInfo t : openSet) System.out.print("("+t.x+","+t.y+","+(t.cost+t.hCost)+") "); I get results in which the right ordering is not kept, eg: (7,7,6) (7,6,7) (6,8,6) (6,6,7) (5,8,7) (5,7,7) (6,7,6) (6,6,7) (6,5,7) (5,7,7) (5,5,8) (4,7,7) (4,6,8) (4,5,8) is there something subtle I am missing? Thanks!

    Read the article

  • Please summarize how to implement node base licensing

    - by user294896
    Currently a user makes a purchase and then a license is generated and sent to that user, but the license isn't tied to a physical computer so there is nothing to prevent the user sharing the license with someone. I heard people talk about creating a license tied to the mac address of the computer, so the license only works on that computer. Now I know how to get the mac address in code but I dont understand how I can do this step when they first make the purchase on the web, so please what is the basic algorithm for node locked licenses ?

    Read the article

  • TextImageRelation Implementation

    - by BobPelotas
    Hello, Does anyone know any information on implementing the TextImageRelation property on a button? Since it is impossible to paint a custom background without having to also paint the foreground, I need at least an idea of how the algorithm works. I can't find any info on it. Thanks

    Read the article

  • Dynamicall Rendering in a Scrollable Area

    - by James
    What is the generic algorithm or process that is commonly used to dynamically render portions of a scrolling area? For example, in Google Maps, when the user scrolls past the bounds of the currently rendered area, a grey checkerboard pattern is displayed within the not-yet-rendered portions while the application loads and renders those areas. I'm looking specifically for the approach, or the mathematics, related to filling a graphics area in chunks based on what has just come into view. If possible, I'm looking for anything relevant to the GDI+ process of doing so.

    Read the article

  • string s; &s+1; Legal? UB?

    - by John Dibling
    Consider the following code: #include <cstdlib> #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { string myAry[] = { "Mary", "had", "a", "Little", "Lamb" }; const size_t numStrs = sizeof(myStr)/sizeof(myAry[0]); vector<string> myVec(&myAry[0], &myAry[numStrs]); copy( myVec.begin(), myVec.end(), ostream_iterator<string>(cout, " ")); return 0; } Of interest here is &myAry[numStrs]: numStrs is equal to 5, so &myAry[numStrs] points to something that doesn't exist; the sixth element in the array. There is another example of this in the above code: myVec.end(), which points to one-past-the-end of the vector myVec. It's perfecly legal to take the address of this element that doesn't exist. We know the size of string, so we know where the address of the 6th element of a C-style array of strings must point to. So long as we only evaluate this pointer and never dereference it, we're fine. We can even compare it to other pointers for equality. The STL does this all the time in algorithms that act on a range of iterators. The end() iterator points past the end, and the loops keep looping while a counter != end(). So now consider this: #include <cstdlib> #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { string myStr = "Mary"; string* myPtr = &myStr; vector<string> myVec2(myPtr, &myPtr[1]); copy( myVec2.begin(), myVec2.end(), ostream_iterator<string>(cout, " ")); return 0; } Is this code legal and well-defined? It is legal and well-defined to take the address of an array element past the end, as in &myAry[numStrs], so should it be legal and well-defined to pretend that myPtr is also an array?

    Read the article

  • Evil merges in git - where do they come from?

    - by Benjol
    I've read this question and the answers, but what isn't clear to me is WHO creates the "changes that do not appear in any parent". Is it the git merge algorithm screwing up? Or is it because the user has to manually adjust the conflicts to get the thing to build, introducing new code which wasn't in either parent?

    Read the article

  • Sorting string column containing numbers in SQL?

    - by Ish
    Dear Folks, I am trying to sort string column (containing numbers). // SELECT `name` FROM `mytable` ORDER BY `name` ASC +----------+ +-- name --+ +----------+ +-- a 1 ---+ +-- a 12 --+ +-- a 2 ---+ +-- a 3 ---+ You see natural sorting algorithm of Mysql is placing a 12 after a 1 (which is ok for most apps), But I have unique needs, so I want result should be sorted like this. +----------+ +-- name --+ +----------+ +-- a 1 ---+ +-- a 2 ---+ +-- a 3 ---+ +-- a 12 --+ Is it possible with just SQL, or I have to manipulate result-set at application level? Thanks for reading...

    Read the article

  • How to pick random (small) data samples using Map/Reduce?

    - by Andrei Savu
    I want to write a map/reduce job to select a number of random samples from a large dataset based on a row level condition. I want to minimize the number of intermediate keys. Pseudocode: for each row if row matches condition put the row.id in the bucket if the bucket is not already large enough Have you done something like this? Is there any well known algorithm? A sample containing sequential rows is also good enough. Thanks.

    Read the article

  • make VIEW of SHOW TABLE query

    - by cneeds
    Is there a way to make a VIEW of this SHOW TABLE query? SHOW FULL TABLES FROM `db_name` WHERE `Table_type` = "Base table" When I save this as a view (using phpMyAdmin) I get #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SHOW FULL TABLES FROM `db_name` WHERE `Table_type` = "Base table"' at line 4 when phpMyAdmin tries to execute this CREATE ALGORITHM = UNDEFINED VIEW `Tables` AS SHOW FULL TABLES FROM `db_name` WHERE `Table_type` = "Base table"

    Read the article

  • A C# collection, which behaves like C++ set or priority_queue?

    - by Wojciech
    Hello, I have written the Dijkstra's algorithm many times in C++ - I need there set or priotity_queue, both give me possibility to add an element and find the least one (using specified comparator). Now, I've got a problem when trying to write Dijkstra in C# - is there any structure which could be useful for me? I need adding and finding or erasing the least element. Using Visual Studio '08

    Read the article

  • What is the most secure encryption mode for Android?

    - by jax
    Currently I am using: Algorithm_mode_padding="RSA/ECB/PKCS1Padding" Provider="BC" I have heard that ECB can cause patterns in the output. What is the most secure Algorithm, mode and padding for Android at the moment? I will be using this for license files. Also, what is the best keysize to use when creating a new public and private key?

    Read the article

  • Generate digital signature using VBA

    - by tputkonen
    I have text cells of arbitrary length in Excel's column A. Using a private key, I want to generate digital signature for data in column A into the cell in column B. I'm looking for a macro implementation for the digital signature algorithm - I don't think one ships with Excel, but is there an addon available? It must be possible to easily verify correctness of the signature in other environments as well.

    Read the article

  • Counting number of searches

    - by shinjuo
    I am trying to figure out how to get the total number of tests each search makes in this algorithm. I am not sure how I can pass that information back from this algorithm though. I need to count how many times while runs and then pass that number back into an array to be added together and determine the average number of test. main.c #include <stdio.h> #include <stdlib.h> #include <time.h> #include <stdbool.h> #include "percentage.h" #include "sequentialSearch.h" #define searchAmount 100 int main(int argc, char *argv[]) { int numbers[100]; int searches[searchAmount]; int i; int where; int searchSuccess; int searchUnsuccess; int percent; srand(time(NULL)); for (i = 0; i < 100; i++){ numbers[i] = rand() % 200; } for (i = 0; i < searchAmount; i++){ searches[i] = rand() % 200; } searchUnsuccess = 0; searchSuccess = 0; for(i = 0; i < searchAmount; i++){ if(seqSearch(numbers, 100, searches[i], &where)){ searchSuccess++; }else{ searchUnsuccess++; } } percent = percentRate(searchSuccess, searchAmount); printf("Total number of searches: %d\n", searchAmount); printf("Total successful searches: %d\n", searchSuccess); printf("Success Rate: %d%%\n", percent); system("PAUSE"); return 0; } sequentialSearch.h bool seqSearch (int list[], int last, int target, int* locn){ int looker; looker = 0; while(looker < last && target != list[looker]){ looker++; } *locn = looker; return(target == list[looker]); }

    Read the article

  • Flow charts and algorithms

    - by Dave
    Hello there, I am from a networking background and completely new to algorithm and flow charts, so could you please assist me with the following? Draw flow charts for the following algorithmss: State whether a number entered at the keyboard is even or odd. Calculate the mean of a five numbers entered by the user from the keyboard Count the number of characters and the number of words that are in a text file Many thanks in advance!

    Read the article

  • Second min cost spanning tree.

    - by Evil
    Hello. I'm writing an algorithm for finding the second min cost spanning tree. my idea was as follows: 1) Use kruskals to find lowest MST. 2) Delete the lowest cost edge of the MST. 3) Run kruskals again on the entire graph. 4) return the new MST. My question is this: Will this work? Is there a better way perhaps to do this?

    Read the article

  • Need MD5 guideline

    - by Arman
    Is there any specific algorithm for the encoding and decoding MD5. Kindly give me the proper direction or guideline, so that I can move on.. I have search a lot on Google but I haven't find, kindly give the articles or tutorial link.

    Read the article

< Previous Page | 141 142 143 144 145 146 147 148 149 150 151 152  | Next Page >