187 Posted Topics
Re: [QUOTE=sohguanh;547693]Java design patterns should not be restricted to Java alone. Design patterns should be language independent.[/QUOTE] Some (most) design patterns in Java are done for getting around the inherent limitations of the language. Java tends to make a big deal out of little things. Many other languages don't need them … | |
Re: Do you understand what each individual line of your code does? Draw out your data structure on paper and simulate by hand what your code is doing, line by line. You'll see your problem then. Potential problems include... [icode]current[/icode] could be null; behavior differs when the first node of the … | |
Re: Yes. [url]http://www.gnu.org/software/libc/[/url] [code]/* Compare S1 and S2, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. */ int strcmp (p1, p2) const char *p1; const char *p2; { register const unsigned char *s1 = (const unsigned char *) … | |
Re: What does [quote]the id in itemsList will be repeat for each different item[/quote] mean? Is that your [i]whole[/i] design? | |
Re: Are you interested in a ground-up text editor, not using standard controls? | |
Re: What API are you using for setting up your windows? It depends on that. | |
Re: Given [i]k[/i] identical cats and [i]n[/i] scratching posts in a line, devise an algorithm for finding all the unique ways to arrange the cats about the scratching posts. There should be (n + k)!/((n+k)!n!) ways to do so (i.e. "n+k choose k"). So, given that your given string has [i]k[/i] … | |
Re: The first step is to learn C. What are your problems in regard to that? | |
Re: Well, for that, you could just plug in values of n such as -5 and -7 and notice a pattern. | |
Re: Here is a solution. Just convert it to C. [code]queens n = foldr qu [[]] [1..n] where qu k qss = [ (j,k):qs | qs <- qss, j <- [1..n], all (safe (j,k)) qs ] safe (i,j) (x,y) = i /= x && j /= y && abs (i-x) /= … | |
Re: A/(A+B) is less than 1, so O(log base A/(A+B) of (1/n)) is not equivalent to O(log (1/n)). Rather, it's equivalent to O(- log (1/n)), since log(A/(A+B)) < 0. Then, since log (1/n) = - log (n), we have O(- log (1/n)) = O(log n). Then the whole thing would be … | |
Re: Your mental image of the machine you're programming for is wrong, and your programs will be wrong unless you fix that. The .text portion holds code, the .data portion holds data. You can label parts of your .data portion and refer to them in your code. | |
Re: What makes you think that code will work? Write your code again from scratch and give an explanation of what you're doing and why. If at some point you find yourself at a loss as to what you're doing or why you're doing it, explain how so. Having to put … | |
Re: No. You'll be using some form of indirect comparison. (But "Yes" is also right.) | |
Re: It is impossible to make a program that can compute the time complexity of any program. But you _could_ compute the time complexity for some [i]trivial[/i] algorithms. You need to tell us on what subset of the set of programs you want to support computing time complexity. | |
Re: Haha. Of course, getting a Ph.D. won't necessarily get you the knowledge you need to make a compiler unless you do it once. And of course, you don't need a Ph.D. to get the knowledge either. Heck, a Ph.D. in chemistry wouldn't give you compiler-making skills :) Making a compiler … | |
Re: Try [url=http://factorcode.org/]Factor[/url]. I think a language like that would be great for a beginner. You'll get good at thinking about solving problems and good at general programming-thinking. C++ will mire you in a pit of unnecessarily complicated things -- you can always learn it later. VB 6 will give you … | |
Re: Wouldn't it be easier just to learn how to link glut? | |
Re: Do you have a textbook on the subject? Look in that. If you don't, then imagine interpreting the regular expression by hand. It's not hard to figure out how it maps to a finite automaton that way, if you understand how regular expressions work. | |
Re: One way to deal with 'if' statements is to simply take the maximum possible number of steps it could take. The comparison will take place every time, and assume the interior step will execute every time. This will give you an upper bound on the amount of execution time, but … | |
Re: [QUOTE=DimaYasny;512946]AFAIK Macs use ksh [/QUOTE] I think they used csh before, but when I got a Mac (early 2006) Terminal.app was running bash by default. If they changed the default to ksh, I'd be surprised. Of course, you can use whichever you want; more than one is installed. | |
Re: > 11 + 11i > nan --- i want this gone > -1 + -1i > nan --- whats this What web search terms have you tried? | |
Re: You'll need a database of cities and their latitude-longitude coordinates, or access to an online database, and you'll need an algorithm for finding the distance between two points on a sphere, given their latitude/longitude coordinates. The latter is done by the haversine formula. | |
Re: RPI teaches C++ first and doesn't mention C until some classes involving lower-level details, where you're just expected to pick it up. That works fine. And MIT starts off with Python... | |
Re: [QUOTE=omeralper;505326]i just want to know how to write a circular linked list destructor. anybody help?[/QUOTE] The same way you'd write any destructor. What's so hard about the circular linked list case? Just destroy all of the nodes. | |
Re: If you need to finish in four weeks, a suitable language would be the highest-level language that you already know. | |
Re: What is n in this case? The number of elements in the matrix, or the width or height of the matrix? Edit: or is it the number of 1's in the matrix plus the width? That would be reasonable, depending on the graph/matrix representation. Edit: see reply below. | |
Re: You need to put [icode]#define _GNU_SOURCE[/icode] [i]before[/i] the [icode]#include <unistd.h>[/icode] line, so that the preprocessor has the definition while processing unistd.h. | |
Re: If this is turn-based, the cleanest way to do this is with pipes. Have the AI programs communicate over stdin and stdout, and have the main program fork processes and setup pipes and launch the AI programs with the pipes tied to stdin and stdout. That way (also) you don't … | |
Re: One way to write this cleanly is to write a procedure that, given values for n and k, returns all the proper seating arrangements for these values. I would personally make a function with the declaration [inlinecode]vector<vector<int> > arrangements(int n, int k)[/inlinecode]. Your algorithm would then be to find all … | |
Re: [QUOTE=yagiD;496247]look for "random access files"[/QUOTE] This is wrong, except under the unusual circumstance that the lines are of a fixed, specified length and the amount you want to skip is large. Random access lets you move the read pointer around to a specified location, which does [i]not[/i] help you count … |
The End.