187 Posted Topics

Member Avatar for piers

[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 …

Member Avatar for neocoder
0
350
Member Avatar for KimJack

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 …

Member Avatar for sohguanh
0
920
Member Avatar for blcase
Member Avatar for Nyx18

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 *) …

Member Avatar for sarehu
0
112
Member Avatar for nblue

What does [quote]the id in itemsList will be repeat for each different item[/quote] mean? Is that your [i]whole[/i] design?

Member Avatar for nblue
0
107
Member Avatar for nikita_knp

Are you interested in a ground-up text editor, not using standard controls?

Member Avatar for rizwan_aman007
0
160
Member Avatar for prushik
Member Avatar for prushik
0
86
Member Avatar for losh177
Member Avatar for Ezzaral
0
112
Member Avatar for casperguru

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] …

Member Avatar for sarehu
0
170
Member Avatar for snucho
Member Avatar for jayohn
Member Avatar for Nick Evan
0
109
Member Avatar for satishvengala
Member Avatar for lulusweety
0
242
Member Avatar for briansmall
Member Avatar for manushetty_2005
Member Avatar for nvnq

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) /= …

Member Avatar for technogeek_42
-2
147
Member Avatar for dirk_gently

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 …

Member Avatar for dirk_gently
0
169
Member Avatar for bobrien314

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.

Member Avatar for sarehu
0
63
Member Avatar for olams

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 …

Member Avatar for olams
0
148
Member Avatar for conan19870619

No. You'll be using some form of indirect comparison. (But "Yes" is also right.)

Member Avatar for Narue
0
85
Member Avatar for shinoske

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.

Member Avatar for Salem
0
109
Member Avatar for zeiken

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 …

Member Avatar for Ancient Dragon
0
112
Member Avatar for DangerDev
Member Avatar for seneye

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 …

Member Avatar for technogeek_42
0
176
Member Avatar for venomlash
Member Avatar for kelvinco

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.

Member Avatar for kelvinco
0
49
Member Avatar for vladdy19

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 …

Member Avatar for sarehu
0
58
Member Avatar for arunpawar

[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.

Member Avatar for sarehu
0
106
Member Avatar for beast

> 11 + 11i > nan --- i want this gone > -1 + -1i > nan --- whats this What web search terms have you tried?

Member Avatar for sarehu
0
143
Member Avatar for jmvr_danga_14

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.

Member Avatar for WolfPack
0
2K
Member Avatar for jsully1

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...

Member Avatar for jsully1
0
191
Member Avatar for omeralper

[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.

Member Avatar for twomers
0
150
Member Avatar for zino100

If you need to finish in four weeks, a suitable language would be the highest-level language that you already know.

Member Avatar for invisal
0
299
Member Avatar for amishosh

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.

Member Avatar for invisal
0
97
Member Avatar for n.aggel

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.

Member Avatar for ssharish2005
0
651
Member Avatar for Jishnu

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 …

Member Avatar for Jishnu
0
356
Member Avatar for Archimag

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 …

Member Avatar for Archimag
0
161
Member Avatar for jobs

[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 …

Member Avatar for yagiD
0
108

The End.