Search Results

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

Page 41/203 | < Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >

  • Need help implementing this algorithm with map reduce(hadoop)

    - by Julia
    Hi all! i have algorithm that will go through a large data set read some text files and search for specific terms in those lines. I have it implemented in Java, but I didnt want to post code so that it doesnt look i am searching for someone to implement it for me, but it is true i really need a lot of help!!! This was not planned for my project, but data set turned out to be huge, so teacher told me I have to do it like this. I was reading about MapReduce and thaught that i first do the standard implementation and then it will be more/less easier to do it with mapreduce. But didnt happen, since algorithm is quite stupid and nothing special, and map reduce...i cant wrap my mind around it. So here is shortly pseudo code of my algorithm LIST termList (there is method that creates this list from lucene index) FOLDER topFolder INPUT topFolder IF it is folder and not empty list files (there are 30 sub folders inside) FOR EACH sub folder GET file "CheckedFile.txt" analyze(CheckedFile) ENDFOR END IF Method ANALYZE(CheckedFile) read CheckedFile WHILE CheckedFile has next line GET line FOR(loops through termList) GET third word from line IF third word = term from list append whole line to string buffer ENDIF ENDFOR END WHILE OUTPUT string buffer to file Also, as you can see, each time when "analyze" is called, new file has to be created, i understood that map reduce is difficult to write to many outputs??? I understand mapreduce intuition, and my example seems perfectly suited for mapreduce, but when it comes to do this, obviously I do not know enough and i am STUCK! Please please help.

    Read the article

  • Calculating distance between two X,Y coordinates

    - by Umopepisdn
    I am writing a tool for a game that involves calculating the distance between two coordinates on a spherical plane 500 units across. That is, [0,0] through [499,499] are valid coordinates, and [0,0] and [499,499] are also right next to each other. Currently, in my application, I am comparing the distance between a city with an [X,Y] location respective to the user's own [X,Y] location, which they have configured in advance. To do this, I found this algorithm, which kind of works: Math.sqrt ( dx * dx + dy * dy ); Because sorting a paged list by distance is a useful thing to be able to do, I implemented this algorithm in a MySQL query and have made it available to my application using the following part of my SELECT statement: SQRT( POW( ( ".strval($sourceX)." - cityX ) , 2 ) + POW( ( ".strval($sourceY)." - cityY ) , 2 ) ) AS distance This works fine for many calculations, but does not take into account the fact that [0,0] and [499,499] are kitty-corner to one another. Is there any way I can tweak this algorithm to generate an accurate distance, given that 0 and 499 are adjacent? Thanks, -Umo

    Read the article

  • On counting pairs of words that differ by one letter

    - by Quintofron
    Let us consider n words, each of length k. Those words consist of letters over an alphabet (whose cardinality is n) with defined order. The task is to derive an O(nk) algorithm to count the number of pairs of words that differ by one position (no matter which one exactly, as long as it's only a single position). For instance, in the following set of words (n = 5, k = 4): abcd, abdd, adcb, adcd, aecd there are 5 such pairs: (abcd, abdd), (abcd, adcd), (abcd, aecd), (adcb, adcd), (adcd, aecd). So far I've managed to find an algorithm that solves a slightly easier problem: counting the number of pairs of words that differ by one GIVEN position (i-th). In order to do this I swap the letter at the ith position with the last letter within each word, perform a Radix sort (ignoring the last position in each word - formerly the ith position), linearly detect words whose letters at the first 1 to k-1 positions are the same, eventually count the number of occurrences of each letter at the last (originally ith) position within each set of duplicates and calculate the desired pairs (the last part is simple). However, the algorithm above doesn't seem to be applicable to the main problem (under the O(nk) constraint) - at least not without some modifications. Any idea how to solve this?

    Read the article

  • License key pattern detection?

    - by Ricket
    This is not a real situation; please ignore legal issues that you might think apply, because they don't. Let's say I have a set of 200 known valid license keys for a hypothetical piece of software's licensing algorithm, and a license key consists of 5 sets of 5 alphanumeric case-insensitive (all uppercase) characters. Example: HXDY6-R3DD7-Y8FRT-UNPVT-JSKON Is it possible (or likely) to extrapolate other possible keys for the system? What if the set was known to be consecutive; how do the methods change for this situation, and what kind of advantage does this give? I have heard of "keygens" before, but I believe they are probably made by decompiling the licensing software rather than examining known valid keys. In this case, I am only given the set of keys and I must determine the algorithm. I'm also told it is an industry standard algorithm, so it's probably not something basic, though the chance is always there I suppose. If you think this doesn't belong in Stack Overflow, please at least suggest an alternate place for me to look or ask the question. I honestly don't know where to begin with a problem like this. I don't even know the terminology for this kind of problem.

    Read the article

  • Vacancy Tracking Algorithm implementation in C++

    - by Dave
    I'm trying to use the vacancy tracking algorithm to perform transposition of multidimensional arrays in C++. The arrays come as void pointers so I'm using address manipulation to perform the copies. Basically, there is an algorithm that starts with an offset and works its way through the whole 1-d representation of the array like swiss cheese, knocking out other offsets until it gets back to the original one. Then, you have to start at the next, untouched offset and do it again. You repeat until all offsets have been touched. Right now, I'm using a std::set to just fill up all possible offsets (0 up to the multiplicative fold of the dimensions of the array). Then, as I go through the algorithm, I erase from the set. I figure this would be fastest because I need to randomly access offsets in the tree/set and delete them. Then I need to quickly find the next untouched/undeleted offset. First of all, filling up the set is very slow and it seems like there must be a better way. It's individually calling new[] for every insert. So if I have 5 million offsets, there's 5 million news, plus re-balancing the tree constantly which as you know is not fast for a pre-sorted list. Second, deleting is slow as well. Third, assuming 4-byte data types like int and float, I'm using up actually the same amount of memory as the array itself to store this list of untouched offsets. Fourth, determining if there are any untouched offsets and getting one of them is fast -- a good thing. Does anyone have suggestions for any of these issues?

    Read the article

  • Find existence of number in a sorted list in constant time? (Interview question)

    - by Rich
    I'm studying for upcoming interviews and have encountered this question several times (written verbatim) Find or determine non existence of a number in a sorted list of N numbers where the numbers range over M, M N and N large enough to span multiple disks. Algorithm to beat O(log n); bonus points for constant time algorithm. First of all, I'm not sure if this is a question with a real solution. My colleagues and I have mused over this problem for weeks and it seems ill formed (of course, just because we can't think of a solution doesn't mean there isn't one). A few questions I would have asked the interviewer are: Are there repeats in the sorted list? What's the relationship to the number of disks and N? One approach I considered was to binary search the min/max of each disk to determine the disk that should hold that number, if it exists, then binary search on the disk itself. Of course this is only an order of magnitude speedup if the number of disks is large and you also have a sorted list of disks. I think this would yield some sort of O(log log n) time. As for the M N hint, perhaps if you know how many numbers are on a disk and what the range is, you could use the pigeonhole principle to rule out some cases some of the time, but I can't figure out an order of magnitude improvement. Also, "bonus points for constant time algorithm" makes me a bit suspicious. Any thoughts, solutions, or relevant history of this problem?

    Read the article

  • Longitudinal Redundancy Check fails

    - by PaulH
    I have an application that decodes data from a magnetic stripe reader. But, I'm having difficulty getting my calculated LRC check byte to match the one on the cards. If I were to grab 3 cards each with 3 tracks, I would guess the algorithm below would work on 4 of the 9 tracks in those cards. The algorithm I'm using looks like this (C#): private static char GetLRC(string s, int start, int end) { int result = 0; for (int i = start; i <= end; i++) { result ^= Convert.ToByte(s[i]); } return Convert.ToChar(result); } This is an example of track 3 data that fails the check. On this card, track 2 matched, but track 1 also failed. 0 1 2 3 4 5 6 7 8 9 A B C D E F 00 3 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 10 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 7 20 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 30 8 8 8 9 9 9 9 9 9 9 9 9 9 0 0 0 40 0 0 0 0 0 0 0 1 2 3 4 1 1 1 1 1 50 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 60 3 3 3 3 3 3 3 3 The sector delimiter is ';' and it ends with a '?'. The LRC byte from this track is 0x30. Unfortunately, the algorithm above computes an LRC of 0x00 per the following calculation (apologies for its length. I want to be thorough): 00 ^ 3b = 3b ';' 3b ^ 33 = 08 08 ^ 34 = 3c 3c ^ 34 = 08 08 ^ 34 = 3c 3c ^ 34 = 08 08 ^ 34 = 3c 3c ^ 34 = 08 08 ^ 34 = 3c 3c ^ 34 = 08 08 ^ 34 = 3c 3c ^ 34 = 08 08 ^ 35 = 3d 3d ^ 35 = 08 08 ^ 35 = 3d 3d ^ 35 = 08 08 ^ 35 = 3d 3d ^ 35 = 08 08 ^ 35 = 3d 3d ^ 35 = 08 08 ^ 35 = 3d 3d ^ 35 = 08 08 ^ 36 = 3e 3e ^ 36 = 08 08 ^ 36 = 3e 3e ^ 36 = 08 08 ^ 36 = 3e 3e ^ 36 = 08 08 ^ 36 = 3e 3e ^ 36 = 08 08 ^ 36 = 3e 3e ^ 36 = 08 08 ^ 37 = 3f 3f ^ 37 = 08 08 ^ 37 = 3f 3f ^ 37 = 08 08 ^ 37 = 3f 3f ^ 37 = 08 08 ^ 37 = 3f 3f ^ 37 = 08 08 ^ 37 = 3f 3f ^ 37 = 08 08 ^ 38 = 30 30 ^ 38 = 08 08 ^ 38 = 30 30 ^ 38 = 08 08 ^ 38 = 30 30 ^ 38 = 08 08 ^ 38 = 30 30 ^ 38 = 08 08 ^ 38 = 30 30 ^ 38 = 08 08 ^ 39 = 31 31 ^ 39 = 08 08 ^ 39 = 31 31 ^ 39 = 08 08 ^ 39 = 31 31 ^ 39 = 08 08 ^ 39 = 31 31 ^ 39 = 08 08 ^ 39 = 31 31 ^ 39 = 08 08 ^ 30 = 38 38 ^ 30 = 08 08 ^ 30 = 38 38 ^ 30 = 08 08 ^ 30 = 38 38 ^ 30 = 08 08 ^ 30 = 38 38 ^ 30 = 08 08 ^ 30 = 38 38 ^ 30 = 08 08 ^ 31 = 39 39 ^ 32 = 0b 0b ^ 33 = 38 38 ^ 34 = 0c 0c ^ 31 = 3d 3d ^ 31 = 0c 0c ^ 31 = 3d 3d ^ 31 = 0c 0c ^ 31 = 3d 3d ^ 31 = 0c 0c ^ 31 = 3d 3d ^ 31 = 0c 0c ^ 31 = 3d 3d ^ 31 = 0c 0c ^ 32 = 3e 3e ^ 32 = 0c 0c ^ 32 = 3e 3e ^ 32 = 0c 0c ^ 32 = 3e 3e ^ 32 = 0c 0c ^ 32 = 3e 3e ^ 32 = 0c 0c ^ 32 = 3e 3e ^ 32 = 0c 0c ^ 33 = 3f 3f ^ 33 = 0c 0c ^ 33 = 3f 3f ^ 33 = 0c 0c ^ 33 = 3f 3f ^ 33 = 0c 0c ^ 33 = 3f 3f ^ 33 = 0c 0c ^ 33 = 3f 3f ^ 3f = 00 '?' If anybody can point out how to fix my algorithm, I would appreciate it. Thanks, PaulH

    Read the article

  • Merge Sort issue when removing the array copy step

    - by Ime Prezime
    I've been having an issue that I couldn't debug for quite some time. I am trying to implement a MergeSort algorithm with no additional steps of array copying by following Robert Sedgewick's algorithm in "Algorithm's in C++" book. Short description of the algorithm: The recursive program is set up to sort b, leaving results in a. Thus, the recursive calls are written to leave their result in b, and we use the basic merge program to merge those files from b into a. In this way, all the data movement is done during the course of the merges. The problem is that I cannot find any logical errors but the sorting isn't done properly. Data gets overwritten somewhere and I cannot determine what logical error causes this. The data is sorted when the program is finished but it is not the same data any more. For example, Input array: { A, Z, W, B, G, C } produces the array: { A, G, W, W, Z, Z }. I can obviously see that it must be a logical error somewhere, but I have been trying to debug this for a pretty long time and I think a fresh set of eyes could maybe see what I'm missing cause I really can't find anything wrong. My code: static const int M = 5; void insertion(char** a, int l, int r) { int i,j; char * temp; for (i = 1; i < r + 1; i++) { temp = a[i]; j = i; while (j > 0 && strcmp(a[j-1], temp) > 0) { a[j] = a[j-1]; j = j - 1; } a[j] = temp; } } //merging a and b into c void merge(char ** c,char ** a, int N, char ** b, int M) { for (int i = 0, j = 0, k = 0; k < N+M; k++) { if (i == N) { c[k] = b[j++]; continue; } if (j == M) { c[k] = a[i++]; continue; } c[k] = strcmp(a[i], b[j]) < 0 ? a[i++] : b[j++]; } } void mergesortAux(char ** a, char ** b, int l, int r) { if(r - l <= M) { insertion(a, l, r); return; } int m = (l + r)/2; mergesortAux(b, a, l, m); //merge sort left mergesortAux(b, a, m+1, r); //merge sort right merge(a+l, b+l, m-l+1, b+m+1, r-m); //merge } void mergesort(char ** a,int l, int r, int size) { static char ** aux = (char**)malloc(size * sizeof(char*)); for(int i = l; i < size; i++) aux[i] = a[i]; mergesortAux(a, aux, l, r); free(aux); }

    Read the article

  • Adaboost algorithm and its usage in face detection

    - by Hani
    I am trying to understand Adaboost algorithm but i have some troubles. After reading about Adaboost i realized that it is a classification algorithm(somehow like neural network). But i could not know how the weak classifiers are chosen (i think they are haar-like features for face detection) and how finally the H result which is the final strong classifier can be used. I mean if i found the alpha values and compute the H ,how am i going to benefit from it as a value (one or zero) for new images. Please is there an example describes it in a perfect way? i found the plus and minus example that is found in most adaboost tutorials but i did not know how exactly hi is chosen and how to adopt the same concept on face detection. I read many papers and i had many ideas but until now my ideas are not well arranged. Thanks....

    Read the article

  • combinations algorithm

    - by mysterious jean
    I want to make simple sorting algorithm. given the input "abcde", I would like the output below. could you tell me the algorithm for that? arr[0] = "a" arr[1] = "ab" arr[2] = "ac" arr[3] = "ad" arr[4] = "ae" arr[5] = "abc" arr[6] = "abd" arr[7] = "abe" ... arr[n] = "abcde" arr[n+1] = "b" arr[n+2] = "bc" arr[n+3] = "bd" arr[n+4] = "be" arr[n+5] = "bcd" arr[n+5] = "bce" arr[n+5] = "bde" ... arr[n+m] = "bcde" ... ...

    Read the article

  • Polygon packing 2D

    - by Ilnur
    Hi! I have problem of packing 2 arbitrary polygons. I.e. we have 2 arbitrary polygons. We are to find such placement of this polygons (we could make rotations and movements), when rectangle, which circumscribes this polygons has minimal area. I know, that this is a NP-complete problem. I want to choose an efficient algorithm for solving this problem. I' looking for No-Fit-Polygon approach. But I could't find anywhere the simple and clear algorithm for finding the NFP of two arbitrary polygons.

    Read the article

  • Fuzzy string matching algorithm in Python

    - by Mridang Agarwalla
    Hi guys, I'm trying to find some sort of a good, fuzzy string matching algorithm. Direct matching doesn't work for me — this isn't too good because unless my strings are a 100% similar, the match fails. The Levenshtein method doesn't work too well for strings as it works on a character level. I was looking for something along the lines of word level matching e.g. String A: The quick brown fox. String B: The quick brown fox jumped over the lazy dog. These should match as all words in string A are in string B. Now, this is an oversimplified example but would anyone know a good, fuzzy string matching algorithm that works on a word level. Thanks in advance.

    Read the article

  • in TFS can we customize the merge algorithm (conflict resolution)

    - by Jennifer Zouak
    In our case we want to igonore changes in code comment headers for generated code. In Visual Studio, we can change the merge tool (GUI that pops up) and use a 3rd party tool that is able to be customized to ignore changes (http://msdn.microsoft.com/en-us/library/ms181446.aspx). Great, so a file comparison no longer highlights code comments as differences. However when it comes time to checkin, the TFS merge algorith is still prompting us to resolve conflicts. Is there any way to better inform the merge conflict resolution algorithm about which changes are actually important to us? Or can we replace the algorithm or otherwise have it subcontract its work to a 3rd party?

    Read the article

  • sorting algorithm

    - by mysterious jean
    I want to make simple sorting algorithm...like below... if there is character "abcde".... the character is stored like below.. could you tell me the algorithm for that? arr[0] = "a" arr[1] = "ab" arr[2] = "ac" arr[3] = "ad" arr[4] = "ae" arr[5] = "abc" arr[6] = "abd" arr[7] = "abe" ... arr[n] = "abcde" arr[n+1] = "b" arr[n+2] = "bc" arr[n+3] = "bd" arr[n+4] = "be" arr[n+5] = "bcd" arr[n+5] = "bce" arr[n+5] = "bde" ... arr[n+m] = "bcde" ... ...

    Read the article

  • How to generate all variations with repetitions of a string?

    - by Svenstaro
    I want to generate all variations with repetitions of a string in C++ and I'd highly prefer a non-recursive algorithm. I've come up with a recursive algorithm in the past but due to the complexity (r^n) I'd like to see an iterative approach. I'm quite surprised that I wasn't able to find a solution to this problem anywhere on the web or on StackOverflow. I've come up with a Python script that does what I want as well: import itertools variations = itertools.product('ab', repeat=4) for variations in variations: variation_string = "" for letter in variations: variation_string += letter print variation_string Output: aaaa aaab aaba aabb abaa abab abba abbb baaa baab baba babb bbaa bbab bbba bbbb Ideally I'd like a C++ program that can produce the exact output, taking the exact same parameters. This is for learning purposes, it isn't homework. I wish my homework was like that.

    Read the article

  • Gravity Sort : Is this possible programatically?

    - by Bragaadeesh
    Hi, I've been thinking recently on using the Object Oriented design in the sorting algorithm. However I was not able to find a proper way to even come closer in making this sorting algorithm that does the sorting in O(n) time. Ok, here is what I've been thinking for a week. I have a set of input data. I will assign a mass to each of the input data (assume input data a type of Mass). I will be placing all my input data in the space all at same distance from earth. And I will make them free fall. According to gravitational law, the heaviest one hits the ground first. And the order in which they hit will give me the sorted data. This is funny in some way, but underneath I feel that this should be possible using the OO that I have learnt till date Is it really possible to make a sorting technique that uses gravitational pull like scenario or am I stupid/crazy?

    Read the article

  • Find cheapest price for X number of days

    - by user76152
    Hey 'FLow. I have a technical challenge for you regarding an algorithm. Lets say I have this list of days and prices: List<ReservationPrice> prices = new List<ReservationPrice>(); prices.Add(new ReservationPrice { NumberOfDays = 1, Price = 1000 }); prices.Add(new ReservationPrice { NumberOfDays = 2, Price = 1200 }); prices.Add(new ReservationPrice { NumberOfDays = 3, Price = 2500 }); prices.Add(new ReservationPrice { NumberOfDays = 4, Price = 3100 }); prices.Add(new ReservationPrice { NumberOfDays = 7, Price = 4000 }); What I would like to able to do now is: give me the best price from the list based on a number of days. So if ask for 3 days the best price from the list is from child one (1000) and two (1200), but there are of course different combinations you would have to try out at first. How would an algorithm that found the best price from this list look like ? Thank you!

    Read the article

  • how to work with strings and integers as bit strings in python?

    - by Manuel
    Hello! I'm developing a Genetic Algorithm in python were chromosomes are composed of strings and integers. To apply the genetic operations, I want to convert these groups of integers and strings into bit strings. For example, if one chromosome is: ["Hello", 4, "anotherString"] I'd like it to become something like: 0100100100101001010011110011 (this is not actual translation). So... How can I do this? Chromosomes will contain the same amount of strings and integers, but this numbers can vary from one algorithm run to another. To be clear, what I want to obtain is the bit representation of each element in the chromosome concatenated. If you think this would not be the best way to apply genetic operators (such as mutation and simple crossover) just tell me! I'm open to new ideas. Thanks a lot! Manuel

    Read the article

  • How to "smart resize" a displayed image to original aspect ratio

    - by Paul Sasik
    I have an application in which end-users can size and position images in a designer. Since the spec calls for the image to be "stretched" to the containing control, the end user can end up with an awkwardly stretched image. To help the user with image sizing I am thinking of implementing a smart resizer function which would allow the the user to easily fix the aspect ratio of the picture so that it no longer appears stretched. The quick way to solve this is to actually provide two options: 1) scale from width 2) scale from height. The user chooses the method and the algorithm adjusts the size of the picture by using the original aspect ratio. For example: A picture is displayed as 200x200 on the designer but the original image is 1024x768 pixels. The user chooses "Smart Size from width" and the new size becomes ~200x150 since the original aspect ratio is ~1.333 That's OK, but how could I make the algorithm smarter and not bother the user by asking which dimension the recalculation should be based on?

    Read the article

< Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >