Editing 1185: Ineffective Sorts

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 16: Line 16:
 
The third sort parodies a programmer explaining a {{w|quicksort}} during a job interview. The quicksort works by choosing an index as a pivot value and sorting all elements less than the pivot before the pivot and all the elements greater than the pivot after the pivot. It then does a quicksort to the section less than the pivot and the section greater than the pivot until the whole list is sorted. The interviewee flounders for a little while, then asks whether they can use the standard libraries to call a quicksort. The joke being, the standard library contains a quicksort, and the programmer would rather rely on that (possibly even pass it off as his own work) than his own example of quicksort. While it's commonly a good idea in real projects, this would surely count as a failure on interview.
 
The third sort parodies a programmer explaining a {{w|quicksort}} during a job interview. The quicksort works by choosing an index as a pivot value and sorting all elements less than the pivot before the pivot and all the elements greater than the pivot after the pivot. It then does a quicksort to the section less than the pivot and the section greater than the pivot until the whole list is sorted. The interviewee flounders for a little while, then asks whether they can use the standard libraries to call a quicksort. The joke being, the standard library contains a quicksort, and the programmer would rather rely on that (possibly even pass it off as his own work) than his own example of quicksort. While it's commonly a good idea in real projects, this would surely count as a failure on interview.
  
βˆ’
The final sort is just a mess. First it checks to see if the list is sorted, and exits if it is. Then it rotates the list by a random amount 10,000 times (as if cutting a deck of cards) and exits if the list is ever sorted. Next, in desperation, it checks if the list is sorted three times. Finally, realizing that they have no chance of success, the author performs the computer equivalent of a {{tvtropes|RageQuit|Rage Quit}} and attempts to destroy the computer rather than admit defeat. First, the program attempts to schedule a shutdown of the computer in five minutes, then attempts to delete the current directory, then attempts to delete the user's home directory (presumably the grader's files), and finally all the files on the computer. {{w|rm (Unix)|rm}} is a POSIX command; the -r and -f flags mean that the remove command will remove all contents of the specified directories and will not prompt the user beforehand. Under the guise of "{{w|Software portability|portability}}", the program runs the equivalent Windows {{w|rmdir|rd}} command with switches to delete all files from the "C:" drive without prompting. Finally, the program returns a list containing the numbers one through five in order.
+
The final sort is just a mess. First it checks to see if the list is sorted, and exits if it is. Then it rotates the list by a random amount 10,000 times (as if cutting a deck of cards) and exits if the list is ever sorted. Next, in desperation, it checks if the list is sorted three times. Finally, realizing that they have no chance of success, the author performs the computer equivalent of a {{tvtropes|RageQuit|Rage Quit}} and attempts to destroy the computer rather than admit defeat. First, the program attempts to schedule a shutdown of the computer in five seconds, then attempts to delete the current directory, then attempts to delete the user's home directory (presumably the grader's files), and finally all the files on the computer. {{w|rm (Unix)|rm}} is a POSIX command; the -r and -f flags mean that the remove command will remove all contents of the specified directories and will not prompt the user beforehand. Under the guise of "{{w|Software portability|portability}}", the program runs the equivalent Windows {{w|rmdir|rd}} command with switches to delete all files from the "C:" drive without prompting. Finally, the program returns a list containing the numbers one through five in order.
  
 
In the title text, {{w|StackOverflow}} ([https://stackoverflow.com/ link]) is a question-and-answer site where programmers can ask and answer questions on programming. The author of this code takes advantage of the hopes that someone on StackOverflow knows what they are doing and has posted code to sort a list... ''and somebody [https://github.com/gkoberger/stacksort/ implemented stacksort]; well, sort of.''
 
In the title text, {{w|StackOverflow}} ([https://stackoverflow.com/ link]) is a question-and-answer site where programmers can ask and answer questions on programming. The author of this code takes advantage of the hopes that someone on StackOverflow knows what they are doing and has posted code to sort a list... ''and somebody [https://github.com/gkoberger/stacksort/ implemented stacksort]; well, sort of.''

Please note that all contributions to explain xkcd may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see explain xkcd:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel | Editing help (opens in new window)