Skip to content

s30 design-2 completed - hashmap and queue from stacks#2486

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

s30 design-2 completed - hashmap and queue from stacks#2486
prenastro wants to merge 1 commit into
super30admin:masterfrom
prenastro:master

Conversation

@prenastro

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Implement Queue using Stacks (queue_from_stack.py)

Strengths:

  • Clean, well-organized code that closely follows the optimal approach
  • Correct implementation of the two-stack queue pattern
  • Good variable naming conventions
  • Proper handling of edge cases

Areas for Improvement:

  • The time complexity analysis in comments is incomplete. While operations appear O(1), you should note that pop() and peek() have O(n) worst-case complexity when the output stack is empty and transfer is needed. The amortized complexity is O(1), but individual operations can be expensive.
  • Consider adding a brief comment explaining why the transfer works (reversing stack order to simulate queue FIFO)

VERDICT: PASS


Design HashMap (.idea/Design-2.iml)

Unfortunately, there is no code to evaluate. The submitted file is an IDE configuration file, not a solution to the HashMap problem. To improve, the student should:

  1. Submit actual Java/Python code implementing the MyHashMap class
  2. Follow the problem requirements: implement put(), get(), and remove() methods
  3. Use appropriate data structures (array of linked lists or similar for chaining)
  4. Ensure the implementation handles key updates and returns -1 for non-existent keys

The reference solution demonstrates a proper approach using:

  • An array of buckets (Node objects)
  • Separate chaining with linked lists for collision handling
  • Helper methods for hashing and finding previous nodes

FEEDBACK:
No code was submitted. The student needs to provide an actual implementation of the MyHashMap class with put(), get(), and remove() methods. Please review the problem description and reference solution, then submit working code.

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