Rashakil Fol 978 Super Senior Demiposter Team Colleague

This is an excellent example of the retardedness and overcategorization of design patterns.

The "builder" is just a function.

The "director" is the thing that uses that function.

So this "design pattern" is just fancy way of describing one particular case where you use the behavior of one function to parameterize the behavior of another function. Big deal.

> Then why the need for an extra layer of complexity? So construct method could be moved from cook (director) into PizzaBuilder.

You could. And that would also be the right thing to do in this case.

You have to understand that the people who write design patterns articles on Wikipedia aren't the brightest people in the world.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

But, you can transform every recursive function into a tail-recursive one by manually passing the call stack as an argument. If this has any advantage depends on the language, but usually I would say no.

This is actually not quite possible in every situation. Consider the following.

function go<T>() {
  if (doSomething<T>()) {
    go<Foo<T>>();
    doSomethingElse<T>();
  }
}

In many languages, you can't make a stack to represent the state of this function, without having to perform non-tail-recursive operations down the stack itself.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Binary code does not need to be compiled.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I really have never done this so I cannot be sure. But if i would guess, I would say you need to use some sort of outside server so that the two can communicate.

Wow, way to spend your time publicly guessing the nature of reality and missing.

> when i connet client to server, conect but they are not disconnect. what i do fo that???

Describe what's happening in more detail, so that we understand what's going on? Show some source code? Actually close the connection?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You have each child parsing function return the representation for the thing it has parsed. Then you combine the children return values into your return value. So the children will return trees and you'll combine these trees into a root node.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can find your answers at http://en.wikipedia.org/wiki/Design_pattern_(computer_science)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Maybe there are some tests that are highly correlated with abstraction ability. For example, suppose you gave the examinee a shuffled deck of cards and asked him to sort it in a particular order. Then have him shuffle it and then pick a different way of sorting it in that particular order. See how many ways he can think of. This is not an objectively measured test or one that's efficient to administer. (I don't know if it would be an effective test, either -- my point is that a good test might be some particular problem such as this one. I assume you realize that I'm not an expert on testing, I'm a babbling idiot on a message board.)

There are also the tests that some computer science teachers gave students which showed new people who had never programmed before some really simple pseudocode and asked them what the given program's output would be. (I forget whether they gave some examples of code with output, too.) Those students who adopted a consistent mental model of how the program would work were the ones who ended up doing well in the class.

But is that measuring abstraction ability? Is it measuring something correlated with abstraction ability?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Abstract is not a verb.

How you approach this problem depends on what your goals are, which affects whether you'd rather have a high false positive rate or a high false negative rate.

The proper general approach to your question also depends on the age of the people you're assessing.

> Also what questions could i use to test someones abilty to think of different uses for objects.

Are you hiring ninjas?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Um, show us some real code? We're not going to debug pseudocode, that's a waste of time.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Finally, in _mergeSort, erasing elements from the vector "lhs" and "rhs" is useless and might very well destroy your performance by adding a O(N) complex calls in the middle of your merge loops, I haven't worked out the math or a test-benchmark, but I doubt it remains O(NlogN).

It makes the running time ~(N^2). The cost at each point in the recursion tree is ~N^2 and so the sum of the levels will be N^2 + 2(N/2)^2 + 4(N/4)^2 + ..., which equals N^2 + N^2/2 + N^2/4 + ... which does not exceed 2N^2. (Normally the cost at each level is ~N which gives us N + 2(N/2) + 4(N/4) + ..., which gives us N + N + N + ..., which is N*log2(N) since there are ~log2(N) levels.)

Furthermore, allocating capacity for the result vector with a simple reserve() call will also make your push_back calls guaranteed to be O(1).

I'll note here that this will not affect the time complexity since the amortization applies, but it will improve performance.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I take it you mean that display(...) is not producing any output, other than a newline. You could figure out your problem by adding a few statements to that function that print out useful information like whether the list in question is empty or not. You could add a display(...) call after a single operation of one of your functions, to see whether it should work. You could try constructing a list of size one manually, in the main function, and see if you can display that.

The problem with your code is that you don't understand the semantics of how passing parameters to functions works. You seem to think that modifying the parameter 'q' will modify the variable you passed as an argument. This will not happen.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The errors were caused by the C++ code that the original poster wrote, which is intermingled inside the output of flex++, so C++ would still be the appropriate forum.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Wow Mr. Troll,

I am not a troll. There is a more reasonable explanation for my response, the possibility of which you have not allowed yourself to conceive, which is that your post was a bad post, bad for the reader and inappropriate for the situation.

How else would you have it expressed in text?

You didn't express it in text. You used equations. You showed yourself that the most easy way for you to express the algorithm was with equations.

NOT everyone has the same level of experience as you so you can't just drop a source bomb on someone who doesn't know programming and expect them to know whats going on.

Agreed. That's why I didn't drop a source bomb. You'll notice that it was a few lines. You might also notice that I was responding to you. You didn't need a bunch of exposition.

Flow charts are a huge deal.

No, they are not. Open up any textbook related to programming or computer science. How many flow charts do you see? They never use flow charts. They specify algorithms using pseudocode or real code, and they describe what the algorithms do using prose. Let's pull out some books at random, and see what they use for describing algorithms.

Cryptography Engineering uses lots of pseudocode, mathematical notation, and informal sequence diagrams for describing protocols.

Programming Language Pragmatics uses tons of pseudocode, tons real code, and has state machine diagrams, expression grammars, and, hmm, …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Where did you get admitted to grad school? They sure as heck cared about my grades!. Maybe you are better looking or something ...

Well, I would view something like a 3.6 GPA as abysmal, and a 3.8 in-major as abysmal.

What I really might have meant is that if you were interested in going to grad school, grades should be the last of your worries. If you're interested in the subject, you're not going to have a problem getting good grades.

Yeah, you really only need good enough grades. The point of grad school is to get the degree, not the grades. I notice you didn't negate the need to write papers...

Right, if you're getting anything higher than a B- in your classes in grad school, that means you could have spent less time studying and more time on your research.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Not really. You don't need a PhD in CS to be a computer scientist.

Edit: You also don't need to worry about your grades. Nobody cares about your grades as long as they're not abysmal and meet some minimum.

Edit 2: Especially in grad school. You're not supposed to get good grades in grad school.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Download Python and use it to make programs.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You want to convert the program to a data file? What does that even mean?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

natural language (see example below),

It's called "English," <<snip>>, do you speak it? Sorry, couldn't resist. [1]

flow charts,

<<snip>>

psuedocode

<<snip>>

control tables

<<snip>>

.
.

What I don't get is you talk about horrible ways of representing algorithms. Here is the tried and true good way to represent algorithms: source code! Note that "pseudo-code" is an archaic practice from the time when programming languages all required excess book-keeping or manual memory management or other bureaucracy. Pick a friendly language (Python, or Haskell) and write source code. Or if pseudo-code suits the purpose, go with that. But Python is executable pseudo-code, and Haskell is executable mathematics.

#2 How do I go about writing an algorithm?

...

Okay, first lets start by listing the inputs and outputs we need to solve our problem.

This is the most bureaucratic piece of bullhockey that I have ever seen. [2]

Wait!!!! What is an input and an output!?

I am in 10th grade and what is this.

With this type of problem you can pretty much go with a straight list of steps;

Or he could kill himself. This is the fallacy of the excluded middle. There is a third alternative! Read on to read it!

however, with more complex problems come more complex algorithms. You may not always be able to go with a straight list and this is why flow charts and control tables are great.

Flow charts and control tables …

Vexx commented: Completely useless post, only trolling +0
iamthwee commented: Samuel, do you have a sister? I would make love to her if her writings are adept as yours. Mwah x +12
Rashakil Fol 978 Super Senior Demiposter Team Colleague

How do you convert numbers to words by hand? Take that algorithm and write it in C++.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why don't you think of the efficient way.

Here are your sets A and B. Do these by hand and see if you can think of anything.

A = [0,83,71,39,9,34,77,20,86,9,82,45,88,44,34,38,24,61,48,3,96,66,
47,1,95,54,83,49,9,5,78,78,47,98,54,6,3,1,74,87,1,75,100,18,21,94,
19,15,4,78,72,48,63,56,18,31,83,84,5,65,54,88,38,93,83,16,11,21,80,84]

B = [17,85,78,41,85,56,9,12,83,100,59,66,56,86,66,82,98,92,14,43,96,69,
57,21,97,76,10,72,5,20,20,10,29,37,89,92,71,42,41,58,19,23,30,79,91,67,
57,48,77,11,98,92,60,87,93,48,28,37,3,48,43,58,62,10,10,18,35,28,20,2]

Rashakil Fol 978 Super Senior Demiposter Team Colleague

And "I" is capitalized! Acronyms and initialisms may be capitalized too.

No not really. A int, float, double, short and any variation of them are not object, they are primitive data types. Functions are not object as well.

But you could have implemented [icode]double[/icode], or an equivalent type with a different name, for example, using a class, in C++, and you wouldn't be able to tell the difference. The terminology we happen to use for a particular language should not affect the definition of "object-oriented." For example, if Ruby used the word "blah" instead of "class," it wouldn't cease to be object oriented.

Is that your definition or is it a standard definition?

There is no standard definition. But your definition is weird.

I get the feeling that the way you are using the word "object" is in a different sense than the way object refers to in Object Oriented Programming.

I'm not. If you say that an "object" is an instance of a value whose behavior is defined by a class, then main is not an object. It should be noted, however, that the value [icode]main[/icode] is indistinguishable from other objects in normal usage, except for the backward-compatibility of C-style function declaration syntax. In particular, in C++, there's no reason to distinguish between instances of primitive types and instances of classes that have no public members.

Also, it's really strange to say that a language isn't object oriented simply because there are ways …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Sure. Since your language's orthography apparently uses digits for any homonymous syllable, just use

(std::stringstream() << n).str()
Rashakil Fol 978 Super Senior Demiposter Team Colleague

> For C++ to be a complete OOP language, it would have such things as garbage collection.

Why do you need garbage collection to be a "complete" OOP language?

> Its not pure OOP language because not everything is an object.

Actually in C++ everything is an object.

> One could write a C++ program without even using one object. Even main is not a function of an object.

main is an object.

> I would like to hear your argument of why C++ is a Object Oriented Language if you don't mind.

C++ lets people use inheritance to implement run-time polymorphism. And that's what an object oriented language is. (Why are you capitalizing "Object Oriented", is this some kind of religious thing like you see in the Bible?)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

we have many differences between c and c++
1. C does'nt support name mangalling which is one of the technique of reducing the code length or one can optimize the code

It's not a technique for reducing the code length and it's not a technique for optimizing code. Name lengths don't affect function speed. Name mangling is an implementation detail used to exist in the C ecosystem.

2. c support variable size of arrays on the stack but C++ doesn't so execution of teh code is faster in C as compared to C++

Variable-sized arrays in C99 are very rarely used, and it's generally a bad idea to use them, and even if it weren't, you can use alloca in C++ anyway, and they're not faster than techniques that avoid using them (and avoid using alloca) except in marginal small-length one-time-use cases that don't affect program performance anyway (and if you did really care about performance you could resort to alloca anyway). So it's not a big deal or anything that people spend time worrying about.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I beg to differ, C++ is not an OO language.

What do you call the set of languages that support classes, inheritance, and runtime polymorphism? Unless you're planning on sperging out some "C++ is multiparadigm" crap, or unless you're a dynamic language weenie, there's no way you can say C++ is not an OO language with a straight face. You haven't bothered explaining yourself or being helpful, and your post is designed entirely to flaunt your sense of self-importance, so back your statement up or GTFO.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you're afraid of the USA and Americans in general, then you've apparently never been here. Believe it or not, you can walk down the street, and people don't shoot you! Not even the police! Why are you so afraid of people?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

In the long run (where "long run" means 10-20 years), gun rights don't matter. Once desktop manufacturing becomes affordable, people will be able to download whatever kind of weapons they want.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

This is the dumbest news story ever written in the history of Daniweb.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

How much time you have spent on these problems?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you're a fan of it, you should know more about it than us.

jonsca commented: Nice one +4
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Draw lines between every pair of points, order lines by number of points covered or nearly missed, remove lines with the fewest intersections until no more can be removed. Optimal solution not guaranteed. This is an n^2 log(n) algorithm though.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

That depends on the team.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Ah, there we go.

iamthwee commented: Face...Palm moment? +0
Rashakil Fol 978 Super Senior Demiposter Team Colleague

The control panel's links point to the first page in a thread. Which is bad.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

They're used for every kind of thing. Or to be precise, Lisp is used for every kind of thing (except bootloaders, hahaha), and Python is used for every kind of thing that doesn't need to use much of the CPU.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why are the circles pointing at each other? Am I going to get virused? HELP! IM SCARED

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Nobody can, unless you are lucky enough to run into somebody who's an expert on both Swing and Racket. See http://docs.racket-lang.org/ and look at the GUI toolkit documentation. Racket's documentation is excellent.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

How about a cryptographically secure assassination market?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yep, it's an interesting problem. How about that.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I have to learn cobol

Haha.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Okay. Just learn these things.

1. Learn how to program.
2. Learn how to program C.
3. Learn how to write a compiler, and make one that creates i386 executables.
4. Study these books: http://www.amazon.com/An-Application-Security-Reading-List/lm/R2EN4JTQOCHNBA/ref=cm_lmt_srch_f_1_rsrsrs1 and read academic papers in the field.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The question u made raised is can't possible. Basically the linked list traverse the highest value to the next node. So how it is possible?

There is no way to take the elements from the small unsorted linked list and add it to the larger sorted list. The linked list required that O(n^2) as a part of time complexity. Without reaching to the O(n^2) linked list doesn't works.

You are wrong.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What if the smaller list were sorted? Would you be able to do it then?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Linux is written in C. Look at its scheduling algorithm and see how it could be improved.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

A Java compiler would be based on Java. Write one in Java.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You'll look stupid when you say C#.NET, because that's not an actual term people use. So you should just say C# in the future.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Then why do we use words like "for", "while", "if", "then", etc.? Might as well use "f", "w", "i", "t", etc. And why use infix notation?

"Natural language" doesn't mean using mathematical notation. Applying unique, memorable names to things is not the same thing as natural language, either. For example, sin^2(x) isn't natural language, and neither would be sine^2(x). If you've ever found yourself stumbling over saying "the expression <blah>" or "parenthesis <blah> end parenthesis" in an effort to be clear, you can see how mathematical notation is superior to natural language (for certain things). I don't think anybody would argue that "sum . map (** 3.0) $ [1..100]" is natural language, either, or that the uses of infix operators in that expression has anything to do with natural language. The dollar sign operator isn't even verbally pronounced.

Nor is the use of "if" or "for" or "let" or "function" in programming languages an example of natural language. They are memorable keywords used in various languages because it's common practice to let "if" be used for conditionals, "for" to be used for linear iteration, "let" to be used for declaring variables, and maybe "function" as a keyword used in function declaration syntax. When there is a line-up with natural language, it's more of a pun. "unless (x < 3) { ... }" is cute, but it's just cute. There's a reason why programmers who don't speak English as a first language end up using these keywords without problems, …

Bench commented: Excellent argument +5
jonsca commented: Excellent post +4
Rashakil Fol 978 Super Senior Demiposter Team Colleague

First you should try a basic hill-climbing algorithm and see how well that converges to reasonable solutions.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Ignore all these scrub posters and use Horner's algorithm.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Dealing with the syntax is the easiest part of programming and of learning how to program.

> There is a balance between making programming languages look like natural languages and having them be as unambiguous as possible.

I would disagree, completely. There is no reason to make programming languages look like natural languages.