It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I was just reading about it on a book and wikipedia but still dont understand it 100%.
I would really appreciate it if someone could explain it with an example or two.
Thanks
Say I'm looking at a map, searching for a pizza place near my block in the city. A few different strategies I could use:
Breadth first search (BFS): Look at concentric circles of blocks around my block, farther and farther outward until I find a pizza place. This will give me one of the pizza places which is closest to my block as the crow flies.
Depth first search (DFS): Follow a road until I hit a dead end, then backtrack. Eventually all possible branches will be searched, so if there's a pizza place out there somewhere then I'll find it, but it probably won't be very close to my block.
Uniform cost search (UCS): Say traffic is bad on some streets, and I'm really familiar with the city. For any given location I can say how long it will take me to get there from my block. So, looking at the map, first I search all blocks that will take me 1 minute or less to get to. If I still haven't found a pizza place, I search all blocks that will take me between 1 and 2 minutes to get to. I repeat this process until I've found a pizza place. This will give me one of the pizza places which is the closest drive from my block. Just as BFS looks like concentric circles, UFS will looks like a contour map.
Typically you will implement UCS using a priority queue to search nodes in order of least cost.
I assume you were looking at this Wikipedia page. What it means is that the time required for a given operation (adding two numbers, comparing two numbers, retrieving data from memory, etc.) is independent of the size of the variables involved. In other words, an 8-bit comparison takes the same amount of time as a 32-bit comparison. Making this assumption allows you to simplify an efficiency analysis and compare algorithms without getting bogged down in implementation details.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Very much new to this issue,need to fine total travelling distance while going from one location to another and also need to count total time spent to that travel.finding distance using latitude and longitude of two location don't give correct result i think,because lat and lang distance gives us straight line distance even if we have lots of turning points etc...while we are travelling.
How to draw a path on a map using kml file?
i see this issue,good example has been given there i have implemented that also but it's complicated bcs i don't need to draw a routing path i just need to count total distance and total time.
So Hoping for some one will helpme
Thanks in advance
Aamirkhan I.
ERROR SOLVED
I found my answer i used this google api
http://maps.googleapis.com/maps/api/distancematrix/json?origins=ahmedabad&destinations=mumbai&mode=car&sensor=false
it gives all info for traveling form one location to another
When your travel starts you need to get the current location Latitude
and Longitude and where ever you want to end your travel then you need
to get that location latitude and longitude then calculate the
distance .
Calculating distance
then regarding counting the time When you are getting the current
location at that time only you need to get the current time and where
you are ending your traveling there you need to get that particular
time,then now calculate the time interval between two locations.
Google has an app to do basically this -- Google My Tracks. You can export the data from the app into Google Maps or a KML file.
Find the distance of every part of your path between 2 turn points (by longitudes and latitudes) and sum them up. To find a travell time divide the total distance by planned average speed. It's the only way to solve your problem.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
is there any preexisting efficient algorithms in pattern matching (large data of DNA)?
there are so many algorithms like Knuth-Morris-Pratt algorithm, Boyer-Moore algorithm, Index based forward backward multiple pattern algorithms are there but they are efficient and performs very poor when the is large. so please help me to know about efficient algorithms in pattern matching...
Take a look at the BLAST algorithm.
I'm sure this must have been discussed elsewhere.
I guess you'll already store the strings using two bits only (rather than using eight bits per character). Not only does this reduce the storage size by a factor four (I guess your strings can be as long as hundreds of millions of characters) but also reduces the time to transfer this data (e.g. from disk to memory or from memory to the CPU cache).
The following assumes that there are a lot of queries while the strings to be searched remain the same, so calculating and storing some additional quantities based on the strings is justified.
I suggest you have a look at suffix trees which can be constructed in linear time using Ukkonen's algorithm.
If that is not feasible, maybe you should consider a hybrid approach like building a fixed set dictionary of all possible words up to a fixed length L and divide your string to be searched into regions.
for each word in the dictionary store the region indices in which they appear (include L-1 characters of the next region when building this list)
when searching for a word, split it into strings of length L and check in which regions these appear. Assuming that the maximum search string length does not exceed the length of a region, your search string can only appear in regions where all parts (of length L) of your search string appear (or are in the preceding/following region)
with a standard string searching algorithm, search only the resulting regions for your search string
(this is probably similar to what a Bloom filter does)
For the second approach, you'll need to tune the parameters (the length L of the words in the dictionary and the size/number of regions).
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
How we can to fill the chessboard with domino and we have a some blocks. and chessboard is n x m. and the places filled with ordered numbers.
Test :
Answer like this :
input give n , m and k. k is number of blocks.
and next k lines give blocks such as 6 7 or 4 9.
sorry for my English.
Here's an idea. In your example board, it is immediately obvious that squares 7 9 and 14 must contain domino 'ends', that is to say it must be the case that there are dominos covering 2-7, 8-9, and 14-15.
(In case it's not 'immediately obvious', the rule I used is that a square with 'walls' on three sides dictates the orientation of the domino covering that square)
If we place those three dominos, it may then be the case that there are more squares to which the same rule now applies (eg 20).
By iterating this process, we can certainly make progress towards our goal, or alternatively get to a place where we know it can't be achieved.
See how far that gets you.
edit also, note that in your example, the lower-left corner 2x2 (squares 11 12 16 17) is not uniquely determined - a 90 degree rotation of the depicted arrangement would also work - so you will have to consider such situations. If you are looking for any solution, you must come up with a way of arbitrarily picking one of many possibilities; if you are trying to enumerate all possibilities, you will have to come up with a way of finding them all!
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Say you wanted to find which input causes function x to output value y, and you know the (finite) range of possible inputs.
The input and output are both numbers, and positively correlated.
What would be the best way to optimize that?
I'm currently just looping through all of the possible inputs.
Thanks.
One solution would be a binary search over the possible inputs.
Flow:
find the median input x
get the output from function(x)
if the output is less than the desired y
start over using the smaller half of the possible inputs
else
start over using the larger half of the possible inputs
A binary search algorithm, perhaps?
http://en.wikipedia.org/wiki/Binary_search_algorithm
If the range is finite and small, a precomputed lookup table might be the fastest way
if you have some sets of know "x" data that yield "y" you can divied between training and test sets and use neural networks.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I'm looking for a list of problems (the more the problems the better) with their corresponding algorithm technique(s) these problems can be solved.
For example:
Shortest Path problem -> Dijkstra's algorithm (dynamic programming), and maybe others ...
Knapsack problem -> can be solved with dynamic programming, ...
Convex Hull problem -> could be done by divide and conquer, ...
If in every problem there is a small paragraph explaining how the problem is solved (e.g. it could explain how to "divide" the problem in a divide and conquer algorithm) with the given
technique that would be even better.
Is there any such list available in the net or in a book?
*UPDATE after locking ... *
I'm not looking for problems mostly found in programming contests like TopCoder. Problems from such sites (contests) use to "hide" the problem definition which is supposed to be found by the user. I'm looking for problem definitions, like Given a graph G = (V, E) ... and it's given solution technique Could be solved using divide and conquer ... instead of problems definitions like this: Given N houses, John tries to find a path to go home as fast as possible ... which are how problems are described in programming contests sites.
This question has nothing to do with homework as some people thought. I want to "exercise" my algorithm solution technique skills. By knowing that a given problem can be solved by a given technique will help me try to find a solution using this technique and so I guess will get a deeper understanding of each technique, plus I will be become a better algorithm solver.
The site Algorithmist categories many problems (but not all) from UVa online judge and Sphere Online Judge. For example, here is the partial category listing for UVa Volume I. Also check their Categories page.
Topcoder categorizes each problem from every past contest they held. Besides that, you can filter problems by difficulty, as well as read editorials or other people's solutions.