UserA-UserB-UserC-UserD-UserF
Users connected by '-' know each other.
And I need an algorithm for these 2 tasks:
Calculate the path from UserX to UserY
For UserX,calculate all users that is no more than 3 steps away.
Is there an efficient solution?
EDIT
My purpose is not to prove it right or wrong,but to calculate the result real...
Hey there,
I was playing around with Python's collection.deque and wrote the following benchmark:
#!/usr/bin/python
import timeit
if __name__=='__main__':
number = 1000000
for r in (1,10,100,1000,5000,10000,100000):
print r
print timeit.timeit("while x: x.pop(0);",
"x = list(range("...
I recently joined a new company and the development team was in the progress of a project to rebuild the database categories structure as follows:
if we have category and subcategory for items, like food category and italian food category in food category.
They were building a table for each category, instead of having one table and a l...
jQuery 1.4 released recently and the new website shows some performance charts where 1.4 is clearly better, but has someone already done an analysis of overall performance improvement of 1.4 vs 1.3? If not, how do I profile both on my sites/pages, are there any tools?
Can't wait to find out how fast is 1.4 compared to the previous versi...
I am wanting to hear what others think about this? Currently, I make a mysql database connection inside of a header type file that is then included in the top of every page of my site. I then can run as many queries as I want on that 1 open connection. IF the page is built from 6 files included and there is 15 different mysql queries,...
What is a good way to get the top 10 records from a very large collection and use a custom OrderBy? If I use the LINQ to Objects OrderBy method it is slow and takes a lot of memory because it creates an entire new collection with the new order. I would like a new method with the signature below that does not re-order the entire collect...
Hi
I'm using ADO.NET to communicate some db, and searching for a way to avoid boxing when setting the DbParameter.Value property to value-type.
Is there a way to avoid boxing in DbParameter.Value?
Thanks.
...
I am struggling with writing portion of an app which should behave like the native iphone photo app. Looked at iphone sdk app development book from Orielly which gave an example code for implementing this so-called page-flicking. The code there first created all subviews and then hide/unhide them. At a given time only 3 subviews are visi...
I've written a C++ library that does some seriously heavy CPU work (all of it math and calculations) and if left to its own devices, will easily consume 100% of all available CPU resources (it's also multithreaded to the number of available logical cores on the machine).
As such, I have a callback inside the main calculation loop that s...
Hi, i've a text with a very long list of words to highlight and calling setTextFormat() one for each word takes ages. There's some way to speedup this operation ? i've tried with a TextField not instantiate in the DisplayObject's list, to bypass the rendering stage but i've founded that the performance are the same. Any ideas ?
...
I have a website. It uses jQuery, a few plugins, Cufon, etc to spice things up a little, mostly visually.
The iPhone version does not need any of these files.
Can I, without resorting to subdomains, prevent the iPhone from loading these scripts?
<script src="js/jquery-1.4.min.js" type="text/javascript"></script>
<script src="js/browse...
Following this question - http://stackoverflow.com/questions/2082615/pass-method-as-parameter-using-c and some of my personal experience I'd like to know a little more about the performance of calling a delegate vs just calling a method in C#.
Although delegates are extremely convenient, I had an app that did lots of callbacks via deleg...
When browsing Stack Overflow I see mostly articles and questions about initializing and playback of audio files. My question: Where on the internet are tutorials for advanced audio playback and maybe editing for the various methods of playback? And maybe some tutorials on general workings of audio components, like the fundamentals of the...
After reading about how file based PHP sessions are not the greatest for performance, it has me thinking. Does this mean a PHP script including a lot of files is bad as well? Since it is including a file or is this different from the way session data files are retrieved?
...
I haven't got any experience with databases, but intends to learn it and use it on a web project I'm planning.
Though, I've got advice from a pal of mine that the use of databases should be quite more extensive than I planned. He believes in keeping almost all of the data in databases, where I find that databases are most convenient reg...
Which way is prefer ed and why to use for print, another css file with media="print" or @media print {....} in same file?
...
We're working with legacy data feeds and apps that consume them. We want to introduce Xml but the additional performance overhead is hard to justify. How have you addressed this issue?
We're working with a number of pre-existing data feeds, often files in a well known directory which are updated every few minutes. One approach to making...
How many records are considered normal for a typical SQL sever database table? I mean, if some of the tables in database contain something like three or four million records, should I consider replacing the hardware, partitioning tables, etc? I have got a query which joins only two tables and has four conditions in its WHERE clause with ...
I'm going to sign-up for a dedicated virtual machine from a renowned MS-centric web hosting company. The virtual machine has 1CPU and 1GB of RAM. I'll be running an ASP.NET website on it - the website is pretty simple (a few tables on the back-end DB) but must be as fast as possible.
For the DB I have two options:
1) Install SQL Server ...
I'm trying to optimize an app that makes a lot of RMI calls. According to JProfiler, more than 30% of the CPU time is spent in the sun.rmi.server.LoaderHandler.urlsToPath() method, which is apparently getting called during marshaling. This method calls URL.toExternalForm()
Is that normal? I haven't yet figured out which objects are gett...