0% found this document useful (0 votes)
3 views3 pages

Data Structures Visual Guide

The document provides a visual guide to common data structures, including arrays, linked lists, stacks, queues, hash maps, sets, trees, graphs, tries, and heaps. Each data structure is briefly described along with its use cases and a JavaScript code example. This guide serves as a quick reference for understanding the characteristics and applications of various data structures.

Uploaded by

Deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Data Structures Visual Guide

The document provides a visual guide to common data structures, including arrays, linked lists, stacks, queues, hash maps, sets, trees, graphs, tries, and heaps. Each data structure is briefly described along with its use cases and a JavaScript code example. This guide serves as a quick reference for understanding the characteristics and applications of various data structures.

Uploaded by

Deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Common Data Structures - Visual Guide

1. Array

Ordered collection of elements. Fast access by index. Used for lists, grids, etc.

JavaScript:
let arr = [1, 2, 3];
console.log(arr[1]); // 2

2. Linked List

Nodes connected by pointers. Efficient insert/delete, slow access.

JavaScript:
class Node {
constructor(val) {
this.val = val;
this.next = null;
}
}

3. Stack

LIFO - Last In First Out. Used in undo operations, syntax parsing.

JavaScript:
let stack = [];
stack.push(10);
stack.pop();

4. Queue

FIFO - First In First Out. Used in BFS, task scheduling.

JavaScript:
let queue = [];
queue.push(10);
queue.shift();

5. HashMap

Key-value pair storage. Fast lookups.


Common Data Structures - Visual Guide

JavaScript:
let map = new Map();
map.set('a', 1);
console.log(map.get('a'));

6. Set

Stores unique values only.

JavaScript:
let set = new Set([1, 2, 3]);
set.add(2); // Duplicate ignored

7. Tree

Hierarchical structure. Used in DOM, folder systems.

JavaScript:
class TreeNode {
constructor(val) {
this.val = val;
this.left = null;
this.right = null;
}
}

8. Graph

Nodes connected by edges. Used in networks, pathfinding.

JavaScript:
const graph = {
A: ['B', 'C'],
B: ['D'],
C: ['E']
};

9. Trie

Prefix tree. Efficient for word search and autocomplete.


Common Data Structures - Visual Guide

JavaScript:
class TrieNode {
constructor() {
this.children = {};
this.isEnd = false;
}
}

10. Heap

Complete binary tree. Min/Max Priority Queue.

JavaScript: // Usually implemented with arrays and custom logic.

You might also like