{"id":16724168,"url":"https://github.com/vimalk78/lca-rmq","last_synced_at":"2026-01-01T22:04:55.836Z","repository":{"id":151489408,"uuid":"135769620","full_name":"vimalk78/lca-rmq","owner":"vimalk78","description":"implementation of algorithm to find LCA with RMQ","archived":false,"fork":false,"pushed_at":"2018-06-04T08:28:21.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-22T04:41:23.196Z","etag":null,"topics":["algorithm","lca","rmq","trees"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vimalk78.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-06-01T22:44:45.000Z","updated_at":"2020-01-10T14:57:41.000Z","dependencies_parsed_at":"2023-09-28T07:17:40.580Z","dependency_job_id":null,"html_url":"https://github.com/vimalk78/lca-rmq","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"a580f659cea6f39256e0b8e6c552f5cb7ed90ee2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vimalk78%2Flca-rmq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vimalk78%2Flca-rmq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vimalk78%2Flca-rmq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vimalk78%2Flca-rmq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vimalk78","download_url":"https://codeload.github.com/vimalk78/lca-rmq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243746133,"owners_count":20341202,"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":["algorithm","lca","rmq","trees"],"created_at":"2024-10-12T22:44:12.326Z","updated_at":"2026-01-01T22:04:50.803Z","avatar_url":"https://github.com/vimalk78.png","language":"Java","readme":"\n## Algorithm for the Least Common Ancestor problem.\n\nThis implements LCA with \"Range Minimum Queries\" as described in the paper \"The LCA Problmem Revisited\".\n\nhttps://www.ics.uci.edu/~eppstein/261/BenFar-LCA-00.pdf\n\n**Completed** : Naive RMQ, Faster RMQ (using nlogn sparse table)\n\n**TODO** : Implement ±1 RMQ\n\n### Naive RMQ output : \n```\n(1(2(4..)(5..))(3(6..)(7..)))\nindexs :  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\nvalues : [1, 2, 4, 2, 5, 2, 1, 3, 6, 3, 7, 3, 1]\nlevels : [1, 2, 3, 2, 3, 2, 1, 2, 3, 2, 3, 2, 1]\n------ query distance --\u003e \n|\n|  starting index\nV\n   0,   0,   0,   0,   0,   0,   6,   6,   6,   6,   6,   6,  12,\n   1,   1,   3,   3,   5,   6,   6,   6,   6,   6,   6,  12,   0,\n   2,   3,   3,   5,   6,   6,   6,   6,   6,   6,  12,   0,   0,\n   3,   3,   5,   6,   6,   6,   6,   6,   6,  12,   0,   0,   0,\n   4,   5,   6,   6,   6,   6,   6,   6,  12,   0,   0,   0,   0,\n   5,   6,   6,   6,   6,   6,   6,  12,   0,   0,   0,   0,   0,\n   6,   6,   6,   6,   6,   6,  12,   0,   0,   0,   0,   0,   0,\n   7,   7,   9,   9,  11,  12,   0,   0,   0,   0,   0,   0,   0,\n   8,   9,   9,  11,  12,   0,   0,   0,   0,   0,   0,   0,   0,\n   9,   9,  11,  12,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n  10,  11,  12,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n  11,  12,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n  12,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n------------------------------\nLCA of 6 and 7 is 3. Expected : 3\nLCA of 4 and 7 is 1. Expected : 1\nLCA of 2 and 3 is 1. Expected : 1\nLCA of 2 and 2 is 2. Expected : 2\nLCA of 1 and 1 is 1. Expected : 1\n```\n### Faster RMQ (using sparse table) output :\n```\n(1(2(4..)(5..))(3(6..)(7..)))\nindexs :  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\nvalues : [1, 2, 4, 2, 5, 2, 1, 3, 6, 3, 7, 3, 1]\nlevels : [1, 2, 3, 2, 3, 2, 1, 2, 3, 2, 3, 2, 1]\n------ query distance as power of 2 --\u003e \n|\n|  starting index\nV\n   0,   0,   0,   0,   6,   0,   0,   0,   0,   0,   0,   0,   0,\n   1,   1,   1,   3,   6,   0,   0,   0,   0,   0,   0,   0,   0,\n   2,   2,   3,   5,   6,   0,   0,   0,   0,   0,   0,   0,   0,\n   3,   3,   3,   6,   6,   0,   0,   0,   0,   0,   0,   0,   0,\n   4,   4,   5,   6,   6,   0,   0,   0,   0,   0,   0,   0,   0,\n   5,   5,   6,   6,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   6,   6,   6,   6,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   7,   7,   7,   9,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   8,   8,   9,  11,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n   9,   9,   9,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n  10,  10,  11,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n  11,  11,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n  12,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n------------------------------\nLCA of 6 and 7 is 3. Expected : 3\nLCA of 4 and 7 is 1. Expected : 1\nLCA of 2 and 3 is 1. Expected : 1\nLCA of 2 and 2 is 2. Expected : 2\nLCA of 1 and 1 is 1. Expected : 1\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvimalk78%2Flca-rmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvimalk78%2Flca-rmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvimalk78%2Flca-rmq/lists"}