Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Hello guys! I noticed that Guttag uses lists in many cases where - seemingly - tuples would work as well. When I write code I'm trying to avoid mutable data objects whenever it's possible but I was just wondering if there's any particular reason why lists may be preferable in general? (Maybe something about memory requirements? )

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at in under 10 minutes. Go to now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer


To see the expert answer you'll need to create a free account at Brainly

lists in general are more easier to work and can easily refer to an element, pop out a element from list , add elements , overwrite elements(replace with new ones) etc. certainly all these features are not available in tuples and lists have an advantage where we need to constantly modify the stored data be it add elements or refer to them. as regarding memory requirements someone else may better answer it
tuples have a memory advantage I think
lists are dynamically sized, tuples are not

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

It seems like a tuple would be an array(n-tuple)? I've heard the term in discrete and calc and such. From above it says tuples cannot modify the data within(stacks,queues,etc) but Arrays can... Arrays aren't a list I don't believe.
A list takes up more bytes than a tuple, and a tuple is immutable. That would seem to argue for using tuples unless you need to be able to append or assign values to elements. I find lists easier to work with.
not sure why prof. Guttag uses list over tuples but the following link gives some info about their differences and uses. hope it helps
Lists vs Tuples is very much about what you need them for, If you want a variable that you do not want to accidentally change use a tuple for constants, (For style, constants variable names are written in uppercase i.e. EARTH_RADIUS = 6 378.1) If you want to change / add to / remove from you need mutability, a list would be better.

Not the answer you are looking for?

Search for more explanations.

Ask your own question