前序中序构建二叉树

摘要: public Node PreMidToTree(int[] pre,int[] mid) { if (pre == null || mid == null) return; Dictionary dic = new Dictionary(); for (int i = 0; i dic) { ... 阅读全文
posted @ 2017-05-24 20:07 冰狼舞 阅读(129) 评论(0) 推荐(0) 编辑

链表去重

摘要: private void RemoveDupNode(List list) { Node head =list[0]; Node p,q,r; while(p!=null) { q = p; while(q.next!=null) { if(q.next.data == p.data) { r = q.next; q.ne... 阅读全文
posted @ 2017-05-11 20:53 冰狼舞 阅读(103) 评论(0) 推荐(0) 编辑

链表逆序

摘要: private void ListResverse(ListNode head) { ListNode cur,next; if(head == null||head.next == null) return; cur = head.next; while(cur.next!=null) { next = cur.next; cur.next = ne... 阅读全文
posted @ 2017-05-08 20:47 冰狼舞 阅读(60) 评论(0) 推荐(0) 编辑

快排

摘要: private void QuickSort(List list,int left,int right) { if(left=x&&i<j) j--; while(list[i]<=x&&i<j) i++; if(i<j) { temp = list[i]; list[i] = list[j]; list[j... 阅读全文
posted @ 2017-04-20 18:27 冰狼舞 阅读(101) 评论(0) 推荐(0) 编辑

层序遍历

摘要: private void LevelOrder(TreeNode node) { Queue queue = new Queue(); queue.Enqueue(node); TreeNode treeNode = null; while(queue.Count>0) { treeNode = queue.Dequeue(); ... 阅读全文
posted @ 2017-04-12 18:37 冰狼舞 阅读(95) 评论(0) 推荐(0) 编辑

二分查找

摘要: private int BinarySearch(List list,int value) { int low = 0; int high = list.Count - 1; int middle = 0; while(lowvalue) high = middle-1; else if(list[middle]<value) low = midd... 阅读全文
posted @ 2017-04-12 11:33 冰狼舞 阅读(80) 评论(0) 推荐(0) 编辑