06 2015 档案

摘要:排序算法复习大致结束了,主要有以下几种:冒泡排序、选择排序、简单插入排序、希尔排序、归并排序、快速排序、堆排序。#include #define MAXSIZE 1000using namespace std;class SqList{public: SqList():length(0){} Sq... 阅读全文
posted @ 2015-06-30 08:43 朱传林 阅读(191) 评论(0) 推荐(0) 编辑
摘要:堆的定义:1)完全二叉树,2)每个结点的值都大于其左右孩子结点的值。根据堆的定义可知,最大值就是根结点,其次就是根结点左右孩子结点中的一个…… 堆排序有两个很重要的过程:1)建堆,2)堆维护。实质上,这两个过程都可以通过一个函数来实现。void HeapAdjust(SqList* l... 阅读全文
posted @ 2015-06-30 08:41 朱传林 阅读(152) 评论(0) 推荐(0) 编辑
摘要:快速排序将以枢轴为界,将原数组分为两个部分,枢轴以前,值都小于枢轴的值,枢轴以后的值都大于枢轴。 采用递归的方法,对以枢轴为界的两个子序列进行快速排序,直至子序列长度为1。 1、快速排序的关键是枢轴的选取,主要有三种方法:1)选取第一个或最后一个作为枢轴值;2)采用随机数生成器,生成枢... 阅读全文
posted @ 2015-06-30 07:59 朱传林 阅读(285) 评论(0) 推荐(0) 编辑
摘要:归并排序原理即将两个有序的数组合并成一个,归并排序有两种方法:递归和循环。/*递归方法*/void Merge(int TR1[], int TR2[], int low, int mid, int high){//将TR2归并入TR1中 int pos1 = low; int pos2 = mid... 阅读全文
posted @ 2015-06-29 16:46 朱传林 阅读(153) 评论(0) 推荐(0) 编辑
摘要:对于C++程序员来说,编辑器不是必要的,直接在IDE中写代码就可以。但有时,写一些短小的代码或者写一些脚本的时候,编辑器还是比较必要的。 以前用的是NotePad++,NotePad++还是挺不错的。本人以后想朝Linux方向发展,而Sublime是跨平台的,所以就放弃NotePa... 阅读全文
posted @ 2015-06-29 09:29 朱传林 阅读(197) 评论(0) 推荐(0) 编辑
摘要:进入找工作倒计时状态了,计划好好复习一下数据结构和相关算法,预计用两天时间把见过的排序算法整理下,首先看一下时间复杂度为O(n2)的算法。 首先参考大话数据结构定义一个链表类:#include #define MAXSIZE 1000using namespace std;cl... 阅读全文
posted @ 2015-06-29 08:14 朱传林 阅读(172) 评论(0) 推荐(0) 编辑
摘要:/etc/profile,/etc/bashrc 是系统全局环境变量设定~/.profile,~/.bashrc用户家目录下的私有环境变量设定当登入系统时候获得一个shell进程时,其读取环境设定档有三步1首先读入的是全局环境变量设定档/etc/profile,然后根据其内容读取额外的设定的文档,如... 阅读全文
posted @ 2015-06-26 14:42 朱传林 阅读(117) 评论(0) 推荐(0) 编辑
摘要:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1... 阅读全文
posted @ 2015-06-23 14:09 朱传林 阅读(106) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n... 阅读全文
posted @ 2015-06-23 13:00 朱传林 阅读(153) 评论(0) 推荐(0) 编辑
摘要:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next... 阅读全文
posted @ 2015-06-23 11:50 朱传林 阅读(113) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al... 阅读全文
posted @ 2015-06-22 10:08 朱传林 阅读(124) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa... 阅读全文
posted @ 2015-06-22 09:09 朱传林 阅读(117) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl... 阅读全文
posted @ 2015-06-22 09:00 朱传林 阅读(105) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth... 阅读全文
posted @ 2015-06-22 08:52 朱传林 阅读(138) 评论(0) 推荐(0) 编辑
摘要:Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, except... 阅读全文
posted @ 2015-06-22 08:32 朱传林 阅读(148) 评论(0) 推荐(0) 编辑
摘要:Given preorder and inorder (Inorder and Postorder) traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in ... 阅读全文
posted @ 2015-06-22 08:26 朱传林 阅读(161) 评论(0) 推荐(0) 编辑
摘要: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 le... 阅读全文
posted @ 2015-06-21 16:05 朱传林 阅读(106) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2... 阅读全文
posted @ 2015-06-21 15:04 朱传林 阅读(119) 评论(0) 推荐(0) 编辑
摘要:1、几乎所有关于二叉树的问题都可以用递归解决,二叉树和递归可谓相依相生;2、对于二叉树问题,递归的代码量往往比循环要简单很多,但简单不一定意味着好,递归的深度如果太大,容易引起栈溢出;3、遍历二叉树时,可以考虑使用栈存储二叉树;4、只要知道二叉树的前序和中序或后序和中序就可以还原二叉树,但前序和后序... 阅读全文
posted @ 2015-06-21 12:00 朱传林 阅读(101) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ... 阅读全文
posted @ 2015-06-21 11:49 朱传林 阅读(151) 评论(0) 推荐(0) 编辑
摘要:反转二叉树:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) :... 阅读全文
posted @ 2015-06-21 11:48 朱传林 阅读(157) 评论(0) 推荐(0) 编辑
摘要:三种方法中,递归最为简单,栈次之,循环最为麻烦。递归的深度如果太大则会导致栈溢出;栈的方式需要额外的辅助空间;循环编程最麻烦。 首先是递归://递归方法void midPrint_r(TreeNode* root){//中序遍历 if(root==NULL) return; if... 阅读全文
posted @ 2015-06-21 09:47 朱传林 阅读(200) 评论(0) 推荐(0) 编辑
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-... 阅读全文
posted @ 2015-06-18 16:44 朱传林 阅读(115) 评论(0) 推荐(0) 编辑
摘要:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu... 阅读全文
posted @ 2015-06-18 15:48 朱传林 阅读(109) 评论(0) 推荐(0) 编辑
摘要:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No... 阅读全文
posted @ 2015-06-18 15:16 朱传林 阅读(132) 评论(0) 推荐(0) 编辑
摘要:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文
posted @ 2015-06-18 09:08 朱传林 阅读(90) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re... 阅读全文
posted @ 2015-06-18 08:15 朱传林 阅读(142) 评论(0) 推荐(0) 编辑
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Def... 阅读全文
posted @ 2015-06-18 08:12 朱传林 阅读(113) 评论(0) 推荐(0) 编辑
摘要:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ... 阅读全文
posted @ 2015-06-18 08:11 朱传林 阅读(106) 评论(0) 推荐(0) 编辑
摘要:Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For exam... 阅读全文
posted @ 2015-06-17 15:42 朱传林 阅读(186) 评论(0) 推荐(0) 编辑
摘要:Sort a linked list inO(nlogn) time using constant space complexity. 分析:排序算法中,堆排序、归并排序、快速排序、希尔排序的时间复杂度是nlogn,堆排序和归并排序对下标依赖性比较强,比较适合顺序表的排序,对链表处理起来比较... 阅读全文
posted @ 2015-06-17 09:45 朱传林 阅读(154) 评论(0) 推荐(0) 编辑
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *... 阅读全文
posted @ 2015-06-17 09:42 朱传林 阅读(124) 评论(0) 推荐(0) 编辑
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... 阅读全文
posted @ 2015-06-16 14:41 朱传林 阅读(159) 评论(0) 推荐(0) 编辑
摘要:Remove all elements from a linked list of integers that have valueval.ExampleGiven:1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6,val= 6Return:1 --> 2 --> 3 --... 阅读全文
posted @ 2015-06-16 14:40 朱传林 阅读(118) 评论(0) 推荐(0) 编辑
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *... 阅读全文
posted @ 2015-06-16 14:38 朱传林 阅读(127) 评论(0) 推荐(0) 编辑
摘要:/*如果采用单向链表,end()函数如何表示? *所以必须得采用循环链表的方式? * */#ifndef LIST#define LIST#includeusing namespace std;//声明template struct Node{ T data; struct Node* next; ... 阅读全文
posted @ 2015-06-15 16:30 朱传林 阅读(135) 评论(0) 推荐(0) 编辑
摘要:仅仅实现了基本的链表操作,如创建、查找、删除、排序等。//头文件/*there is no head node exist * */#include using namespace std;typedef struct Node{ int value; struct Node* next;}... 阅读全文
posted @ 2015-06-14 16:39 朱传林 阅读(172) 评论(0) 推荐(0) 编辑
摘要:一、整数的表示1、对于无符号数,可以认为是不包含负数的原码表示方法,即直接把正数转换成二进制表示; 对于有符号数,有三种表示方法 1)补码,最高位的权重为-2^(w-1),这是原码表示的最高位权重是正好相反的。补码是有符号数用的最多的编码方式,表示的有符号数据的范围为[-2^(w-1),2^... 阅读全文
posted @ 2015-06-13 15:45 朱传林 阅读(218) 评论(0) 推荐(0) 编辑
摘要:对string作了一些扩展,包括string转化为int、string转化为double、string转化为bool、打印系统当前时间。但没有解决数据溢出的问题,请大神帮忙解决!//头文件/*part of interface about string; *it follow the functio... 阅读全文
posted @ 2015-06-12 15:43 朱传林 阅读(163) 评论(0) 推荐(0) 编辑
摘要:原文:http://www.cnblogs.com/yubinfeng/archive/2010/11/02/1867386.html一、基础1、说明:创建数据库CREATE DATABASE database-name2、说明:删除数据库drop database dbname3、说明:备份sql... 阅读全文
posted @ 2015-06-12 12:43 朱传林 阅读(268) 评论(0) 推荐(0) 编辑
摘要:原文:http://www.cnblogs.com/flysnail/archive/2012/07/11/2586716.html背景Google的开源项目大多使用C++开发。每一个C++程序员也都知道,C++具有很多强大的语言特性,但这种强大不可避免的导致它的复杂,这种复杂会使得代码更易于出现b... 阅读全文
posted @ 2015-06-11 11:25 朱传林 阅读(160) 评论(0) 推荐(0) 编辑
摘要:原文:http://blog.csdn.net/xupan_jsj/article/details/7855090一、C++编译模式通常,在一个C++程序中,只包含两类文件——.cpp文件和.h文件。其中,.cpp文件被称作C++源文件,里面放的都是C++的源代码;而.h文件则被称作C++头文件,里... 阅读全文
posted @ 2015-06-10 15:48 朱传林 阅读(125) 评论(0) 推荐(0) 编辑
摘要:关于头文件的编译,在我另一篇转载的博客中有很详细的说明,在这里不再多言。 现在直接比较以下两种类的实现方式://头文件1#include #include "date.h"#include "address.h"using namespace std;class Person{public... 阅读全文
posted @ 2015-06-10 15:37 朱传林 阅读(180) 评论(0) 推荐(0) 编辑
摘要:1、C和C++的区别 1)从语法上来说,C是C++的一个子集,C++是在C的基础上发展而来,C++对C的兼容的;其次,C++除了C这一模块之外,还有包括:面向对象的部分(类、继承、封装、多态等),泛型编程部分,STL。 2)从编程思想上来说,C是一种结构化的语言,它的重点在算法和数据结构上,... 阅读全文
posted @ 2015-06-08 16:52 朱传林 阅读(168) 评论(0) 推荐(0) 编辑
摘要:原文:http://blog.csdn.net/lcj_cjfykx/article/details/41691787分治算法 一、基本概念 在计算机科学中,分治法是一种很重要的算法。字面上的解释是“分而治之”,就是把一个复杂的问题分成两个或更多的相同或相似的子问题,再把子问题分成更小的子问题……直... 阅读全文
posted @ 2015-06-08 16:00 朱传林 阅读(211) 评论(0) 推荐(0) 编辑
摘要:原文:http://blog.csdn.net/nomasp/article/details/46380027回顾比较排序相信阅读过前面5篇博文的童鞋们已经发现了“在排序的最终结果中,各元素的次序依赖于它们之间的比较”。于是乎,这类排序算法被统称为”比较排序“。比较排序是通过一个单一且抽象的比较运算... 阅读全文
posted @ 2015-06-08 10:59 朱传林 阅读(186) 评论(0) 推荐(0) 编辑
摘要:1、在C/C++中,当数组作为函数的参数进行传递时,数组就自动退化为同类型的指针。2、对于str1、str2定义时须分配内存空间,所以地址不同,而str3、str4都指向某一常量区,所以地址是相同的。char str1[] = "hello world";char str2[] = "hello w... 阅读全文
posted @ 2015-06-04 11:05 朱传林 阅读(201) 评论(0) 推荐(0) 编辑
摘要:http://rickie622.blog.163.com/blog/static/212388112011213407503/查看当前发行版可以使用的shell[jack@localhost ~]$ cat /etc/shells/bin/sh/bin/bash/sbin/nologin查看当前使... 阅读全文
posted @ 2015-06-01 08:34 朱传林 阅读(237) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示