Editing Talk:2483: Linked List Interview Problem

Jump to: navigation, search
Ambox notice.png Please sign your posts with ~~~~

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 4: Line 4:
 
This code won't mail the linked list to a museum - it will mail the memory location of the head of the list to a museum.{{unsigned ip|172.70.130.192}}
 
This code won't mail the linked list to a museum - it will mail the memory location of the head of the list to a museum.{{unsigned ip|172.70.130.192}}
 
:I think part of the joke might be that the high-level language being used will actually spit out a representation of the entire list when using the str function. So it actually does all the traversing and abstracts it away, again making the interview question seem redundant! [[Special:Contributions/162.158.159.48|162.158.159.48]] 10:40, 1 July 2021 (UTC)
 
:I think part of the joke might be that the high-level language being used will actually spit out a representation of the entire list when using the str function. So it actually does all the traversing and abstracts it away, again making the interview question seem redundant! [[Special:Contributions/162.158.159.48|162.158.159.48]] 10:40, 1 July 2021 (UTC)
::The language looks almost like Python -- the only difference being the keyword ''define'' instead of ''def''. Lisp is the only family of languages I can think of that automatically converts linked lists to a representation of all the elements, since the linked list is its fundamental data structure. [[User:Barmar|Barmar]] ([[User talk:Barmar|talk]]) 14:06, 1 July 2021 (UTC)
 
:::Haskell too: `headElem:tailList` is cons, https://wiki.haskell.org/How_to_work_on_lists#Notes_about_speed says "Haskell lists are ordinary single-linked lists." [[User:Solomon|Solomon]] ([[User talk:Solomon|talk]]) 01:34, 1 December 2022 (UTC)
 
  
 
just to make sure I get this right.
 
just to make sure I get this right.
Line 22: Line 20:
 
Does anyone know when the last comic was that used colors? Is this something worth mentioning? --[[Special:Contributions/162.158.88.42|162.158.88.42]] 06:11, 1 July 2021 (UTC)
 
Does anyone know when the last comic was that used colors? Is this something worth mentioning? --[[Special:Contributions/162.158.88.42|162.158.88.42]] 06:11, 1 July 2021 (UTC)
  
: I found the category: [[:Category:Comics with color]]. --[[Special:Contributions/162.158.93.153|162.158.93.153]] 06:17, 1 July 2021 (UTC)
+
: I found the category: [[Category:Comics with color]]. --[[Special:Contributions/162.158.93.153|162.158.93.153]] 06:17, 1 July 2021 (UTC)
  
 
I added some words regarding the title text.  Feel free to expand/clarify/correct as necessary. [[Special:Contributions/172.69.35.209|172.69.35.209]] 06:57, 1 July 2021 (UTC)
 
I added some words regarding the title text.  Feel free to expand/clarify/correct as necessary. [[Special:Contributions/172.69.35.209|172.69.35.209]] 06:57, 1 July 2021 (UTC)
Line 32: Line 30:
  
 
Those wondering why linked lists are considered obsolete: insertion and deletion performance is rarely the issue these days. It's the cost of enumerating over all elements in the list. Both arrays and linked lists have O(n) complexity there, but arrays have the lower cost. And that's before we get into stuff like caches liking predictable access patterns (pointer chasing is not predictable) and all those pointers costing precious cache memory space.--[[User:Henke37|Henke37]] ([[User talk:Henke37|talk]]) 09:45, 1 July 2021 (UTC)
 
Those wondering why linked lists are considered obsolete: insertion and deletion performance is rarely the issue these days. It's the cost of enumerating over all elements in the list. Both arrays and linked lists have O(n) complexity there, but arrays have the lower cost. And that's before we get into stuff like caches liking predictable access patterns (pointer chasing is not predictable) and all those pointers costing precious cache memory space.--[[User:Henke37|Henke37]] ([[User talk:Henke37|talk]]) 09:45, 1 July 2021 (UTC)
:If the elements are simpler and relatively constant in individual storage demands (regardless of total numbers to store), arrays and bulk-caching work well. If they're more convoluted records (e.g. up to 64 characters as element name, 256 characters for a description, version 'number' that's another string, a notes field that is a pointer to an arbitrary chain of formatted/markupped punctuated character-storing freetext variable slots, any number of other object properties you find useful) then most of the advantages of indexable layout for lookahead loading are lost. If you're writing at significantly low-level of code, already, then you could still possibly see an advantage to implementing linked-list structures and not lose out enough to the advantages you'd get for an array implementation.
 
:Though these days you're not encouraged to tunnel past the abstractions the higher-level compiler/interpreter will present to you. You could be hard pressed to do anything efficient yourself (like an array-of-pointers approach, or using XOR packing to cut down on memory requirements in a doubly-linked list) and must blindly trust that the original authors of the intermediate builder gave it the wisdom to not be too bad trying to match what you input to a suitably workable pre-anticipated family of data-series methodologies by the time it gets to runtime.
 
:And there's so much power in a modern computer core that, even with a resource-hogging OS, you're probably not going to break it by manually forcing the worst option, unless you're already in danger of stressing the system even with the truly best one. [[Special:Contributions/141.101.99.93|141.101.99.93]] 23:44, 1 July 2021 (UTC)
 
Anyone else think the chosen color might be relevant? We're talking about **link**ed lists and the text is written in blue, the traditional color of hyper**link**s. In any other comic, I might think it a coincidence, but this is a comic that rarely uses color, and never without a purpose. [[User:Trlkly|Trlkly]] ([[User talk:Trlkly|talk]]) 07:15, 3 July 2021 (UTC)
 
:Blue whiteboard pens are probably the more used 'not black' (because easier on the eye?) but not specifically hued (red for important/'do not do' information, green for softer suggestions or else with comparative 'do do' positive stuff). From personal experience. Not sure if this is relevent, maybe it's just that blue-on-white is what Randall overwhelmingly experiences when he casually wanders in to NASA, JPL, Cern, NIF, Alphabet Inc, Apple Park, Redmond Campus, etc, and looks for casual inspiration on their various walls. [[Special:Contributions/141.101.98.206|141.101.98.206]] 18:33, 3 July 2021 (UTC)
 
 
I think you're all missing the point of the joke: it's not the ''linked list'' itself but the ''interview question about linked lists'' that should be donated to the museum. A typical interview question is "how do you reverse a linked list?", with the interviewer expecting you to write down the algorithm where you walk down the list while creating a new linked list in the process, wiring up its "next" pointer to the previously visited element. For the first element you traverse, you set the "next" pointer of that element in the reversed list to nil, because it will be the last element in the reversed list. The final result is a pointer to the last visited element, which becomes the head of the reversed list. These kind of questions are stereotypical for programmer interviews (just like "how do you swap to numbers without using a temporary variable?") and therefore Cueball makes a snarky remark that this question is now so archaic that it should be in a historical museum of sorts.[[Special:Contributions/162.158.88.88|162.158.88.88]] 14:22, 5 July 2021 (UTC)
 
:The text below the comment ("... donate their linked list ...") suggests the reading others have taken...
 

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)

Template used on this page: