Files
leetcode/apps/docs/public/hash-table-operations.svg
T

49 lines
3.5 KiB
XML

<svg viewBox="0 0 650 280" xmlns="http://www.w3.org/2000/svg">
<rect width="650" height="280" fill="#f8f9fa" rx="10"/>
<!-- Title -->
<text x="325" y="30" font-family="Arial, sans-serif" font-size="18" font-weight="bold" text-anchor="middle" fill="#2c3e50">Hash Table: Three Core Operations (All O(1))</text>
<!-- Insert -->
<rect x="50" y="60" width="180" height="180" fill="#ffffff" stroke="#27ae60" stroke-width="3" rx="8"/>
<text x="140" y="85" font-family="Arial, sans-serif" font-size="15" font-weight="bold" text-anchor="middle" fill="#27ae60">INSERT</text>
<text x="140" y="115" font-family="monospace" font-size="13" text-anchor="middle" fill="#2c3e50">map["Alice"] = </text>
<text x="140" y="135" font-family="monospace" font-size="13" text-anchor="middle" fill="#2c3e50">"555-1234"</text>
<text x="140" y="170" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#7f8c8d">1. Hash "Alice"</text>
<text x="140" y="188" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#7f8c8d">2. Compute index</text>
<text x="140" y="206" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#7f8c8d">3. Store at index</text>
<text x="140" y="230" font-family="Arial, sans-serif" font-size="13" font-weight="bold" text-anchor="middle" fill="#27ae60">O(1)</text>
<!-- Lookup -->
<rect x="240" y="60" width="180" height="180" fill="#ffffff" stroke="#3498db" stroke-width="3" rx="8"/>
<text x="330" y="85" font-family="Arial, sans-serif" font-size="15" font-weight="bold" text-anchor="middle" fill="#3498db">LOOKUP</text>
<text x="330" y="115" font-family="monospace" font-size="13" text-anchor="middle" fill="#2c3e50">value = </text>
<text x="330" y="135" font-family="monospace" font-size="13" text-anchor="middle" fill="#2c3e50">map["Alice"]</text>
<text x="330" y="170" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#7f8c8d">1. Hash "Alice"</text>
<text x="330" y="188" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#7f8c8d">2. Compute index</text>
<text x="330" y="206" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#7f8c8d">3. Read from index</text>
<text x="330" y="230" font-family="Arial, sans-serif" font-size="13" font-weight="bold" text-anchor="middle" fill="#3498db">O(1)</text>
<!-- Delete -->
<rect x="430" y="60" width="180" height="180" fill="#ffffff" stroke="#e74c3c" stroke-width="3" rx="8"/>
<text x="520" y="85" font-family="Arial, sans-serif" font-size="15" font-weight="bold" text-anchor="middle" fill="#e74c3c">DELETE</text>
<text x="520" y="115" font-family="monospace" font-size="13" text-anchor="middle" fill="#2c3e50">delete</text>
<text x="520" y="135" font-family="monospace" font-size="13" text-anchor="middle" fill="#2c3e50">map["Alice"]</text>
<text x="520" y="170" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#7f8c8d">1. Hash "Alice"</text>
<text x="520" y="188" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#7f8c8d">2. Compute index</text>
<text x="520" y="206" font-family="Arial, sans-serif" font-size="11" text-anchor="middle" fill="#7f8c8d">3. Remove from index</text>
<text x="520" y="230" font-family="Arial, sans-serif" font-size="13" font-weight="bold" text-anchor="middle" fill="#e74c3c">O(1)</text>
<!-- Bottom note -->
<text x="325" y="265" font-family="Arial, sans-serif" font-size="13" text-anchor="middle" fill="#7f8c8d">All operations complete in constant time (on average)</text>
</svg>