![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
zerlina98
这个作者很懒,什么都没留下…
展开
-
General Tree
相关术语及定义:(1)Root: 树T是由一个或一个以上的结点组成的有限集,R称为根节点 (2)Subtree: 集合(T-|R|)非空时,集合中结点被划分成n个不相交的子集,每个子集都是树,子集Ti称为T的subtree,定义i < j,Ti位于Tj之前,T0为最左子节点 (3)结点的子结点数目:该结点的出度(out degree) (4)forest: 1/n颗树 (5)ancestor原创 2017-11-25 17:22:16 · 1116 阅读 · 0 评论 -
【Leetcode】2.reverse-integer
题目Given a 32-bit signed integer, reverse digits of an integer.32-bit很大,所以要按位来//调试,可以设置断点,可以单步调试,看究竟是哪里出错//要看代码逻辑,什么变量究竟是什么值#include <iostream>using namespace std;class Solution{public: i...原创 2018-04-01 21:33:04 · 163 阅读 · 0 评论 -
【Leetcode】53. Maximum Subarray
题目:Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.找到拥有最大的和的连续的子数组//也可以用smax = max(smax,sum);class Solution { p...原创 2018-04-01 21:54:46 · 120 阅读 · 0 评论 -
【Leetcode】66. Plus One
Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each element i...原创 2018-04-30 17:57:16 · 162 阅读 · 0 评论 -
【Leetcode】35. Search Insert Position
题目Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.给定...原创 2018-04-01 21:51:06 · 85 阅读 · 0 评论 -
【Leetcode】27 Remove Element
//题目:Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input a...原创 2018-04-01 21:42:08 · 108 阅读 · 0 评论 -
【Leetcode】26 Remove Duplicates from Sorted Array
//题目Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modif...原创 2018-04-01 21:35:48 · 95 阅读 · 0 评论 -
【Leetcode】1. Two Sum
//题目要求Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the s...原创 2018-04-01 21:31:05 · 101 阅读 · 0 评论 -
二叉树构造与遍历
#include#include#includeusing namespace std;/*class link{public: int data; link* next; link(int d):data(d),next(NULL){} link *head; link* tail; };class stack{public: link *top;原创 2018-01-22 16:20:49 · 167 阅读 · 0 评论 -
合并链表
#include #includeusing namespace std;struct ListNode { int val; ListNode* next; ListNode(int i):val(i),next(NULL){} //c++中可以给结构体中加函数,这里用来赋值};class List{ //链表类:头尾指针,构造析构,插入数值,打印,返回第一个数,删除,清原创 2018-01-22 16:20:32 · 193 阅读 · 0 评论 -
BST构造
#includeusing namespace std;#includeclass BstTree{ struct Node{ Node *left; Node *right; int data; Node(int i):data(i),left(NULL),right(NULL){ } };public: Node* ro原创 2018-01-22 16:20:16 · 406 阅读 · 0 评论 -
最小堆与huffman树
#include #include template class MinHeap {private: T * heapArray; int currentSize; int MaxSize; void siftUp(int position){ int par=parent(position); while (position原创 2018-01-22 16:20:01 · 213 阅读 · 0 评论 -
各种排序
#includeusing namespace std;/* *Insertion sort *stable *best case: n *worst case:n^2 *average case:n^2 */void Insertionsort(int arr[],int n){ for(int i=1;i<n;i++){ for(int j=i;(j>0&&arr原创 2018-01-22 16:19:43 · 139 阅读 · 0 评论 -
二分查找
转载 2018-05-02 15:17:43 · 176 阅读 · 0 评论