Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
Check out the new SourceForge HTML5 internet speed test! No Flash necessary and runs on all devices. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. ×

Comment Re: Doing it wrong? (Score 1) 600

Yes, there are of course ways to do it as you can always convert an iteration to recursion. But, it's pretty much pointless unless you're working with a pure language. If you're going to use a queue, why not just iterate?

In particular, a version that collects a queue is easily parametrized to work breadth first, depth first, or some alternative strategy.

        enum Mode { DepthFirst, BreadthFirst };

        void visit(Node* root, Mode mode)
        {
                std::list work { root };
                while (work.size()) {
                    Node* node = work.front();
                    work.pop_front();
                    if (node) {
                        printf("%d\n", node->value);
                        switch (mode) {
                        case DepthFirst: {
                            nodes.push_front(node->left);
                            nodes.push_front(node->right);
                        } break;
                        case BreadthFirst: {
                            nodes.push_back(node->left);
                            nodes.push_back(node->right);
                        } break;
                        }
                    }
                }
        }

Comment Re: Doing it wrong? (Score 1) 600

My algorithm class was just fine. But just for sake of discussion, please convert this depth-first binary tree iteration to breadth-first:

        void visit(Node* node)
        {
            if (!node) return;
            printf("%d\n", node->value);
            visit(node->left);
            visit(node->right);
        }

Comment Re: Doing it wrong? (Score 1, Informative) 600

You know, it might be a pretty good idea to not use recursion and just implement your own stack in many of those cases, because recursion locks you into one traversal algorithm, namely depth-first.

If instead you collect the new nodes to visit to a list, you are able to choose whichever order to traverse those nodes easily. Such as in the order of "most promising prospect".

With a list you can also wait until its size is larger than n and then split the list for multiple cores to execute, merge the resulting lists and gain some concurrency benefits this way.

It's just a few lines of code to do the stack anyways in modern programming languages anyway.

Comment Re:3D TV is dead? (Score 1) 399

> So...exactly like curved screens then?

It's funny though how my multi-screen setup has the displays placed on a curve instead of a plane.. As if there was some point in having the normal of the surface to be targeted towards the viewer..

For applications involving multiple viewers I certainly agree.

Comment Re:Shock and awe (Score 1) 253

I'm not at all sure why people should be upset about the small size and the related loseability, because isn't the whole point of these to be small?!

If they don't like them, perhaps they can opt not to buy them, or possibly buy from the competition. Oh, but they are not as small, and not white, don't start with an "i", we don't like them.. ;-)

And there certainly are other headsets with Bluetooth, have been for years. I've used to use one from Sony a few years ago and I'm currently using Phiaton BT 220 NC.

Comment Re:because (Score 1) 274

Well, there's some benefit to having fast round-trip-times. I've noticed that Shapeways can take weeks to deliver, but I suppose that cold be because I've only ever ordered metal things from them.

But no service can beat one hour delivery time.

This is probably valuable to you only if you're designing and building something, though.

Comment Not the right audience (Score 1) 230

You don't need to be worried about people who might think about hooking up a special router or even RPi to their network to deal with IoT devices, but rather with people that don't. And that's going to be pretty difficult to solve before all consumer routers come with decent default firewall rules or such additional functionality you're describing.

Comment Re:I predict that this will be totally ineffective (Score 1) 534

They'll simply subscribe to the new updates of Adblock, automatically install the latest version in a sandbox and determine which ads are being blocked. Then they automatically rearrange the urls, css or content in the page so that they are no longer blocked. Within minutes of the new release it's been neutered. Failing that an engineer is automatically alerted to look into it via the ticket system.

And what's to stop Adblock from doing exactly the same? The amount of resources. If Adblock starts blocking actually useful content on the page, people will just stop using it.

Oops, I should've patented that instead!

Slashdot Top Deals

The reason why worry kills more people than work is that more people worry than work.

Working...