{"id":18540143,"url":"https://github.com/ivan-magda/ifmo-b-tree","last_synced_at":"2025-11-01T04:30:28.042Z","repository":{"id":84189285,"uuid":"114691957","full_name":"ivan-magda/ifmo-b-tree","owner":"ivan-magda","description":"IFMO - Advanced Data Structures","archived":false,"fork":false,"pushed_at":"2017-12-25T14:00:21.000Z","size":5217,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-26T04:42:50.147Z","etag":null,"topics":["algorithms","b-tree","collections","data-structures","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivan-magda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-18T22:00:59.000Z","updated_at":"2017-12-22T09:41:57.000Z","dependencies_parsed_at":"2023-05-23T21:45:28.867Z","dependency_job_id":null,"html_url":"https://github.com/ivan-magda/ifmo-b-tree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivan-magda%2Fifmo-b-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivan-magda%2Fifmo-b-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivan-magda%2Fifmo-b-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivan-magda%2Fifmo-b-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivan-magda","download_url":"https://codeload.github.com/ivan-magda/ifmo-b-tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239256991,"owners_count":19608608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","b-tree","collections","data-structures","swift"],"created_at":"2024-11-06T19:53:07.460Z","updated_at":"2025-11-01T04:30:28.014Z","avatar_url":"https://github.com/ivan-magda.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# B-tree\nB-tree is a self-balancing tree data structure that keeps data sorted and allows searches, sequential access, insertions, and deletions in logarithmic time. The B-tree is a generalization of a binary search tree in that a node can have more than two children. Unlike self-balancing binary search trees, the B-tree is optimized for systems that read and write large blocks of data. B-trees are a good example of a data structure for external memory. It is commonly used in databases and filesystems.\n\n### The Code:\n- Searching:\n  - `value(for:)` method searches for the given key and if it's in the tree, it returns the value associated with it,\n  else it returns `nil`.\n- Insertion:\n  - The method `insert(_:for:)` does the insertion. After it has inserted a key, as the recursion goes up every node checks the number of keys in its child.\n  - if a node has too many keys, its parent calls the `split(child:atIndex:)` method on it.\n  - If the root has too many nodes after the insertion the tree calls the `splitRoot()` method.\n- Deletion:\n  - `remove(_:)` method removes the given key from the tree. After a key has been deleted,\nevery node checks the number of keys in its child. If a child has less nodes than the order of the tree, it calls the `fix(childWithTooFewKeys:atIndex:)` method.\n  - `fix(childWithTooFewKeys:atIndex:)` method decides which way to fix the child (by moving a key to it, or by merging it), then calls `move(keyAtIndex:to:from:at:)` or `merge(child:atIndex:to:)` method according to its choice.\n  \n### Benchmarks Results:\n- [Charts](./Resources)\n\n## Helpful Links:\n- [Wikipedia](https://en.wikipedia.org/wiki/B-tree)\n- [geeksforgeeks](https://www.geeksforgeeks.org/b-tree-set-1-introduction-2/)\n- [cs.cornell.edu](https://www.cs.cornell.edu/courses/cs3110/2009fa/recitations/rec25.html)\n\n## LICENSE\nThis project is open-sourced software licensed under the MIT License.\n\nSee the [LICENSE](./LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivan-magda%2Fifmo-b-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivan-magda%2Fifmo-b-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivan-magda%2Fifmo-b-tree/lists"}