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

Implemented Trie Data Structure #162

Merged

Conversation

Ramy-Badr-Ahmed
Copy link
Contributor

@Ramy-Badr-Ahmed Ramy-Badr-Ahmed commented Sep 14, 2024

Contents:

  • TrieNode Class: Represents individual nodes with children and isEndOfWord attributes and core methods:

    addChild: Adds a child node for the given character and returns the child node.
    getChild: Retrieves the child node for the given character, or null if no such child exists.
    hasChild: Checks if a child node for the given character exists.

  • Trie Class: Implements core methods:

    insert: Inserts a word into the Trie.
    search: Searches for a word in the Trie.
    startsWith: Finds words starting with a given prefix.
    delete: Deletes a word from the Trie and recursively removes nodes associated with a word.
    getWords(): Retrieves all words in the Trie.
    traverseTrieNode: Recursively collect all words starting from a given node.

  • Unit Tests: TrieTest.php includes PHPUnit tests to validate the correct behavior of insertion, search, deletion, and retrieval functions.

GitHub Actions

All tests and workflows (in my forked repository) have passed.

Code style

directory_md

PHP Composer

Copy link
Contributor Author

@Ramy-Badr-Ahmed Ramy-Badr-Ahmed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @darwinz
Looking forward to your review 🙂

Copy link
Contributor

@darwinz darwinz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thank you for contributing!

@darwinz darwinz merged commit 42badbf into TheAlgorithms:master Sep 18, 2024
2 checks passed
Ramy-Badr-Ahmed added a commit to Ramy-Badr-Ahmed/PHP-DSA that referenced this pull request Sep 28, 2024
Ramy-Badr-Ahmed added a commit to Ramy-Badr-Ahmed/PHP-DSA that referenced this pull request Sep 28, 2024
darwinz added a commit that referenced this pull request Oct 1, 2024
* Added Disjoint Sets Data structure

* Moved DisjointSetTest.php to  tests/DataStructures

* Update DataStructures/DisjointSets/DisjointSet.php

Co-authored-by: Brandon Johnson <[email protected]>

* Update DataStructures/DisjointSets/DisjointSetNode.php

Co-authored-by: Brandon Johnson <[email protected]>

* Update DataStructures/DisjointSets/DisjointSetNode.php

Co-authored-by: Brandon Johnson <[email protected]>

* Update tests/DataStructures/DisjointSetTest.php

Co-authored-by: Brandon Johnson <[email protected]>

* Update tests/DataStructures/DisjointSetTest.php

Co-authored-by: Brandon Johnson <[email protected]>

* Update tests/DataStructures/DisjointSetTest.php

Co-authored-by: Brandon Johnson <[email protected]>

* Considered PHPCS remarks. Unit Testing is now working.

* Remove data type mixed. Considered annotations for php7.4.

* Remove data type mixed. Considered annotations for php7.4.

* updating DIRECTORY.md

* Implemented Trie DataStructure

* Added Trie to DIRECTORY.md

* updating DIRECTORY.md

* Implemented AVLTree DataStructure

* updating DIRECTORY.md

* Implemented AVLTree DataStructure

* Implemented SegmentTreeNode.php

* Implementing SegmentTree

* Implementing SegmentTree with updateTree

* Implementing SegmentTree with rangeUpdateTree

* Implementing SegmentTree with query and queryTree

* Added serializing and deserializing of the SegmentTree

* Adding unit tests SegmentTree implementation

* Added unit tests for SegmentTree updates and range updates

* considering PHPCS for Added unit tests for SegmentTree updates and range updates

* Added unit tests for SegmentTree serialization/deserialization and array updates reflections

* Added unit tests for SegmentTree  Edge Cases

* Added unit tests for SegmentTree Exceptions (OutOfBoundsException, InvalidArgumentException)

* Added SegmentTree to DIRECTORY.md

* Implemented Segment Tree Data Structure

* Added some comments to my files in: #160, #162, #163, #166. Implemented Segment Tree Data Structure.

* Added some comments to my files in: #160, #162, #163, #166. Implemented Segment Tree Data Structure.

* Added comments time complexity for query(), update() and buildTree()

---------

Co-authored-by: Brandon Johnson <[email protected]>
Co-authored-by: Ramy-Badr-Ahmed <[email protected]>
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