自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(17)
  • 收藏
  • 关注

原创 Given a binary tree, return the preorder traversal of its nodes' values.

Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Note: Recursive solution

2017-04-28 12:45:09 636

原创 由LeetCode引发的二叉树 前序,中序,后序总结

前序遍历:访问根节点——访问左子树——访问右子树中序遍历访问左子树——访问根节点——访问右子树后序遍历访问左子树——访问右子树——访问根节点实例演示:对于如下的二叉树:前序遍历:GDAFEMHZ中序遍历:ADEFGHMZ后序遍历:AEFDHZMG

2017-04-28 12:35:42 595

原创 LeetCode Given a binary tree, return the postorder traversal of its nodes' values.

Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].Note: Recursive solutio

2017-04-28 11:29:02 3513

原创 二分查找算法详解以及java实现

二分查找的基本思想:m=(i+j)/2i=m+1j=m-1对于一组数据:数值 22 34 55 7789 93 99 102 120 140索引 0 12 3 4 5 67 8 9查找数据77,99,34的流程:对于77:i=0, j=9, m=4, k=89>77  选择左子表i=0, j=3, m=1, k=3

2017-04-25 15:29:19 831

原创 给定一个字符串实现对字符串左移或右移指定长度

给定一个字符串S[0,1,...,N-1],要求把S的前k个字符移动到S的尾部,如把字符串"abcdef"前面的2个字符'a','b'移动到字符串的尾部,得到新字符串“cdefab”;即字符串循环左移k

2017-04-24 22:00:41 3443

原创 Huffman编码原理(C++,java实现)

对于给定一组数利用huffman对其编码1. 首先介绍huffman树

2017-04-24 21:07:08 553

原创 从数组中找出最大的前两个数

#include void select(int* data,int data_size,int &Max,int &secondMax){ //Max=data[0]; //secondMax=data[0]; for(int i=0;i<data_size;i++){ if(Max<data[i]){ secondMax=Max; Max=data[i]; }e

2017-04-24 20:50:56 3125 2

原创 字符串长度统计

#include #include "tchar.h"using namespace std;//int _tmain(int argc,_TCHAR* argv[]){// char str[]="JulyEdu";// printf("%d\n",sizeof(str)); //8// printf("%d\n",strlen(str));//4// return 0;//}

2017-04-24 15:22:25 518

原创 11月基础算班,凯撒加密和异或加密,C++程序实现

凯撒加密:#include #include #include using namespace std;//11月算法基础班//如何解密未知nCaesar的密文//1.暴力解密,进行26次//2.统计密文中字符出现的频率,与正常文本中字符的频率进行比较int _tmain(int argc, _TCHAR* argv[]){ ifstream iFile("G://p

2017-04-24 15:04:51 683

原创 常量字符串常遇问题,代码解释

#include #include ////#include //#include "stdafx.h"using namespace std;//--->1//int _tmain(int argc, _TCHAR* argv[])//{// char* str="JulyEdu"; //等效于const char* str="JulyEdu"// str[4]='a'

2017-04-24 10:31:02 374

原创 java实现交换排序

所谓交换,就是根据序列中两个记录键值的比较结果来对换这两个记录在序列中的位置,交换排序的特点是:将键值较大的记录向序列的尾部移动,键值较小的记录向序列的前部移动。public class Solution { /* * java实现交换排序 */ public int[] sortChange(int[] data){ int temp; for(

2017-04-23 23:01:05 1481

原创 java选择排序实现

1.选择排序算法描述:选择排序:比如在一个长度为N的无序数组中,在第一趟遍历N个数据,找出其中最小的数值与第一个元素交换,第二趟遍历剩下的N-1个数据,找出其中最小的数值与第二个元素交换......第N-1趟遍历剩下的2个数据,找出其中最小的数值与第N-1个元素交换,至此选择排序完成。以下面5个无序的数据为例:56 12 80 91 20(文中仅细化了第一趟的选择过程)

2017-04-23 22:48:20 422

原创 冒泡排序

冒泡排序的基本思想是:每次比较两个相邻的元素,如果它们的顺序错误就把它们交换过来。例如我们需要将12 35 99 18 76 这 5 个数进行从大到小的排序。第一次排序:后续排序与重复第一次排序的工作。对应java代码实现:

2017-04-23 11:44:19 319

原创 由LeetCode排序引起的排序算法总结

排序算法分类概览冒泡排序、选择排序、插入排序,对象排序,时间复杂度为O(n^2);快速排序、归并排序、堆排序时间复杂度为O(nlogn);基数排序、计数排序,划分排序,桶排序,时间复杂度都是O(n)排序算法性能比较不同排序算法性能比较排序算法稳定性定义算法复杂度分类及比较

2017-04-23 10:57:05 1149

原创 Leetcode--->Given n points on a 2D plane, find the maximum number of points that lie on the same str

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line./** * Definition for a point. * class Point { * int x; * int y; * Point() {

2017-04-21 21:47:18 2281

原创 leetcode

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node./** * Definition for binary tree *

2017-04-20 09:45:01 480

原创 LeetCode 逆波兰表达式java实现

Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression.Some examples: ["2", "1", "+", "3"

2017-04-20 09:41:36 1758

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除