# Are These Two Friends? Adjacency Lists and Grids

Answer "are these two already friends?" in one step without running out of memory, before every Add friend button: why reading a friend list and a box for every pair both fall short at a million people, and how to choose between an adjacency list, a set per person and an adjacency matrix.

![Cheat sheet: Are These Two Friends? Adjacency Lists and Grids](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/b2027639c0d249929d55540270f002d1.webp)

- Category: Data Structures
- Level: Journeyman
- Tags: Adjacency List, Adjacency Matrix, data structures, Edge, Graph, Vertex
- Updated: November 3, 2026

Source: https://www.ask-codey.com/cheat-sheets/ds-graph-representations-cheat-sheet
