- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Or perhaps even better:
Recursion (n) re.curs.ion Definition: See recursion (n-1)
-matt (P.S: Recursion (0) re.curs.ion Definition: termination)
Admin
That won work in ASP. Try: del c:\
Admin
We can only dream... ;o)
Admin
The best math teacher I had was Aunt Mom.
Admin
Early people COUNTED from zero to twenty (hands plus feet) and then switched over to calculations, twenty-one, twenty-two, one-hundred-and-... etc.
Computers only count from 0 to 1 and then do calculations for everything else, two-times-one and four-times-one, etc. Therefore Zero,One,Many is indeed the best choice as it is the most natural way for computers to deal with any number.
Admin
http://en.wikipedia.org/wiki/Pirah%C3%A3_people
The Piraha, perchance?
Admin
What's the difference? All you've done is recurse explicitly rather than implicitly.
Admin
Why not? The max path length on a windows system is 32K, and is smaller on Linux. You're not going to overflow the stack with that as your input. Especially since the string contents don't actually go onto the stack.
Admin
A few things to ponder:
I am 35 years old with children. I make $90K a year. How much money do I insure myself for in case the unthinkable happens and I need to replace what I would have earned?
My cell phone uses a frequency of ~2.4 billion cycles per second. How does the manufacturer verify the correct frequency? How did the engineers design it?
How many miles (kilometers for you international types) do I drive in a 10 year period? In a lifetime?
Only liberal arts majors would think that 1 million is a large number. If you find visualizing large numbers hard, I would suggest learning about logarithms.
Admin
Now where do I go to find this job? I'd love to find a development job that doesn't involve me living in or near a city. Heck, I think it's even safe to say I could be your new best coder :-)
Admin
This bottled my mind
Admin
And if Microsoft markets Windows 2010 with a "no limits file system" you are screwed. The title of this WTF is "Should be enough" that is a WTF, please consider.
Admin
I know what you're trying to allude to, but just as an annoying tidbit of information, I believe the maximum path length on Windows is 260 characters... so with one character directory names and the backslash character, you're gonna be stuck well before 130 levels.
Admin
+1, Subtle
Admin
This depends on a lot of information that I don't have, but a reasonable estimation is $900,000.
Neither owning, using, manufacturing, nor testing that phone required possessing one million of anything.
The average driver drives ~1,000 miles a month, 12,000 per year, and with 50 years of driving would reach ~600,000 total miles driven. An OTR truck driver would clear nearly 200,000 miles per year legally.
While you make a persuasive argument, this still doesn't translate to the average person understanding what a million is. I can use math to figure out that my upstairs bathroom has a volume of ~360 cubic feet, minus toilet, vanity, bathtub, and through the theory of sphere packing I can determine that one million marbles will occupy about 77 cubic feet, making them fit comfortably inside the bathroom. Until I actually do that, though, I still don't know what a million marbles looks like, and I would bet that no more than 100 people in the world have ever seen it.
Admin
This is shattering my image of The Daily WTF being professionals mocking the incompetent. If you write broken code and analyze the OS to see if you can get away with it you are annoying.
Admin
As for your hypothetical no-limits-file system, if it really included paths larger than RAM size: All system functions that return paths or take them as parameters would fail, so you'd need a major interface changes. So while I'm all for avoiding arbitrary limits, planning in advance for something hypothetical like this would be going too far ...
Admin
Admin
A programmer either understands recursion or not. This applies to every other programmer, too.
Admin
Admin
I'd be interested in learning a sorting algorithm as good as QuickSort that does not use recursion.
Admin
$MFT?
http://www.pcguide.com/ref/hdd/file/ntfs/archMFT-c.html
Admin
Obviously, you'd store the directory path in a file on the disk, and pass the path to that file around.
Oh, wait...
Admin
This code does not perform a directory tree deletion. It only deletes plain files from within the tree.
Admin
Admin
I can see what you're getting at, but I'm not sure I agree exactly. We still don't really use large numbers: we almost always use units that are themselves divisible into smaller units. Whether you're talking of 1 million pounds - which to most people is one of a unit called 'a million pounds' - or ten kilometres - which is really ten lots of a thousand metres, each thousand being lumped together into a 'kilometre'.
When we do use specific large numbers, we have to count them indirectly - simply because it's impractical to count that high. Generally, though, things that are sold in numbers too high to practically count are worth little enough relative to the transaction that we can estimate the number some other way - by weighing, for example.
For what it's worth, I have seen a million of something (enumerated), although I didn't count them. Anyone who's seen a palletload of anything small will have done - screws, sweets, sheets of paper, for example.
Admin
Take a look at InsertionSort... oh, you meant to say "as fast as" instead of "as good as" :)
Admin
Admin
Admin
chdir(folderNodeID). idParent = folderParentNdodeID(folderNodeID) etc.
My hypothetical no limit file system is not far fetched (change node IDs to 128 bit if you want), only with your implementation would it be impractical.
Remember the title of this is "Should be enough". I think I'm winning this debate.
Admin
Moral: Don't forget the base case or you'll never get to hear the punchline.
Admin
All you'd be doing is to memoize full path names on the way until you get to a point where there are no more directories (ignoring Unix conventions for the sake of simplicity). Delete all the files, pop the stack, and continue.
As always, iteration and recursion are equivalent (as you well know). The benefit in this case is that, given a procedural language, it's easier to explain the iterative approach -- and, I would argue, more likely to produce a bug-free result. (Some of the suggestions above are not bug free.) Given a functional language: yes, I'd agree with you.
Mind you, my first thought was definitely "surely there's a library function to do this?"
Admin
This would not be a multi-billion dollar furniture company headquartered in western Wisconsin, by any chance, would it? Because it sure sounds like the place I used to work ...
Admin
Admin
... Because, if it is, I was the other guy crazy enough to move there in the last 10 years from a large city (Milwaukee).
And the people who did not work at Company A, worked at the chicken rendering plant up the street.
Admin
Volume:if each one is around 1cm³, then a bit over 1m³ (but there'd be empty space, which would increase it a bit; I've not properly taken that into account).
As for buying and re-selling, well, what quantities would you be selling them in? 10? 25? 100? That's at least 10,000 units, and you'd want reasonable markup (and I'd expect a pack of 100 to cost a bit less than 10 packs of 10).
Call that $50k after the tax man gets his share. Let's also say that prices are doubled over the next 30 years (naïve calculation; $75k/year). That's $2¼M, a.k.a. windfall there for the spending. Typically? I wouldn't like to say, but there's no reason that I can see why a long-distance driver couldn't do a million miles in 10 years. If a logarithm falls in a forest…Admin
Admin
Admin
Or were you just using that as a launching pad for demonstrating your big smarts about unwinding recursion with a stack, like all the other stack > recursion commenters? Sorry, of course I meant by crafting a stack.
0_o
See, this is what worries me about developers arrogant enough to make unfounded claims about such things as "the newer generations", without considering the shoulders they themselves stood on.
Or do you still code with a magnetized needle and a steady hand?
Oh, crap, I've been had!XD
Admin
I am sorry :)
Admin
Ok google "INode file system structure" "or INode pointers". I'm not confirming your point as there is no major interface changes. The operating system stores INode numbers and INode pointers for traversing directory structures. This is how unix, linux, ntfs layout directory structures. It's how all your command line programs traverse directories, it's how the kernel traverses directories. So where is the major interface change? And you tried to pose a rhetorical question but instead asked a question with a definite answer. The operating system stores the current path as a single number. Don't try and get into technical arguments if you don't know what your talking about it makes you look silly.
Admin
Not everybody knows recursion
Admin
fjf as this is turning into a programming less for you.
I wonder if this:
string FolderName = fileSystem.getFolderNameByID(NodeID);
ever occurred to you?
The operating system stores your entire file system as linked nodes. The fact they have a textual name associated with them does not in anyway mean that the operating system is using the textual representation. No changes needed to access files by a node ID. You are plain wrong.
Admin
Admin
The first thing you should know about recursion is that it involves recursion.
Admin
fjf I'm finished with this but you are correct 2^128 is an arbitrary limit. My bad. It's higher than the number of atoms in the solar system but I'll still accept your point. But I did mention Microsoft marketing...
Admin
I ran out of things to mark my page with. This is obviously a fault with the instructions. I quit.
Admin
[quote user="greg barton"][quote user="fjf"]By confirming my points? Well, if you think so ...[/quote]
Ok google "INode file system structure" "or INode pointers". I'm not confirming your point as there is no major interface changes. The operating system stores INode numbers and INode pointers for traversing directory structures. This is how unix, linux, ntfs layout directory structures. It's how all your command line programs traverse directories, it's how the kernel traverses directories. So where is the major interface change?[/quote] In the part of my reply that you cut away:
chdir (const char *) -> chdir (some_integer_type)
Not major enough?
Same for open(), opendir(), stat() and many others (and whatever their Windows equivalents are).
Again, I'm talking about interfaces, not internal storage (which may be the lesser problem, though there are probably also a number of places where the full path is stored, such as the current directory). BTW, I know that in some cases there are alternative interfaces available, such as fchdir(), but my point is that most existing programs do use interfaces that pass path names and store path names in memory. They would all have to be changed massively to allow for path names larger than RAM size (more precisely, addressable virtual memory size).[/quote]
[quote user="greg barton"]Don't try and get into technical arguments if you don't know what your talking about it makes you look silly.[/quote] I'm trying to resist commenting on your apparent inability to distinguish between interface and internal storage, but can we calm down a little? As I said, I'm all with you about avoiding artifical limits, but I think you're focussing on a side-issue here. If you're serious about that, first write your own OS with no interfaces that expose path names in memory, including system library and utilities that make use of them, then we can talk about the merits of non-recursive directory traversals in those programs ...
Admin
So far the last time, hopefully:
string FolderName = fileSystem.getFolderNameByID(NodeID);
This very line would not work if the name is larger than the RAM size, since strings are stored in RAM, so you would have to change every program that uses it. No, you don't have to change the internal representation of node numbers in the OS, but you have to change the interface of getFolderNameByID() (or at least provide an alternative that perhaps retrieves the name into a designated file or so) and make programs use those new interfaces.
Admin
A teacher at my school made a book containing a million "X"s, to help us to visualise how much is a million. It would have been something like 250 pages at 80 cols x 50 rows.