- 博客(27)
- 问答 (1)
- 收藏
- 关注
原创 平衡查找树——2-3查找树——红黑树(1)
二叉查找树VS平衡查找树Binary Search Tree possibilitiesBalanced Search Trees如何学 平衡查找树为了保证之前学习的二分查找树BST的平衡性,解决在最坏情况时高度为N的情况,这里有几种平衡查找树:AVL2-3 Search TreesRed-black BSTs ——红黑二叉查找树直接关注最重要的一种搜索树——红黑树,在SGI STL中红黑树
2016-09-30 14:41:30 3419
原创 二叉查找树BST(2)
经典算法书关于算法的一些推荐书籍,可以看下这里BST API#include <iostream>using std::cout;using std::cin;using std::endl;using ElemType = int;class BST {private: struct Node { ElemType data; Node *left;
2016-09-29 15:13:44 474
原创 推荐两本算法书
完善一下BST,后续还会继续完善,然后将一些讲解贴出来。#include <iostream>using std::cout;using std::cin;using std::endl;using ElemType = int;class BST {private: struct Node { ElemType data; Node *left;
2016-09-28 23:00:15 5481
原创 union-find(并查集)
推荐一本普林斯顿大学实战型数据结构与算法书全书用java实现,之前没用过java不用担心的。真是感觉曾经的自己那么naive(当然现在依旧,只不过naive level降低了…),当年为什么就是不明白并查集,觉着非常高端。记着那几个学长讲到这里时,就是彻底不懂。现在,起码给你思想,你能懂了。声明:切的图片、敲的代码都来自本书union-find API(1)UF(int N) // initiali
2016-09-28 11:30:43 312
原创 Operating Systems
Three levelvirtualizationconcurrencypersistenceWhy need OS virtualize resources?This is not the main question, as the answer should be obvious: it makes the system easier to use.How to virtualize r
2016-09-27 15:27:06 698
原创 Some Questions of Process API(1)
Some Questions of Process APIRecord some code of calling Process API to enhance the understanding of these API. Some questions and related coding. It’s even more fun than it sounds!Aside(RTFM – READ
2016-09-25 12:10:35 1147
原创 关于读书梯度的领会
单从计算机类书籍方面说读书一定要读经典书,比如学习C语言,可以看下C之父的书(是的,就是那本);学C++可以读一下《C++ primer》;学习OS,读…exception 1但是,有写经典书,不是你想读就能读的,得看你的水平。比如说,当你刚要学C++,可能,我说的可能,你要去看《C++ primer》就可能看不懂,那怎么办?先去此类书籍中简单点儿的书,当然尽量还是经典书。exception 2还有
2016-09-22 10:46:48 277
原创 C语言模拟shell命令1
Process API在UNIX系统中,如何创建进程?UNIX在提供的system calls中,有一对非常奇异的创建新的进程system calls: fork()exec()当然,要用这两个system calls,还要用到wait(),通常是一个进程用来等待另一个进程完成。关于为什么UNIX给了这么几个奇异的接口来创建一个新的进程呢?历史证明吧!在构建UNIX shell中,fork()
2016-09-22 09:45:19 1556
原创 72. Edit Distance
ProblemGiven two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a wor
2016-09-16 18:12:05 217
原创 70. Climbing Stairs
ProblemYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Solution题目思路了很简单了:dp[i] = dp[i
2016-09-16 16:09:29 175
原创 120. Triangle
ProblemGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,
2016-09-14 09:19:12 190
原创 198. House Robber
ProblomYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent
2016-09-13 08:57:51 185
原创 快速排序(quicksort)
IT公司招人,无论笔试还是面试,快排基本上都会问到。通常情况下,快排实现有两个函数:void quickSort(int arr[], int left, int right);int partition(int arr[], int left, int right)快排采用divide-and-conquer策略:选一个pivot valuePartitionSort both par
2016-09-11 14:55:10 3750
原创 121. Best Time to Buy and Sell Stock
ProblemSay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock
2016-09-09 17:37:44 189
原创 53. Maximum Subarray
最近迷恋DP,我看还是将这个主题先解决一些。ProblemFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous
2016-09-09 16:13:18 157
原创 300. Longest Increasing Subsequence
ProblemGiven an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 101], theref
2016-09-08 11:37:23 167
原创 63. Unique Paths II
ProblemFollow up for “Unique Paths”:Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid
2016-09-08 10:15:23 149
原创 62. Unique Paths
ProblemA robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach th
2016-09-07 17:30:46 161
原创 64. Minimum Path Sum
ProblemGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right
2016-09-07 15:33:47 147
原创 374. Guess Number Higher or Lower
还是按照Similar Problems刷题更好些…ProblemWe are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I’ll tell you whe
2016-09-07 11:43:43 166
原创 278. First Bad Version
ProblemYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based
2016-09-07 11:31:11 174
原创 34. Search for a Range
TitleGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the target is not found in t
2016-09-07 10:42:05 225
原创 260. Single Number III
TitleGiven an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given nums =
2016-09-04 10:32:45 203
原创 137. Single Number II
TitleGiven an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without usi
2016-09-04 09:44:48 184
原创 136. Single Number
TitleGiven an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using ext
2016-09-03 23:51:10 170
原创 二叉查找树BST(1)
今天建二叉查找树(binary search tree)#include <iostream>using std::cout;using std::endl;using ElemType = int;struct Node { ElemType data; Node *left; Node *right;};class BST {public: BST();
2016-09-03 17:44:20 310
空空如也
求帮助:2. Add Two Numbers ,已疯,谢谢
2016-05-19
TA创建的收藏夹 TA关注的收藏夹
TA关注的人