Graph
List

📚List

NEW

An ordered collection of elements that can be accessed by position and supports insertion and deletion.

DESCRIPTION

In computer science, a list is an abstract data type representing an ordered sequence of elements. Implementations include arrays (dynamic arrays) and linked lists, trading off random access versus insertion performance. Lists may allow duplicates and support operations like indexing, slicing, and iteration. High-level languages provide built-in list types with rich APIs. Lists underpin many algorithms and data modeling patterns.

ALTERNATIVE DEFINITIONS

Wikipedia

In computer science, a list or sequence is an abstract data type that represents a countable number of ordered values, where the same value may occur more than once.

Emphasizes ordered values and allowance for duplicates.

Source

Python Documentation

The list data type has some more methods. Here are all of the methods of list objects: append(), extend(), insert(), remove(), pop(), clear(), index(), count(), sort(), reverse().

Provides the standard operations available in Python’s list implementation.

Source

Oracle Java SE

The List interface provides a way to store ordered collections. Lists typically allow duplicate elements and provide positional access and search.

Highlights ordered collections and positional access within Java’s standard library.

Source

Linked List Sequence Stack Queue Dynamic Array Indexing Iteration Data Structure

COMPETING TERMS

Vector

RELATIONS

KNOWLEDGE AREAS

Software Engineering Programming Languages

TARGET AUDIENCE

Software Developer Full Stack Developer Data Engineer

EXTERNAL SOURCES

  • Wikipedia - List (abstract data type)
  • Python - Python list operations and methods
  • Oracle - Java List interface reference
  • Wikipedia - Abstract data type overview

TOP QUESTIONS

When should I use a List instead of an Array?

Use lists when you need dynamic resizing or convenient insertion/deletion. Arrays are preferable for fixed-size, high-performance random access.

Category: Opinion

Can a List contain duplicates?

Yes, by definition lists allow the same value to occur more than once.

Category: Definition

What is the complexity of inserting in a List?

In a linked list, insertion can be O(1) at known positions; dynamic arrays are amortized O(1) at the end but O(n) in the middle.

Category: Tutorial

What operations do common List implementations support?

Indexing, iteration, insertion, deletion, sorting, slicing, and searching are typical.

Category: Definition

How does a List differ from a Set?

Lists are ordered and allow duplicates; sets are unordered and enforce uniqueness.

Category: Misunderstanding

What risks come with large Lists?

Memory overhead and fragmentation for linked lists; costly reallocation and shifts for dynamic arrays on inserts.

Category: Risks

How do language APIs influence List usage?

Languages offer specific methods and performance characteristics; choose implementations aligned to your workload.

Category: Management

What are alternatives to Lists for ordered data?

Deques, arrays, and balanced trees can serve ordered collections with different trade-offs.

Category: Alternatives

Is a List the same as a Vector?

Not necessarily; vector commonly refers to dynamic arrays in C++ or mathematical vectors in linear algebra.

Category: Misunderstanding