Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Lru cache#45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Akshayy67 wants to merge2 commits intoalgorithm-visualizer:master
base:master
Choose a base branch
Loading
fromAkshayy67:lru-cache-1

Conversation

Akshayy67
Copy link

No description provided.

@Akshayy67
Copy link
Author

Summary

This PR adds a visualization for the LRU (Least Recently Used) Cache data structure.

What is LRU Cache?

A cache that stores a limited number of items and automatically evicts the least recently used item when capacity is exceeded. It's widely used in operating systems, databases, and web applications.

Implementation Details

  • Data Structure: Circular doubly-linked list + HashMap
  • Time Complexity: O(1) for both GET and PUT operations
  • Space Complexity: O(capacity)
  • Language: JavaScript

Visualization Features

  • Shows cache state after each operation (most recent → least recent)
  • Logs all operations with clear descriptions
  • Highlights the most recently used item
  • Demonstrates eviction behavior when capacity is exceeded
  • Includes comprehensive demonstration with multiple scenarios

Testing

Tested on Scratch Paper - All operations work correctly with no errors
✅ Code runs without any console errors
✅ Visualization displays properly
✅ All operations are logged correctly

Category

Uncategorized

Files Added

  • Uncategorized/LRU Cache/code.js - Implementation with visualization
  • Uncategorized/LRU Cache/README.md - Comprehensive documentation

Real-World Applications

  • Operating Systems (page replacement)
  • Web Browsers (cache management)
  • Databases (query caching)
  • CDNs (content delivery)
  • APIs (response caching)

1 similar comment
@Akshayy67
Copy link
Author

Summary

This PR adds a visualization for the LRU (Least Recently Used) Cache data structure.

What is LRU Cache?

A cache that stores a limited number of items and automatically evicts the least recently used item when capacity is exceeded. It's widely used in operating systems, databases, and web applications.

Implementation Details

  • Data Structure: Circular doubly-linked list + HashMap
  • Time Complexity: O(1) for both GET and PUT operations
  • Space Complexity: O(capacity)
  • Language: JavaScript

Visualization Features

  • Shows cache state after each operation (most recent → least recent)
  • Logs all operations with clear descriptions
  • Highlights the most recently used item
  • Demonstrates eviction behavior when capacity is exceeded
  • Includes comprehensive demonstration with multiple scenarios

Testing

Tested on Scratch Paper - All operations work correctly with no errors
✅ Code runs without any console errors
✅ Visualization displays properly
✅ All operations are logged correctly

Category

Uncategorized

Files Added

  • Uncategorized/LRU Cache/code.js - Implementation with visualization
  • Uncategorized/LRU Cache/README.md - Comprehensive documentation

Real-World Applications

  • Operating Systems (page replacement)
  • Web Browsers (cache management)
  • Databases (query caching)
  • CDNs (content delivery)
  • APIs (response caching)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@Akshayy67

[8]ページ先頭

©2009-2025 Movatter.jp