Rashakil Fol 978 Super Senior Demiposter Team Colleague

> Can you please explain me the weakpoints of c++ language?

No call-with-current-continuation. No closures. I.e. C++ lacks fundamental features that other programming languages have (but most lack). It takes time and typing to do things that could be completed much more quickly and easily in other languages. No good macros (but templates are a pretty nice try). C++ is an abstract assembly language. (But that's also a strength, if that's what you need.)

But asking about weakpoints means nothing unless you mention a specific task. If you were to ask me what my weakpoints are, I'd say that I tend to be a bit lazy. I'm a student. But if I were a pro golfer, I'd probably talk about my short game. So, weakpoint at what? Every part of C++ is a weakpoint, if you're making some web application. If you're doing something with the Windows operating system, then PHP has major weakpoints. (If you're making a web application, then PHP still has major weakpoints :P.)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

And Indian friend of mine says yes, definitely.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Please stop acting like a retarded version of Narue.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can tell yourself. You understand how every individual part works, right? So simulate the code by hand, and you'll see where it's going wrong.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I have been working on this for the past week and i am almost done but i dont know why my program keeps crashing at the end game
check and also it doesnt realize that there is a piece that interrupts the connect four if it were like XXXOX it still says that X wins and it is due by 12 oclock tonight andi dont know what to due please help!!!!!

Run through the program by hand.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

In C and C++, the 'double' datatype can be used to store approximations of the real numbers. For example, double x = 3.5; . Use doubles to store all your resistances, and then you can do approximate arithmetic on them. These approximations can store about fourteen decimal digits of precision. They're like numbers in a calculator (where if you multiply (1 / 3) * 3 you're liable to get 0.9999999999999).

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Oh I wouldn't say you are evil. I'd just say you suffer from PMS 24/7, 365.25 days a year. :cheesy:

There aren't that many days in a year :-)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I never had a vending machine problem, but I've had airport simulations and matrix classes :-)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I don't know how much you know so apologies if I repeat stuff you already know.

Your constructor that uses no arguments is not assigning anything as the value of numerator and denominator. For that reason, whatever happened to be stored in memory at the physical location of numerator and denominator is not overwritten with anything, and so the variables numerator and denominator attain some arbitrary, unpredictable values. Your deconstructor is printing out these values.

You can only have one destructor. If you want your destructor's behavior to be affected by whichever constructor you use, you should use a third variable that indicates which constructor is used. (It could, for example, contain a number, 1, 2, or 3.) Then base your deconstructor's behavior on that.

However, this is not a good practice; I don't recommend it. (I generally don't recommend ordinary programs having deconstructors that print out information, but maybe I'm a bit too picky.) An uninitialized fraction, when used in a program, would be intended to later have some other fraction copied into it. E.g.

fraction x, y(3, 5);
x = y;

If you're going to be printing out values, you might as well recognize the bleak reality of the situation that your fraction contains some uninitialized values.

Generally speaking, for when you're designing programs in the future, whenever you want something to behave completely differently based on the way it's constructed, you probably really want to break your class into two different classes …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you signed up for piano lessons, but then decided that you didn't feel like taking them, would you ask somebody to go in your place?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You're right; this isn't really recursion; you're just making a cute loop (and never returning :-)).

Once you get this working properly, the stack datastructure you are currently using will be replaced by the chain of recursive calls (which in a way, can be thought of a datastructure, too).

Here is how I recommend you think: "Reading an expression either requries reading an individual number, or, it requires reading one expression, reading an operator, and reading another expression." See the recursion in the way I've defined 'reading an expression'?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

http://www.cs.rpi.edu/~hollingd/opsys/

See "Chapter 2: Processes and Threads" for lecture notes with sample code, and see "Writing a Shell" (which mentions pipes and reading and writing), with sample code.

(Using Unix of course.)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you're really interested in being precise, you can work out a detailed analysis based on the increasing inner loop iterations. But that's not always worth it, and certainly not for this question.

To give an example of what Narue's talking about, it's not too hard to see that the total number of times you output the value count1+count2 will be N the first time through, N - 1 the second time, N - 2, the third time, and so on.

Then the total number of times you print a number will be N + (N - 1) + (N - 2) + ... + 3 + 2 + 1. This is known to equal (N^2 + N) / 2. Then your running time is O(N^2), since N^2 /2 becomes the dominating term when N gets really large.

Once you've done this (or seen it) once or twice, it becomes obvious, and going through motions like these are a waste of time, anytime you come across some pair of for loops with a similar structure.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

User-interface-wise, I think it'd be best to detect code, and if the message has no code tags at all (and if code is detected), then ask the user if they'd like code tags (automagically added) and then have a neat little interface where they could drag and drop code tags around to the appropriate place if the detector got the boundaries wrong.

Of course, I'm dreaming a bit here, as it'd be annoying to implement this with a language as crufty as PHP, messing with code that already works, with very little to gain.

And I guess the people sophisticated enough to use a REAL real programming language are probably sophisticated enough to use code tags already, right? :p

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I say it's their loss if they don't post using code tags, so who cares?

(Of course, it's Dani's loss, too, in that case, so I guess Dani would.)

I personally care more about the large margins given when code tags are used. </attempt type="derail conversation">

((call/cc call/cc) (lambda (f)
                      (display "Worst infinite loop, ever!")
                      (newline)
                      (f f)))

This is what i'm talking about, above and below ^^.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

x * y = x + x + ... + x
(y times).

Just put a zero somewhere and use a loop that runs y times adding x each time.

Or in your case, replace x with a, y with b - c.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

No it's fine.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

1.An algo can't have both constant time and O(n^2).
2.There is no such thing as O(n^2 + <something>)

The time the algorithm takes is a function of more than one variable, so O(n^2 + <something>) is perfectly reasonable notation.

3.Time complexity of an algorithm is independent of PL, OS or anything at all. Even if you have hardware quick sort on your machine it is still O(n log n) (Worst case O(n^2))

You're missing the point. I'm talking about development time; every serious language has the same time complexities. For any given task, some programming languages take less economic resources than others. You wouldn't use Delphi to code a supercomputer, would you? If you're writing a MacOSX application, Objective C would be the language of choice, no? If you're a scientist doing some numerical calculation, you'd use Matlab or something like it, no? They're the cheapest tools for their respective jobs, and you'd be wasting money/time otherwise.


4.I still have no idea about what is the algorithm we debate on its time complexity.

You can derive a closed form of the summation by simplifying the relation

sum_from_1_to_K(x^n) - sum_from_1_to_K((x-1)^n) = K^n

iteratively or recursively. The algorithm implements this and then evaluates the closed form of the expression.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What happens when you use the delete key?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why do you keep asking the meaning of simple words like "out-dated" and "necessary" ?

Because it seems those words do not mean what you think they mean.

If you checked Evans Data Corporation's survey on my previous post there were no mention of Haskell, Lisp, GHC, ADA, Fortran. I never said bad, because the word "bad" is such a vague expression and relative. I say that they are old, useless and no body use (/remember) them anymore. The languages you mention are like Latin, maybe cool for the sake of it, but pretty much dead languages.

Your claim that nobody uses them anymore is contradicted by reality.

You call Haskell old, but it's newer than Delphi.

What are you talking about Ada and Fortran for?

What the heck ? If I didn't misunderstood, the variables here are a and b and n is constant. (Assume E is sigma operator) k=a to b E k^n
You can't calculate time complexity over the constant, your time complexity is O(k) = O(b-a) which is linear time. I can code that under a minute on almost any language.

No, constant time relative to a and b, O(n^2) relative to n. n is not constant, why would it be constant? Well, O(n^2 + n log ab), if a and b are arbitrary size integers, but not all programming languages have that built in. The algorithm is a matter of algebra.

This is all distracting from your original claim …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

First of all Perl is almost out-dated by Python.

What does out-dated even mean in the context of programming languages? As I said, add Perl or some language inarguably more powerful than Perl to your list of languages, so add Python, if you consider it better.

Second the job could be done in less than half an hour w/ both Delphi or C#. (Don't take the language alone, the acompaniying wizards and IDE features are also a criteria of choice.)

No, I don't think so. Please introduce me to this magical wizard you use for stripping text out of malformed HTML, organizing it into rows, categorizing it, indexing rows of a CSV by words stripped out of company names, and then throwing up a soundex-like search through a CSV file for similar words and prices, and then combining that information and communicating it to a picky telnet server.

And I challeng you to write the same code in Delphi w/o using a single line of code typing.

What is the value of not typing lines of code?

You best bet would be DCG (Delphi Compiler Generator) which is an enhanced lexical analyzer-parser generator (from gcc bison and yacc) which is free. Haskell is as old as berlin wall.

Then why didn't the Pugs project use it?

No, Lisp is as old as the Berlin wall. Haskell was created in the 80s. I fail to see your point about old = bad; Pascal is older than Haskell, …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

So to be a programmer do I need to know all these languages...

You would just need to make computer programs. That's the definition of programmer...

You know, you should try Scheme.
http://www.drscheme.org/

It's a lot more fun than Java and Visual Basic (and C++). And you'll be better at programming, having used it. Don't quit until you understand closures and call-with-current-continuation!

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Narue, don't listen to those people. This is not your decision to make. You must come back and be moderative at this forum. It's your only option! Do it at the expense of all other parts of your life, including your insanity, if necessary!

And in case you're not going to come back willingly...
[img]http://img.photobucket.com/albums/v285/covingtonjim/hypnotoad1.jpg[/img]

I will track you down and force you and your ancestors to solve word problems!

Okay, I don't actually sign the petition.

Sorry Comatose!

Rashakil Fol 978 Super Senior Demiposter Team Colleague

So my final opinion is C# and Borland Delphi Rocks. C and C++ are ok for performance on native code, portability and legacy stuff. For scripting and DHTML we can keep JScript (not Java Script) I guess and that's all. Tell me your favorite PL and I can tell you why it isn't necessary today w/ proofs.

"Necessary"? What does that mean? A programming language doesn't have to be "necessary," it has to be better. The only "necessary" language is machine code.

The other summer, I had a bunch of data in one text file, and then in another text file (an HTML file), I had a bunch of other data. I needed to process the information. One hour of Perl later, the job was done. Could the job have been done so quickly in C, C#, Delphi, C++, or Jscript? No. So add Perl, or some language inarguably more powerful than Perl, to your wall of necessary programming languages.

There are many tasks that the languages you've listed are not good for. For (a self-referential) example, if you needed to write a programming language interpreter, to run on PCs, as quickly as possible, what would you use? Haskell would be a better decision than the languages you've mentioned (and it would probably be the best decision).

If you measure programming languages by how much money they can make your business, then to claim that all you need are C#, C++, Delphi, C, and Jscript is laughable, …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Prove it for the cases where N is one less than a power of two.

Then, as you add new elements across the new bottom row, find a pattern into how much each individual element contributes to the total possible number of comparisons.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

lionsh, were you told that this is possible? I have a feeling it isn't possible.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

= is the assignment operator, not equivalence test operator, and you probably declared a as const.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you're thinking about "relationships" like association, containment, and such, then you're not thinking about solving the problem. Think about what your program would be doing when running minesweeper, and then the classes that you find convenient to use will fall out directly from the types of objects you're thinking of.

Rashakil Fol 978 Super Senior Demiposter Team Colleague
void Rational::reduce()
{
    int x = getNumerator();
    int a;
    x = a;

What is the value of x supposed to be right now?

int y = getDenominator();
    int b;
    y = b;

What is the value of y supposed to be right now?

int i;
    while (i = (a % b))

Why are you doing arithmetic with a and b, if they are uninitialised?

{
        a = b;
        b = i;
    }
    x /= b;
    y /= b;
}

How are the numerator and denominator supposed to change if you don't actually set them to the newly calculated values?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What you do mean, "access their computer"? A computer at home? This is probably not the right forum for this question.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I am wondering why it makes false claims on its front page.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What is this disease that people have which causes them to want their PCs to look like Mac OS X? This is the saddest thing ever.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What do you mean, not a chance? There are countless free ones, such as DrScheme.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

See my just-edited post (and, um, get a Scheme interpreter, hehe). You can choose complex numbers as your initial guess. You can also have cubic equations with complex coefficients!

Scheme happens to have built-in support for complex numbers, and I happened to be using it at the time. Maybe Python would have been a more readable choice.

[edit]port it yourself[/edit]

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yes. Newton's method works pretty well with third-degree polynomials, even if you use complex numbers. I think it actually converges all the time. Here's an example written in Scheme

(define (cubic-eq a b c d)
  (vector a b c d))

(define term vector-ref)

(define (cubic-evaler eq)
  (lambda (x)
    (+ (* (+ (* (+ (* (term eq 3)
		      x)
		   (term eq 2))
		x)
	     (term eq 1))
	  x)
       (term eq 0))))

(define (diff cubic)
  (cubic-eq (term cubic 1)
	    (* 2 (term cubic 2))
	    (* 3 (term cubic 3))
	    0))

(define (newton cubic start thresh displayer)
  (let* ((f (cubic-evaler cubic))
	 (fp (cubic-evaler (diff cubic))))
    (define (rec pt n esc)
      (displayer pt)
      (newline)
      (if (= n 0)
	  pt
	  (rec (- pt (/ (f pt)
			(let ((yp (fp pt)))
			  (if (= 0 yp)
			      (esc #f)
			      yp))))
	       (- n 1)
	       esc)))
    (call-with-current-continuation
     (lambda (esc) (rec (exact->inexact start) thresh esc)))
    ))

(define (show-newtons eq guess n)
  (newton eq guess n display))

;;; Use show-newtons to play with Newton's method and cubics.
;;; This uses 4x^3 + 3x^2 + 2x + 1, with an initial guess of 1+1i,
;;; and ten iterations.
(show-newtons (cubic-eq 4 3 2 1) 1+1i 10)
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Never knew dat. How do regular math on that. Is there some special nomenclature or something?

No special nomenclature, except that i * i = -1. Then you can add, multiply, subtract, and divide complex numbers of the form (a + bi), where a and b are real numbers -- and get complex numbers back. For example, (a + bi) + (c + di) = (a + c) + (b + d)i. Or,

(a + bi) * (c + di) = (ac - bd) + (ad + bc)i

Division uses a bit of a trick:

(a + bi) / (c + di) =
(a + bi) * (c - di) / [(c + di) * (c - di)] =
(ac + bd + bci - adi) / (c*c + d*d) =
[(ac + bd) / (c*c + d*d)] + [(bc - ad) / (c*c + d*d)]i

Then, for example, to "simplify" the expression sqrt(-5), you can use:
sqrt(-5) = sqrt(5) * sqrt(-1) = sqrt(5) * i. That's not really much simpler than saying sqrt(-5).

Rashakil Fol 978 Super Senior Demiposter Team Colleague

This is fairly straightforward to write.

http://planetmath.org/encyclopedia/CubicFormula.html

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You don't know how to do it? What have you thought?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

First, what if stdin doesn't contain a newline character? You've got an infinite loop, then.

Second, your linked list is finishing off with a node whose tail pointer (and character) is uninitialized.

Third, if the value passed for N is null, then the caller cannot see the linked list you've created at all, so you've got a memory leak.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

hey thats real simple but only if u have memorized hex and bianary

What are you talking about? What do you mean by "memorized hex and binary"?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I think a neat, but relatively simple problem, would be to create an reverse Polish notation calculator. It would take a line of input, like, 2 3 + 5 *, and display 25. You'd need to understand what reverse Polish notation is; you can look online, probably Wikipedia.

Or try playing with some other programming language(s), like Perl or Scheme or Ruby or Python or Io. Then you'll have some more time to think of some ideas :)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

is it bad to not be a student on this page because i thought it was for anyone who needed help with c++

It has more to do with the way you write. You seem like a drunken toddler, and nobody wants to handhold a toddler who (presumably) can't do any work on his/her own. There are easier ways to get one's fix.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Note that you should use square brackets, [ and ], rather than the curly brackets, { and }, in the tags I mentioned.

Oh, so you're saying we should use code tags? :D

Rashakil Fol 978 Super Senior Demiposter Team Colleague

He's talking about parsing sequences of DNA.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Think harder. A good night's sleep helps.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Here is Narue's tutorial on finding O notation bounds, which has had success with some learners: http://eternallyconfuzzled.com/articles/bigo.html

Here is my tutorial, which was helpful to one person looking for a more precise definition. It was written more as a clarification than an introduction. http://shobadobs.com/tuts/big_o.html

There's Wikipedia and MathWorld, but their articles on Big O notation seem pretty bad.

And um, don't you know how to use Google?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

This requires some basic algebra.

80 = 2m + w, where w is the width of the rectangle, m is the width of the margin.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I started C++ a few weeks ago..

I want to go to MIT for computer science, and for that i want to learn a few computer languages.

Go ahead, let the rest of your life be decided by a ninth grader. (Hehehe.)

I know how to make loops and random numbers. I am about to go into arrays and pointers soon, but before i get to the hard stuff, i want to know if i should learn C++.

Stop worrying about learning languages, and start learning how to make computer programs. What is the easiest way for you to start and write a useable program, right now? If you wanted to make a tetris clone, right now, how would you do it?

would it be more benifecial for me to learn a scripting language such as Python or C?

Yes, learn Python. Forget about C. Or use QBASIC. It worked for Ken Silverman, after all. Python's a great choice.

what will the colleges want out of me? will they expect me to know C or can i just jump into OOP?

Colleges expect you to know nothing. Colleges want good grades. If you do something Interesting while in high school, that's very good, too.

OOP? What's the point of that? It's a buzzword, used to describe a way of organizing data and algorithms. On the whole spectrum of 'advancedness' of programming languages, OOP (at least as seen with C++ and Java) is very near the bottom. And by the …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why do you care about the answer? The questions themselves are wrong.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Another way of putting it is that the symbol O(N log N) has exactly the same meaning as O(50N log N). So would the expected answer be 24, or would it be 1200? This is why coming up with any value by plugging numbers into O notation expressions is completely meaningless.