Rashakil Fol 978 Super Senior Demiposter Team Colleague

Look at the project's webpage for information.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Write one in Javascript, it should take no more than 15 lines.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

1. Use snprintf to generate the appropriate path name.

2. Think of an appropriate data structure, that's what this exercise is all about.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What does "swop" mean?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

None.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

And... why don't you know how to solve this problem? Do you know what the "set number" is? What a 4-way set associative cache is? What a gigabyte is?

Why do you not know how to solve this problem?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

> sin^(2) *((Pi*x)/4)

Lolwut?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

> I don't think the order makes a difference, because the tree will just re-balance itself before it adds a level.

Try reading how rebalancing works and then reconsider your opinion.

Also your answer would be wrong regardless.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

As if a headhunter would know anything about anything.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What parts of C do you have a hard time grasping?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Rashakil, can you give me an exmaple of a "simple programming question"

Some examples: Reverse a linked list. Create the mirror image of a binary tree. Verify that a binary tree is a valid BST. Print out the numbers from 1 to 100, but print fizz instead for any multiple of 3, buzz for any multiple of 5, and fizzbuzz for numbers that are multiples of both 3 and 5. Write a function that word-wraps a line of text into 80-character wide paragraphs. Write a UTF-8 decoder (after being reminded how UTF-8 works). Write a program that prints out how many unique tic-tac-toe games there are.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Well your thesis is going to be scientifically speaking complete nonsense so maybe you should think of something else.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Uh yeah professionals copy files from one place to another... because they need them there.

It's certainly a lot easier with the command line than opening up a couple of windows with the GUI, making sure they don't overlap, and navigating to the folder and dragging and dropping. Or opening an SFTP client... lol.

No you just cp x y and you're done.

Or you scp foo@bar:~/path/to/x y . Instead of opening a bunch of windows and being an all-around slowpoke.

The main benefit of GUI features is for graphical output, not graphical input.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

And out of curiosity Rashakil Fol, why'd you say to avoid big companies that don't ask technical questions. Surely if they're a big company and don't ask technical questions then it'd be a lot easier and beneficial to get a job with them wouldn't it?

It's a great place to work if you're mentally retarded and can't answer simple programming questions, or if you'd like to have such a person as a coworker.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Companies to go for: Small companies. Companies that ask you to write code on the whiteboard in interviews. Companies that ask technical questions in basically all the interviews.

Companies to avoid: Large sprawling companies. Companies that don't ask technical questions, or ask very easy ones.

There's a bit of a gray area for large software companies that are pretty good places to work. Some are good, some are bad.

Also, do employers care for "bad coding" i.e. if using a lot of <br> <font> tags in html rather than doing it all in the css. Or redoing something by hand each time in php rather than creating a function for it?

They do care about that. Obviously that's bad code. (<Br> tags are not bad. Machine-generated font tags are not necessarily bad, but they probably are bad the way you'd use them)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The proper functions are the basic string handling functions. It's called programming. There might be some command line parsing library but it is so trivial to support this feature yourself.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Lol a GPA calculator.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

There are some HTML parsing libraries in some languages but really it's trivially easy to write your own sufficiently good algorithm to play the game.

Edit:
One easy way to do it might be Greasemonkey (or some old version of Greasemonkey if they've locked down the security a bit). This is what I did for some infamous stunt I pulled.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Taywin is basically incredibly confused.

If your algorithm does n^2/2 + n/2 operations then its running time is Theta(n^2).

As a general rule the polynomial a*n^k + b*n^(k-1) + ... + c*n^0 is Theta(n^k).

In particular, (1/2)*(n^2) <= n^2/2 + n/2 <= n^2, for all n >= 1. (Can you prove this yourself?) This by definition means that the function taking n to n^2/2 + n/2 is in Theta(n^2).

Edit:
You could also say that your formula n*(n+1)/2 is Theta(n*(n+1)/2). This is never incorrect. Of course the idea is to simplify it, since Theta(n^2) = Theta(n*(n+1)/2).

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I strongly condemn jwenting's post. Please don't just label as 'Indians' in general. For your kind information, it is Ramanujan's Mathematics, which stands as the base for Modern Computer Electronic Systems

Lolwut?

Ramanujan has practically nothing to do with computing. Maybe he devised a few quicker algorithms for computing pi.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why are you even being asked such a question? Why are you not asked to write actual code?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

How many patients will it take to remove the stand, exactly?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Clearly the right-wingers do not understand the concept of "trade-off" or "cost vs benefit" (which is odd since they are usually so supporting for the market which is all about that stuff).

And yes they (right wingers) understand the idea of trade-offs. Don't talk to people like they're stupid. You might feel all high and mighty, but that's a fantasy. (Or did you think you were actually convincing? I don't get your behavior. Why would you act so stupid so deliberately?)

Anyway, the cost of removing the freedom to own a machine gun/grenade launcher/hand gun is small since almost no-one will ever use such and item for useful purposes and most people have no desire to own one.

To say that you have the right to bring men with guns and lock people up in cages who have not harmed others because you "calculated" that this policy produces a more optimal society is complete conceit on your part. Also, to actually carry out that act is immoral.

Do you have any questions about this concept and why some consider it true?

Another thing that you should ask yourself (since you're a utilitarian, you need to figure out precisely what is worth optimizing) is whether you value lives too much. If you could mandate that everybody do one hour of work each in order to collectively save 50 people's lives, would you do it? How about thirty minutes? Five minutes? What if we had the option to pay …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

All algorithm you need to know are usually already implemented efficiently by the libraries or some other well known vendors. Your job should be to efficiently use them to complete your project and increase your productivity.

This is completely not true.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The point is that we should ban fertilizer.

(And we should ban technology in general.)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I don't know what made you come to that conclusion.

But about 1% of the population are psychopaths, and 50% of people will have some kind of mental illness some time in their life. Asking that all people not have access to weapons of mass destruction (machine guns, bombs, etc...) so that those few who will become criminals have a limited capacity to cause mayhem and chaos doesn't assume everyone is guilty or everyone will become a murderer. It is accepting the fact that there has never been a time in human history without some murderers (thus it is unlikely there will be such a time in the near future).

Going by that reasoning you might as well throw everybody in prison right now. The only reason you think that's preposterous is because you want to live outside of prison. Other people want to have shoot man-killing devices, or simply have them. Yet here you are applying your fallacy to what they want to do, while not applying it to what you want to do.

If you want to go for some utilitarian "thousands of people should go without the freedom to have automatic weapons in case one madman gets his hands on one" route, you're going to have to daydream about scenarios that are extremely rare. There is a vast scarcity of mad gunmen in this country, who could just as well be mad food-poisoners or mad derailers. You're building your ideas about "gun security" out of movie-plot …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You have a stack overflow, because your algorithm is hitting an O(n^2) case.

You can solve this by recursing into the smaller subproblem and then tail-recursing (i.e. looping, updating variables and jumping to the top of the function) for the larger subproblem.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Wow, some people here sure don't like the idea of innocent until proven guilty.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

A general understanding of trees and caching associative operations in their internal nodes will never go out of style.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

2) Hashing is at worst linear time in theory? So that still makes it O(n^2) in theory

That's why there was that verbiage about selecting a hash function randomly from the universal set of hash functions. So we can say that for some C the probability of the algorithm taking more than C*n time approaches zero as n gets arbitrarily large.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'm so confused on how to calculate the running time of an algorithm. i've searched online but i can't seem to understand any of the explanations hence my question: how do you calculate the running time of any algorithm?

You count how many primitive operations it takes (as a function of the size of the input). Then you convert that formula to O notation, since the actual formula depends on your notion of what a "primitive operation" is.

If the number of primitive operations that happen depends on the actual value of the input, not just the size, then you calculute some upper bound on the number of primitive operations your function could take. Then you convert that formula to O natation.

Edit: A "primitive operation" has to be one that takes a bounded amount of time. That is, there is some value C for which every "primitive operation" in the programming language takes less than C seconds. That way your computation of running time corresponds to actual time. In certain circumstances, you might make different assumptions that don't correspond to actual clock-time, depending on your needs.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

That depends on how your program is written. Does it take the file name as a command line parameter? Does it read the file as standard input? It depends.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

But then you would have to compare to x every time when x changes.

Now you're changing the problem from the original way it was stated.

Moreover, what happens if there is more than one pair of a and b that sum up to x. Algorithm must run in linear time.

My response is simply a demonstration of how your proposal to construct a hash table doesn't make sense. And the running time has nothing to do with the possibility of having multiple pairs sum to x, it's always O(n^2) whether you like it or not.

As for getting it running in O(n): You can easily get an algorithm running in O(n log n) without any use of hash functions. I hope that is obvious. Once you start thinking about that solution, it is easy to think of an O(n) solution that uses a hash table.

(Assuming you have the magical hash function that can distinguish n inputs without needing to look at log_2(n) bits of each value. Which is what we are assuming, isn't it?)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You'll need to use map or write a recursive function that is like map.

Note that your output requires O(n^2) work to construct, which means you'll need an O(n^2) algorithm here, not one of these obviously-O(n) algorithms.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I think the reason as to why use hashing is to do a fast look up on the hash value of x and see if it exists in the hash table constructed from the summation over elements of A and B.

You see, that's ridiculous, because instead of putting the elements of {a+b : a \in A, b \in B} into a hash table, you could just compare each of them to x.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Hashing functions have absolutely nothing to do with the problem you're trying to solve. Your question is completely ridiculous or else you've paraphrased it incorrectly.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You crossposted this question in the IT Professional's Lounge. Considering how strongly patience correlates with success, your goals are probably unrealistic.

It won't take anywhere near 10 years to learn several different programming languages. It takes about a day for an experienced programmer to learn a reasonable programming language. If you know Scheme, C++, Javascript, Haskell, and C, you've got the programming language depth to pick up Java in a day, and more baroque languages like Ruby or Perl in a week or so.

If you don't suck at programming, you can easily make a million dollars by working for ten years.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Hi, does it matter which edition of the books is used? For example Linear Algebra and its applications has a 1988 and the next one I found is a 2004 edition.

There are different textbooks by that name, so you'll need to tell us who the author is. (The one by Strang has dates 1988 and July 2005 so if that's the author I don't know where 2004 comes from.)

If it's Strang you're talking about, no it doesn't matter that much, but the 2005 book has more problems.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

So conclusion? One team was formed to write Visual Studio in Assembly or Basic where high level compilers could be written such as C++, asp.net, Visual Basic, C# and the Robotics Framework.

Look how stupid you are.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The distinction between CS and software engineering programs varies on a school-by-school basis and can be discerned by looking at the course descriptions. The main difference in curriculum is usually that software engineering programs omit important classes (if you want to be good at programming) and instead spend time teaching stuff you'll learn in your first job after college anyway.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

2 programs a and b that have performance as o(log n) and o(n),if each program requires 10 sec to solve a problem of size 1000,what is the time required for each to double.

There's no way to answer the question.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You need to make a helper function, analogous to identifierOrKeyword, that scans past the first newline in the string. The span or break functions might come in handy.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The example you made does seem simpler than the iterative way. Would doing it this way effect the speed at all or do you think it would execute the same speed both ways?

It would execute with the same speed. It draws the same number of squares, including all the ones that are occulted by larger squares.

If you wanted a faster implementation, ...

def drawFigure(levels, size, x, y, ratio):
    draw3(levels, size, x, y, ratio, 1, 1, true)

def draw3(levels, size, x, y, ratio, dx, dy, fourth_too):
    if levels >= 0:
        h = size / 2
        sr = size / ratio
        draw3(levels - 1, sr, x + dx * h, y + dy * h, ratio, dx, dy, false)
        draw3(levels - 1, sr, x - dx * h, y + dy * h, ratio, -dx, dy, false)
        draw3(levels - 1, sr, x + dx * h, y - dy * h, ratio, dx, -dy, false)
        if fourth_too:
            draw3(levels - 1, sr, x - dx * h, y - dy * h, ratio, -dx, -dy, false)
        drawBox(x - h, y - h, x + h, y + h, 'green' if levels % 2 else 'red')

That only draws the squares that are visible.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Let's make a fair comparison by writing a program that has access to the same draw-me-a-filled-in-square API and uses recursion. Let's say we have a drawBox(x1, y1, x2, y2, outlineColor) function as our drawing primitive that draws a filled in square with an outline.

Let's implement drawFigure(levels, size, x, y, ratio) that draws the figure with "size" being the size of the central square, (x, y) being the center point, "ratio" being the ratio of square sizes (which is just 2 in your programs). So drawFigure(levels, size, size, size, 2) would implement your program.

def drawFigure(levels, size, x, y, ratio):
    if levels >= 0:
        h = size / 2
        sr = size / ratio
        drawFigure(levels - 1, sr, x - h, y - h, ratio)
        drawFigure(levels - 1, sr, x + h, y - h, ratio)
        drawFigure(levels - 1, sr, x - h, y + h, ratio)
        drawFigure(levels - 1, sr, x + h, y + h, ratio)
        drawBox(x - h, y - h, x + h, y + h, 'green' if levels % 2 else 'red')

And that's it!

That's a lot simpler than a for loop inside a for loop inside a while loop.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It makes you have to think about how it's going to unwind after the recursion is done. With a for loop, the thinking is very linear.

Because you have a problem that can be done linearly with filled-in squares. It's a perfectly legitimate way to solve that particular problem. Now make it so that the width of the smaller squares is 1/3 the width the next bigger square instead of 1/2.

And under recursion, the thinking is very logical. All you have to think is "my 3/4-square (with n levels underneath) has three half-size 3/4-squares attached to it here, here, and here (with n-1 levels underneath).

I have written my own language interpreter, and never used recursion.

How are you parsing expressions like (1 + 2 * (3 + 4))? How are you representing them? How are you handling control structures within control structures? I'm going to guess this language interpreter is incredibly simplistic.

Rashakil, how did you learn how to program? Did you start off by taking a class or did you teach yourself in an unofficial manner? I taught myself since I was 10 years old and I think that's probably why there's a difference in the ways we would approach the problem. It's probably because when I taught myself, I always used for loops and have become used to using them. For you, I am guessing you learned recursion fairly early on, and then therefore find it easier to think about problems that way.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I had to write a triply nested recursive algorithm to draw squares on the screen.

By "triply nested recursive algorithm", I take it you refer to a function which calls itself in three places.

Your probably thinking how hard could it possibly be to just draw squares on the screen? Well look at the code below.

Judging by the extremely simple program below, it's quite easy.

Anyway, I don't understand why CS teachers emphasize recursion so much. In my opinion it just over complicates the problem.

The reason it's emphasized is because it's very useful. It also forces students to understand how their programming language (in particular, regarding the scoping of local variables and function parameters in recursive functions) actually works. Recursion is used all the time in all kinds of software, so it's not like they're going to ignore it.

I also don't like the idea of pushing so much data onto the stack when a simple for loop will do the trick.

A simple for loop won't do the trick. Go ahead and try converting the program below to a simple for loop. You'd have to manually implement a stack of state variables. A recursive implementation expresses the behavior in a much more straightforward manner, because you can follow the behavior of the function in a straightforward manner.

All of my CS teachers (had three so far) taught recursion even before talking about loops. Just think about how little recursion is used in the …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

@mustafaneguib: I understand that the need for a new language is minimal at this point because there is pretty much a language for every need. It would be nice though, in my opinion, if there was a language like .NET that compiled to native code for faster execution. Anyway, I don't design programming languages for a certain purpose, I just do it because I like designing programming languages (and like to brag about something most people wouldn't understand).

.NET is not a language. WTF are you talking about?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I am not sure why people downvote others when someone tries to help.

My mouse slipped and I didn't realize there is now an undo feature.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Are you compiling with optimizations on?

Maybe you shouldn't evaluate sqrt(j) every time through the for loop. That sounds like something an optimizer might catch, but even then you're converting i from int to double every round of the loop.

You could use a better prime testing algorithm. Miller-Rabin would do fine. See http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Currently I am studying multi-thread, and I feel pretty confusion about the concept
of blocking, non-blocking, synchronous and asynchronous.

Exactly, there are so many explanations, and each of them have something differents,
someone says synchronous could be non-blocking too, someone says synchronous must be blocking.Someone says asynchronous must be non-blocking, someone says it could be blocking too.

Someone says synchronous is same as blocking, someone says it is different.

I am extremely confuse about those concepts now, don't know how to discern the differents between them.

Could anybody help me clear up my mind?Thanks a lot

Okay, here's what they mean.

"Blocking" and "non-blocking" describe individual operations, or individual function calls (or system calls). A blocking operation is basically one that can take a long time. In particular, if you made a function that read data, and waited for data to arrive before returning, it would be a blocking operation, because it could take arbitrarily long before the data arrived, and the CPU would be idle (or another thread would be scheduled to run). A non-blocking operation, on the other hand, would be one designed to return immediately, with some return value indicating that it does not have data at this time.

If you want to manage multiple forms of I/O at the same time, blocking system calls are fine as long as you use multiple threads. A blocking system call will only block the thread it's on, and that thread has nothing better to do, …