Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Trie] Fix trie contains function for empty string #954

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lexorus
Copy link

@lexorus lexorus commented Oct 8, 2020

Checklist

Description

Currently Trie().contains(word: "", matchPrefix: true)) will return false, which is wrong since the root node of a Trie is considered an empty string. This PR fixes this bug. More information can be found here or by checking implementations of Trie data structure in other languages.
There is actually already a test written for this, which is failing at the moment. So this PR also makes tests for Trie data structure to pass.

What has been done

  1. Fix contains function to return true for empty string
  2. Update Trie project to Swift 5. No code changes were required.
  3. Removed useless UI tests.

How to test

Open Trie.xcodeproj and make sure project builds and tests are passing.

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.

None yet

1 participant