{"id":16742383,"url":"https://github.com/urtuba/cpp-binary-tree","last_synced_at":"2025-07-15T22:10:08.545Z","repository":{"id":127188592,"uuid":"166646835","full_name":"urtuba/cpp-binary-tree","owner":"urtuba","description":"constructing a binary tree structure and finding path on it","archived":false,"fork":false,"pushed_at":"2021-07-12T19:13:39.000Z","size":303,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T00:26:45.481Z","etag":null,"topics":["binary-tree","cpp","data-structures","homework","istanbul-technical-university"],"latest_commit_sha":null,"homepage":"","language":"C++","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/urtuba.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":"2019-01-20T10:03:44.000Z","updated_at":"2021-07-21T00:16:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"5804a98f-c4c9-4c50-bf52-cb7c607fe1df","html_url":"https://github.com/urtuba/cpp-binary-tree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/urtuba/cpp-binary-tree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urtuba%2Fcpp-binary-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urtuba%2Fcpp-binary-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urtuba%2Fcpp-binary-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urtuba%2Fcpp-binary-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urtuba","download_url":"https://codeload.github.com/urtuba/cpp-binary-tree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urtuba%2Fcpp-binary-tree/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265464215,"owners_count":23770315,"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":["binary-tree","cpp","data-structures","homework","istanbul-technical-university"],"created_at":"2024-10-13T01:23:35.690Z","updated_at":"2025-07-15T22:10:08.532Z","avatar_url":"https://github.com/urtuba.png","language":"C++","readme":"# Binary Tree Exercise\nIt is data structures homework in Istanbul Technical University.\n\n## Problem\nThere is an input file first line indicates values of nodes of the tree to be created. They are always placed like the graph given below:\n\n\u003cdiv style=\"width:100%\"\u003e\n\u003cdiv style=\"margin:auto\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/urtuba/cpp_binary_tree/master/img/img1.PNG\" alt=\"order\" height=\"250px\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n\nLeft to right, top to bottom. It is impossible to add a node on level 3 before fully filling level 2. Or you cannot add new node to right if left is blank.\n\nSecond line of input file indicates the target. We will try to find a path in the left sub-tree and another one in right sub-tree which makes the target number whey you sum their nodes. Example:\n\n\u003cdiv style=\"width:100%\"\u003e\n\u003cdiv style=\"margin:auto\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/urtuba/cpp_binary_tree/master/img/img2.PNG\" alt=\"order\" height=\"250px\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n\nWe need 1 path for each subtree. If program finds more than one, leftest path is valid in the subtree.\n\n\u003cdiv style=\"width:100%\"\u003e\n\u003cdiv style=\"margin:auto\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/urtuba/cpp_binary_tree/master/img/img3.PNG\" alt=\"order\" height=\"250px\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n\n## Compile and Run\n\nCompile it: ``g++ -std=c++11 -Wall -Werror b_tree.cpp -o b_tree ``\n\nRun it: ``./b_tree input.txt``\n\nRun on windows: ``b_tree input.txt``\n\n## Notes\n\nRemember the first image, there was a series of data like 1, 2, 3, 4, 5... As you can realize, this numbers are ordered with positive integers. Even tree is initialized with different data like 19, 25, 30... there is a secret 1, 2, 3 order in order to their position in the tree. I used this to distinguish whether a node is left or right subtree.\n\nWhenever ``ptr -\u003e nodeNum \u003c 3*pow(2, floor(log2(ptr-\u003enodeNum)))/2`` goes true, you can assume you are in left subtree.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furtuba%2Fcpp-binary-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furtuba%2Fcpp-binary-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furtuba%2Fcpp-binary-tree/lists"}