Which Data Structure Is Used in Adjacency List?


Angela Bailey

Which Data Structure Is Used in Adjacency List?

When it comes to representing graphs, one popular approach is using the adjacency list. This data structure efficiently captures the relationships between vertices and their neighbors. In this article, we will explore the data structures commonly used to implement an adjacency list and understand their advantages and disadvantages.

What is an Adjacency List?

An adjacency list is a way to represent a graph as a collection of linked lists or arrays. Each vertex in the graph is associated with a list of its neighboring vertices. This representation allows for efficient storage of sparse graphs, where the number of edges is much smaller than the number of possible connections.

Data Structures Used in Adjacency List

There are various data structures that can be used to implement an adjacency list. Let’s take a look at some commonly used ones:

Array of Linked Lists

In this approach, we use an array where each index represents a vertex in the graph. The value at each index is a linked list containing the neighboring vertices of that vertex.

This data structure offers flexibility in terms of adding or removing edges, as it allows for dynamic resizing of linked lists. However, searching for a specific edge can be less efficient compared to other data structures like hash tables or binary search trees.

Hash Table with Linked Lists

A hash table with linked lists combines the advantages of both hash tables and linked lists. In this approach, we use a hash table where each key represents a vertex, and the corresponding value is a linked list containing its neighboring vertices.

This data structure provides efficient lookup time for finding neighboring vertices based on their keys. It also allows for dynamic resizing and offers good performance for sparse graphs. However, it may consume more memory compared to other data structures.

Binary Search Trees

Using binary search trees to implement an adjacency list can provide efficient searching capabilities. Each vertex in the graph is represented as a node in the binary search tree, and the left and right child nodes represent its neighbors.

This data structure allows for fast searching of neighboring vertices using binary search algorithms. However, it may not be suitable for graphs with a large number of edges, as the tree’s height can increase significantly.

Choosing the Right Data Structure

The choice of data structure for implementing an adjacency list depends on various factors such as the size and density of the graph, the operations required (e.g., adding/removing edges, searching for specific edges), and memory constraints.

If you have a sparse graph with fewer edges, an array of linked lists or a hash table with linked lists can provide efficient storage and retrieval. On the other hand, if your graph is denser or requires faster searching capabilities, using binary search trees may be more suitable.


In summary, an adjacency list is a flexible and efficient way to represent graphs. The choice of data structure depends on factors such as graph density, required operations, and memory constraints. By understanding the advantages and disadvantages of different data structures like arrays of linked lists, hash tables with linked lists, and binary search trees, you can make an informed decision when implementing an adjacency list in your applications.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy