{"id":17141341,"url":"https://github.com/talisk/skdatastructureexercise","last_synced_at":"2025-03-24T08:21:53.415Z","repository":{"id":254426591,"uuid":"51731167","full_name":"talisk/SKDataStructureExercise","owner":"talisk","description":null,"archived":false,"fork":false,"pushed_at":"2016-03-06T11:15:20.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T13:46:23.433Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","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/talisk.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-15T04:40:44.000Z","updated_at":"2021-07-15T07:07:21.000Z","dependencies_parsed_at":"2024-08-23T11:59:56.456Z","dependency_job_id":"dc1edd50-7e84-400e-8978-a181b3b2d467","html_url":"https://github.com/talisk/SKDataStructureExercise","commit_stats":null,"previous_names":["talisk/skdatastructureexercise"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talisk%2FSKDataStructureExercise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talisk%2FSKDataStructureExercise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talisk%2FSKDataStructureExercise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talisk%2FSKDataStructureExercise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/talisk","download_url":"https://codeload.github.com/talisk/SKDataStructureExercise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245233033,"owners_count":20581727,"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":[],"created_at":"2024-10-14T20:25:04.224Z","updated_at":"2025-03-24T08:21:53.392Z","avatar_url":"https://github.com/talisk.png","language":"C++","readme":"# 数据结构练习题 - C++实现\n\n## 第1题 | [解题思路](https://github.com/talisk/SKDataStructureExercise/tree/master/ex001)\n\n把二元查找树转变成排序的双向链表\n\n输入一棵二元查找树，将该二元查找树转换成一个排序的双向链表。要求不能创建任何新的结点，只调整指针的指向。\n\n10\n\n|\t\\\n\n6\t\t14\n\n|\t\\\t|\t\\\n\n4\t8\t12\t16\n\n转换成双向链表\n\n4=6=8=10=12=14=16。\n\n首先我们定义的二元查找树 节点的数据结构如下：\n\n```c++\nstruct BSTreeNode {\n  int m_nValue; // value of node\n  BSTreeNode *m_pLeft; // left child of node\n  BSTreeNode *m_pRight; // right child of node\n};\n```\n\n## 第2题 | [解题思路](https://github.com/talisk/SKDataStructureExercise/tree/master/ex002)\n\n设计包含min函数的栈。\n\n定义栈的数据结构，要求添加一个min函数，能够得到栈的最小元素。\n\n要求函数min、push以及pop的时间复杂度都是O(1)。\n\n## 第3题 | [解题思路](https://github.com/talisk/SKDataStructureExercise/tree/master/ex003)\n\n求子数组的最大和\n\n输入一个整形数组，数组里有正数也有负数。数组中连续的一个或多个整数组成一个子数组，每个子数组都有一个和。求所有子数组的和的最大值。要求时间复杂度为O(n)。\n\n例如输入的数组为1, -2, 3, 10, -4, 7, 2, -5，和最大的子数组为3, 10, -4, 7, 2，因此输出为该子数组的和18。\n\n## 第4题 | [解题思路](https://github.com/talisk/SKDataStructureExercise/tree/master/ex004)\n\n在二元树中找出和为某一值的所有路径\n\n输入一个整数和一颗二元树，从树的根结点开始往下访问一直到叶结点所经过的所有结点形成一条路径。打印出和与输入整数相等的所有路径。\n\n例如输入整数22和如下二元树：\n\n10\n\n|\t\\\n\n5\t\t12\n\n|\t\\\n\n4\t7\n\n则打印出两条路径：10, 12和10, 5, 7。\n\n二元树结点的数据结构定义为：\n\n```c++\nstruct BinaryTreeNode { // a node in the binary tree\n\tint m_nValue; // value of node\n  \tBinaryTreeNode *m_pLeft; // left child of node\n\tBinaryTreeNode *m_pRight; // right child of node\n};\n```\n\n## 第5题 | [解题思路](https://github.com/talisk/SKDataStructureExercise/tree/master/ex005)\n\n查找最小的k个元素。输入n个证书，输出其中最小的k个。\n\n例如输入1, 2, 3, 4, 5, 6, 7, 8这八个数字，则最小的四个数字为1, 2, 3, 4, 5。\n\n## 第6题 | [解题思路](https://github.com/talisk/SKDataStructureExercise/tree/master/ex006)\n\n给你10分钟的时间，根据上排给出十个数，要求下排每个数都是先前上排那十个数在下排出现的次数。\n\n上排的十个数如下：【0, 1, 2, 3, 4, 5, 6, 7, 8, 9】\n\n举一个例子，\n\n数值：0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n\n分配：6, 2, 1, 0, 0, 0, 1, 0, 0, 0\n\n0在下排出现6次，1在下排出现2次……以此类推。\n\n## 第7题 | [解题思路](https://github.com/talisk/SKDataStructureExercise/tree/master/ex007)\n\n编程判断两个链表是否相交。给出两个单向链表的头指针，比如h1，h2，判断这两个链表是否相交。为了简化问题，我们假设两个链表均不带环。","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalisk%2Fskdatastructureexercise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftalisk%2Fskdatastructureexercise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalisk%2Fskdatastructureexercise/lists"}