Forum: Computer Science Nov 15th, 2009 |
| Replies: 8 Views: 771 For example, suppose you have a function
int f(int n) {
if (n == 0) {
return 1;
}
else {
return n * f(n-1);
}
}
We want to measure its cost. But before we do so, we'll... |
Forum: Computer Science Nov 13th, 2009 |
| Replies: 8 Views: 771 Create a recursive formula for the time complexity and figure it out from there. |
Forum: Computer Science Nov 11th, 2009 |
| Replies: 4 Views: 546 Hey, you're right, it is easy for me. |
Forum: Computer Science Nov 11th, 2009 |
| Replies: 8 Views: 771 Let's look at this one. I'm going to ignore the swap for now.
Iteration2:
public static long dominoes(long x, long y){
long temp;
double koeficient = 0, faktor;
for(long i=0; i<=x+y;... |
Forum: Computer Science Nov 11th, 2009 |
| Replies: 8 Views: 771 Addition is O(n) where n is the number of bits in the BigInteger, and multiplication depends on the algorithm used: http://en.wikipedia.org/wiki/Multiplication_algorithm . That depends on the Java... |
Forum: Computer Science Nov 6th, 2009 |
| Replies: 9 Views: 456 Search for it on Google. It's a nice language that has access to all the Java libraries. |
Forum: Computer Science Nov 5th, 2009 |
| Replies: 9 Views: 456 |
Forum: Computer Science Oct 20th, 2009 |
| Replies: 8 Views: 436 When you run a Theta(n) operation n times, it takes Theta(n^2) time to do. I mean in general if you run an operation that takes n seconds n times, it's going to take n*n seconds. |
Forum: Computer Science Oct 18th, 2009 |
| Replies: 8 Views: 436 No, when n is the size of the array, resizing takes Theta(n) time because you have to copy all the elements. |
Forum: Computer Science Oct 18th, 2009 |
| Replies: 8 Views: 436 You would just write that each push and pop wolud take Theta(n) time. (And so the average time per operation is Theta(n) which is bad because we'd like it to be O(1).) |
Forum: Computer Science Oct 13th, 2009 |
| Replies: 5 Views: 386 MS Visual C++ Express. It should work.
Edit: as a stopgap, if you're short on time, you can run single-file C++ programs at http://codepad.org/ . But it's in your best interest to get a compiler... |
Forum: Computer Science Oct 13th, 2009 |
| Replies: 5 Views: 386 You can compile and run the program if you want to see if it works. |
Forum: Computer Science Oct 13th, 2009 |
| Replies: 3 Views: 417 Yes, read through the Time Complexity of Algorithm thread. It's a very old thread and has practical and theoretical answers. |
Forum: Computer Science Sep 25th, 2009 |
| Replies: 6 Views: 619 What courses are available and which ones are good depends on which school you're going to. There is a lot of variety in the ways various computer science departments teach. |
Forum: Computer Science Mar 4th, 2009 |
| Replies: 30 Views: 3,155 I'm going to haunt all your posts and make your existence on this forum a miserable one. |
Forum: Computer Science Mar 2nd, 2009 |
| Replies: 30 Views: 3,155 |
Forum: Computer Science Mar 1st, 2009 |
| Replies: 4 Views: 1,499 Anyway, your first example (where A gets assigned 54) is perfectly right. |
Forum: Computer Science Mar 1st, 2009 |
| Replies: 4 Views: 1,499 When you store something in B, that means the predefined value will be overwritten. |
Forum: Computer Science Feb 22nd, 2009 |
| Replies: 4 Views: 609 Well clearly, the matrix manipulation class should provide clear error messages, throwing exceptions when you try to do impossible things. What do you expect integers to do when you divide by zero? ... |
Forum: Computer Science Feb 22nd, 2009 |
| Replies: 4 Views: 609 Define 'provider' and define 'consumer'. What do you mean by 'putting a car in a garage'? That analogy can mean different things. (Maybe just tell us what you're doing.) |
Forum: Computer Science Feb 1st, 2009 |
| Replies: 8 Views: 4,459 |
Forum: Computer Science Feb 1st, 2009 |
| Replies: 30 Views: 3,155 What is the purpose of this post?
Reality disagrees with you. |
Forum: Computer Science Jan 31st, 2009 |
| Replies: 8 Views: 4,459 Nobody could help you unless you listed specific books for which you wanted solutions manuals. And since nobody here would know how to find them off the top of their heads, you might as well do the... |
Forum: Computer Science Jan 20th, 2009 |
| Replies: 5 Views: 1,399 |
Forum: Computer Science Jan 15th, 2009 |
| Replies: 16 Views: 1,033 Use C#, not Java. Java is the worst language in popular use, besides C++. |
Forum: Computer Science Jan 8th, 2009 |
| Replies: 5 Views: 630 And that doesn't matter. If you want better code writing techniques in languages like C#, the easiest and best way is to learn Haskell. |
Forum: Computer Science Jan 8th, 2009 |
| Replies: 5 Views: 630 |
Forum: Computer Science Jan 7th, 2009 |
| Replies: 5 Views: 630 Learn Scheme, C++, Haskell, and C#. That will take some time. You have to actually do projects in them, of course.
The languages you've listed, and most other languages, are not worth learning... |
Forum: Computer Science Nov 26th, 2007 |
| Replies: 8 Views: 1,965 How much money? 2 hours = $400. |
Forum: Computer Science Sep 17th, 2007 |
| Replies: 7 Views: 5,417 It's not that hard. First you can just grep the compiler name. For Haskell you can grep '.lhs'. If that fails, then for any compiled gc'd language you can just look at the garbage collector. ... |
Forum: Computer Science Aug 18th, 2007 |
| Replies: 3 Views: 1,226 Um, it's hard to understand you, so I'm going to guess that the answer depends on the definition of 'driver'.
Edit: but more seriously, I'd say no, based on the way the word 'driver' is used in... |
Forum: Computer Science Jun 14th, 2007 |
| Replies: 12 Views: 2,917 |
Forum: Computer Science May 9th, 2007 |
| Replies: 3 Views: 1,816 Store the array alongside a 'multiplier value' that you multiply the elements of the array by when reading them (and divide by when writing...). Then have MultiplyAll simply change the multiplier... |
Forum: Computer Science Apr 13th, 2007 |
| Replies: 29 Views: 6,549 That does the trick, except that computing A[j]/n takes log(n) time. But it is nice. |
Forum: Computer Science Apr 8th, 2007 |
| Replies: 29 Views: 6,549 Because it's wrong. You can make assumptions of O(1) comparison for comparison-sort based algorithms, mainly because the comparison operation is in fact O(1) average over the course of the sorting... |
Forum: Computer Science Apr 7th, 2007 |
| Replies: 29 Views: 6,549 Considering that computing sqrt(N) takes log(N) time (at least), square rooting all the integers that you're sorting will doom you to N*log(N) complexity. And it will just arrange your elements into... |
Forum: Computer Science Apr 5th, 2007 |
| Replies: 29 Views: 6,549 Are you sure you don't need to provide O(N) _average_ time? |
Forum: Computer Science Apr 5th, 2007 |
| Replies: 29 Views: 6,549 Here's some ideas about strategy: First of all, consider an extreme case, where sqrt(n) buckets have sqrt(n) elements fall into them. Well, know (by induction) that any bucket with more than... |
Forum: Computer Science Apr 5th, 2007 |
| Replies: 29 Views: 6,549 What about something like this:
Make buckets for the ranges 0..n-1, n..2n-1, ..., n^2-n..n^2-1.
Then, first go through the array and fill the buckets with counts of how many elements fall in... |
Forum: Computer Science Jan 1st, 2007 |
| Replies: 3 Views: 2,268 Now what do you mean, saying array insertion is carried out in constant time? What do you mean by insertion? Exactly what datastructure are you using to represent the array? If you've got some... |