Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Data structures

Name: sadfrog 2012-01-25 16:00

Is it bad using linked lists where i could possibly use arrays?
Having a dynamic data structure is nice in case i decide i need
to remove / add more elements later, but in this case it's unlikely.

What is "good practice" in this case?

Name: Anonymous 2012-01-25 16:08

are you asking if ~doubling the memory usage when it is not necessary is a bad thing? then yes.

Name: Anonymous 2012-01-25 16:15

It's not about "good practice", it's about whether you need constant time access to arbitrary elements or not, whether you need the most space efficient storage possible or not, whether you need to traverse the list in both directions or not ...

Name: Anonymous 2012-01-25 16:15

>2 yeah, well i guess i'll rewrite it later if it becomes an issue. =/

Name: Anonymous 2012-01-25 16:19

Do you care a lot about program speed?
YES: Use arrays
NO: Use linked lists

As for good practices, inserting avocado kernels into yo'ur anus is considered part of the best practices for developers.

Name: Anonymous 2012-01-25 16:47

>>5
Is that what developers mean when they talk about ``inserting the kernel module''?

Name: Anonymous 2012-01-25 17:10

Read a fucking data structures book. This is so easy to be asked on /prog/.

Name: Anonymous 2012-01-25 17:22

Use vectors

Name: Anonymous 2012-01-25 17:42

>>1
Array:
Constant time access
Quite rigid without significant data structure backing.
Doing appending and splitting is generally horrible no matter how one looks at it.
Optimal to mutable techniques.
Data structure optimization techniques use this.

Linked list:
Worse case O(N) time access from beginning to end (if you're always going from beginning to end your algorithms may need refactoring)
Inherently flexible.
Doing appending and splitting is inherently easy and efficient.
Quite friendly to immutable techniques.
Data structure abstraction techniques use this, or its tree cousins.

Name: Anonymous 2012-01-25 17:43

>>5
That's not really correct you mental midget. Now shut up and go scrub another toilet.

Name: 9 2012-01-25 17:58

I should probably split up further linked lists into mutable and immutable linked lists:

Mutable:
Appending and splitting is most efficient.

Immutable:
Appending and splitting is "half-bad" AFAIK.

Name: Anonymous 2012-01-25 18:53

>>11
Immutable:
Sharing is possible.

Name: Anonymous 2012-01-25 18:56

>>12
Wearing your moms pantyhose:
Boner is possible.

Name: Anonymous 2012-01-26 0:50

GC is nice

Name: Anonymous 2012-01-26 5:55

nice is GC

Name: Anonymous 2012-01-26 6:40

>>7
you complain about programm discussion on prog!!!! would you prefer the japanimation threads!!!! at least this is on topic!!!!
>>14
garbagde collection!!!! ha ha ha!!!! only nesecerry when you code gabadge in first place!!!!!!!!!!!

Name: Anonymous 2012-01-26 17:29

>>16
ha ha ha!!!!!

Name: Anonymous 2012-01-26 20:59

sdgfgsg

Don't change these.
Name: Email:
Entire Thread Thread List