Re: Array vs. Linked List Traversal

Liste des GroupesRevenir à c arch 
Sujet : Re: Array vs. Linked List Traversal
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.arch
Date : 01. Aug 2024, 21:14:48
Autres entêtes
Organisation : Stefan Ram
Message-ID : <arrays-20240801201407@ram.dialup.fu-berlin.de>
References : 1
jseigh <jseigh_es00@xemaps.com> wrote or quoted:
It's claimed that array traversal is faster than linked list
traversal.  What would be the reasons for that?

  Array traversal is hella faster than linked list traversal for a few
  key reasons:

  Cache Magic: Arrays stack elements right next to each other in
  memory, so when you hit one element, the CPU cache scoops up the
  neighbors too. It's like grabbing a whole burrito instead of just
  one bean at a time.

  Linked lists are all over the place, so you're constantly
  reaching for new bites.

  Pointer Drag: Linked lists are like following a treasure map -
  you got to read the clue, then go to the spot. Arrays? It's more
  like counting houses on Rodeo Drive - you know exactly where
  everything is.

  CPU Crystal Ball: Arrays are predictable, like traffic on the
  405 at rush hour. The CPU can see it coming. Linked lists are
  more like navigating Santa Monica on a holiday weekend - you
  never know what's around the corner.

  Speed Demon: Figuring out where to go next in an array is quick,
  like zipping down PCH. Linked lists are more stop-and-go, like
  cruising through Hollywood Boulevard.

  Bottom line, arrays crush it for traversal 'cause they're all
  about that efficient memory use, fewer pit stops, and a smooth
  ride the CPU can really groove with.

Date Sujet#  Auteur
1 Aug 24 * Array vs. Linked List Traversal7jseigh
1 Aug 24 +* Re: Array vs. Linked List Traversal2MitchAlsup1
2 Aug 24 i`- Re: Array vs. Linked List Traversal1Lawrence D'Oliveiro
1 Aug 24 +- Re: Array vs. Linked List Traversal1Anton Ertl
1 Aug 24 `* Re: Array vs. Linked List Traversal3Stefan Ram
1 Aug 24  +- Re: Array vs. Linked List Traversal1Chris M. Thomasson
2 Aug 24  `- Re: Array vs. Linked List Traversal1Stephen Fuld

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal