Skip to content

Update sample.java, implement Hashset code - #2698

Open
Siva512 wants to merge 1 commit into
super30admin:masterfrom
Siva512:master
Open

Update sample.java, implement Hashset code#2698
Siva512 wants to merge 1 commit into
super30admin:masterfrom
Siva512:master

Conversation

@Siva512

@Siva512 Siva512 commented Sep 6, 2026

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Design HashSet (Sample.java)

Strengths:

  • Correct implementation of separate chaining technique
  • Good use of comments explaining the approach
  • Proper handling of the remove method by casting to Integer to avoid removing by index
  • Clean, readable code structure

Areas for Improvement:

  1. Bucket Size: Consider using a prime number for SIZE (e.g., 769 or 1009) to reduce collisions and improve hash distribution
  2. Lazy Initialization: Instead of pre-allocating all 420 LinkedLists, consider lazy initialization - only create a LinkedList when a key is first added to that bucket. This saves significant memory.
  3. Worst-case Performance: The current approach has O(n) worst-case time complexity. Consider the double hashing approach used in the reference solution for guaranteed O(1) operations.
  4. Load Factor: Consider implementing dynamic resizing when the load factor exceeds a threshold (e.g., 0.75) to maintain performance.

VERDICT: PASS


Min Stack

VERDICT_REASON: [Brief reason for verdict]

ESTIMATED_GRADE: [A/B/C/D/F]

ESTIMATED_GRADE_REASON: [Brief reason for estimated grade]

VERDICT: NEEDS_IMPROVEMENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants