Tag Info

New answers tagged

1

When you find a statement like "M number of comparisons" about sorting algorithms in literature, the author typically means the number of comparisons between the sorted elements, not the comparisons of something like loop indexes. So if you are asked this in a university assignment, I would guess that this is the number which is meant (but to make that ...


2

One great resource: http://bigocheatsheet.com/ I can tell you right off the bat that: Bubble Sort is in worst case, O(N2) Insertion Sort is in worst case, O(N2) Selection Sort is in worst case, O(N2) Quick Sort is in worst case, O(N2), yet is typically O(n log n) Merge Sort is in worst case, O(n log n)


0

Well, if I understood correctly, if there is a cycle somewhere along the path then you can't have a topological sort. Even if you solve the cycle problem in the case of a FK from table A to itself (I didn't understand what you meant exactly with the term "join table" though, but it's certainly because of my lack of experience with databases) you could always ...


0

Filtering should be done in the database. Databases are really good at filtering results using the WHERE clause. One should always govern that amount of data being queried, paged and returned. You don't want millions or rows going across the network and you don't want the database to page a result set that has a million rows as it is a lot of needless ...


0

Here I will assume that the weight is an integer with a (relatively) short range (i.e. [0, N)). The reason being that if you have way too many different weights, then each weight will have so little entries that it is not even worth sorting those entries alphanumerically... I would hash the dictionary by weight and then simply use some tree structure to ...


0

You could look at this as a simple sorting problem. Consider each "word" to be a unique symbol in an alphabet. To make this efficient you might parse all your sentences into tokens, where each token is a unique number representing a unique word. Does word order matter? You did not specify. If it does, then sort the words (or tokens) within each sentence. Now ...


0

If this is a real life problem, then you must expect inconsistent data, like A beats B, B beats C, C beats A. You already showed inconsistent amounts of information: A played B and D three times each, but didn't play C at all. I'd make a model describing how likely a team is to beat another team, and find values that agree best with the model. For example ...



Top 50 recent answers are included