- 博客(53)
- 收藏
- 关注
原创 TCP可靠性保证
1、序号(32位seq): 保证数据包的有序性2、检验和(16位): 保证数据在传送过程中不被改变3、确认应答(32位ack+1位ACK)、超时重传: 收到则应答,收不到则重传。保证不丢、不重...
2019-07-28 16:46:34
233
原创 TCP协议头结构--标志位
1、TCP标志位紧急指针(URG)、推送(PSH)、复位标志(RST)、同步标志(SYS) 、确认(ACK)、完成(FIN):握手、挥手时用到
2019-07-28 16:42:29
1881
原创 http协议工作过程
https://www.baidu.com/index.html协议名:https;主机名: www.baidu.com(服务器名www+域名baidu.com)端口:443 根目录:/1)域名解析通过DNS把域名解析成IP地址;并且从url中找出端口号(没有,则默认http默认为80,https为403);2)建立连接根据得到的IP和端口,创建socket、 三次握手建...
2019-07-28 16:23:45
3162
原创 Cookie、Session的区别
http无状态缺点的改进1) 存储方式 Cookie存储在客户端(浏览器)上,Session存储在服务器上;2) 安全性Cookie不安全,任何人都可能查看到,Session安全性高;3) 联系 都是保存用户信息,Cookie保存Session的编号Session_id,而Session保存用户的详细信息。4) 大小限制 Cookie有个数和大小的限制,大小一般是4...
2019-07-28 16:21:03
158
原创 长连接、短连接的区别
1) 定义: 长连接:一次TCP连接上可以传送多个HTTP请求和响应;短连接:一次传输完成立即断开TCP连接;下次传输需要重新TCP三次握手;2) 使用场景:长连接:适用于操作频繁、一对一场景,如数据库连接;短连接:适用于一对多场景,如WEB请求;3) 默认协议:http1.1默认长连接,http1.0默认短连接;4) 优缺点:长连接省去较多的建立和关闭连接操作...
2019-07-28 16:15:25
2164
原创 http1.0、http1.1的区别
同属于http无连接缺点的改进措施1、默认支持长连接:1.1在一个TCP连接上默认可以传送多个HTTP请求和响应,1.0需要在请求头中携带Keep-Alive 参数来向服务器请求长连接。2、节约带宽:1.1支持首部探测(若返回100状态码再继续发送boby),且支持断点续传(客户端已有一部分资源,可只请求另外部分,如迅雷下载),1.0每次只能请求整个对象,浪费带宽。3、增加host字段...
2019-07-28 15:53:31
560
原创 http、https的区别
1)安全性:http协议的数据都是明文传输,不提供任何加密,敏感信息传输不安全;https采用该安全套阶层(SST)进行加密传输、身份验证,传输数据经过加密,安全性高。2) 身份认证:https 协议需要到签证机构(ca)申请证书,加强安全性,证书一般需要付费,第三方无法伪造身份;3)连接方式不同:不同的连接方式,端口也不一样,http默认端口为80,https默认端口为443;ht...
2019-07-28 15:51:27
125
原创 http请求方法(get与post区别)
get、post区别1、本质区别:get用于查询信息(查),post用于插入信息(插);2、安全性:对于服务器讲,get是安全(不更改信息)、幂等(作用1次和n次效果相同); post不安全、不幂等; 对于客户端将,get参数直接暴露在URL, 不安全;post参数放消息体中,更安全;3、传送长度: get受 URL限制,传送数据量小; po...
2019-07-28 15:46:38
1908
原创 http常见响应状态码
1xx:指示信息–表示请求已接收,继续处理。100 http1.1协议中的首部接收成功,可以继续发送body了。2xx:成功–表示请求已被成功接收、理解、接受。200(成功)用浏览器打开一个网页,正常情况下都会返回200HTTP状态码。3xx:重定向(URL跳转)–要完成请求必须进行更进一步的操作。300(多种选择)下载一部片,服务器有...
2019-07-28 15:39:44
972
原创 归并排序
https://leetcode-cn.com/submissions/detail/24096646/class Solution(object): def sortArray(self, nums): # ------------------------------------------------------------------------ ...
2019-07-27 01:19:11
204
原创 1、O(1)时间内删除链表节点
# _*_coding:utf-8 _*_class ListNode: def __init__(self): self.val = None self.next = Noneclass Solution: def __init__(self): return def list_generate(sel...
2019-03-16 22:22:07
114
原创 剑指offer--面试题31:栈的压入弹出序列
#include #include using namespace std; bool IsPopOrder(const int* push,const int* pop,int length){ bool bPossible=false; if(push!=NULL && pop!=NULL && length>0) { stack stackD
2017-08-10 16:46:57
279
原创 剑指offer--面试题30:包含min函数的栈
#include#includeusing namespace std;class Solution{public: stack st, minSt;//st表示存储元素的栈,minSt保存每次栈操作时,保存栈中最小元素 void push(int value) ; void pop() ; int min() ; };void Solution::push(i
2017-08-10 15:27:14
229
原创 分配排序之--基数排序
https://leetcode-cn.com/submissions/detail/24108457/class Solution(object): def maximumGap(self, nums): """ :type nums: List[int] :rtype: int """# ------------...
2017-08-03 15:12:21
317
原创 分配排序之--计数排序
https://leetcode-cn.com/submissions/detail/24102019/参考小灰class Solution(object): def sortArray(self, nums): """ :type nums: List[int] :rtype: List[int] """#...
2017-08-03 15:11:03
278
原创 分配排序之--桶排序
https://leetcode-cn.com/submissions/detail/24105977/参考小灰ttps://mp.weixin.qq.com/s/qrboxA5SwN7AbAcpZ_dpNQclass Solution(object): def sortArray(self, nums): """ :type nums: L...
2017-08-03 14:06:45
644
原创 选择排序之--堆排序
https://leetcode-cn.com/submissions/detail/24096354/class Solution(object): def sortArray(self, nums): # ------------------------------------------------------------------------ ...
2017-08-03 14:03:59
214
原创 选择排序之--简单选择排序
# https://leetcode-cn.com/submissions/detail/21150781/class Solution(object): def sortColors(self, nums): # ------------------------------------------------------------------------ ...
2017-08-03 14:02:56
293
原创 插入排序之--希尔排序
https://leetcode-cn.com/submissions/detail/24096030/class Solution(object): def sortColors(self, nums): """ :type nums: List[int] :rtype: None Do not return anything, mo...
2017-08-03 14:00:44
294
1
原创 插入排序之--折半插入排序
#include#includevoid Binary_Insert_Sort(int a[],int length){ for(int i=1;i<length;i++) { int temp=a[i]; //保存待插入元素 //设置初始区间 for(int low=0,high=i-1;low<=high;)
2017-08-03 13:57:19
247
原创 插入排序之--直接插入排序
https://leetcode-cn.com/submissions/detail/24074608/class Solution(object): def sortColors(self, nums):# ------------------------------------------------------------------------ ...
2017-08-03 13:53:51
215
原创 交换排序之--快速排序
https://leetcode-cn.com/submissions/detail/24124350/class Solution(object): def sortArray(self, nums):# ------------------------------------------------------------------------ ...
2017-08-03 13:49:42
286
原创 交换排序之--冒泡排序
# https://leetcode-cn.com/submissions/detail/24074089/class Solution(object): def sortColors(self, nums): # ------------------------------------------------------------------------ ...
2017-08-03 13:47:16
276
原创 剑指offer--面试题29:顺时针打印矩阵
#includevoid Print_Circle(int (*A)[3],int rows,int cols,int start){ int endX=cols-1-start; int endY=rows-1-start; //从左到右打印一行 for(int i=start;i<=endX;++i) printf("%d ",A[start][i]); //从上到下打印一列
2017-07-25 10:05:13
286
原创 剑指offer--面试题28:对称的二叉树
#include #define nullptr NULLstruct BinaryTreeNode { int m_nValue; BinaryTreeNode* m_pLeft; BinaryTreeNode* m_pRight; };BinaryTreeNode* CreateBinar
2017-07-22 21:01:56
238
原创 剑指offer--面试题27:二叉树的镜像
#include #include #include #include using namespace std; typedef struct BTNode { char data; struct BTNode *lchild; struct BTNode *rchild; }BTNode,*BTree; void C
2017-07-22 19:51:52
269
原创 剑指offer--面试题26:树的子结构
#include #define nullptr NULLstruct BinaryTreeNode{ double m_dbValue; BinaryTreeNode* m_pLeft; BinaryTreeNode* m_pRight;};bool DoesTree1HaveTree2(Binary
2017-07-22 16:30:56
219
原创 剑指offer--面试题25:合并两个排序的链表
#include#includetypedef struct Node{ int data; struct Node *next;}LNode,*LinkList;LinkList Create_List(){ int num; LNode *r,*s; LinkList L=(LinkList)malloc(sizeof(LNode)); L->next=NULL;
2017-07-22 14:46:00
253
原创 剑指offer--面试题24:反转链表
#include#include//****************************************宏定义******************************************************typedef int ElemType;typedef struct node{ ElemType data; struct node *next;}N
2017-07-15 20:42:11
328
原创 剑指offer--面试题23:链表中环的入口节点
#include #include#define nullptr NULLstruct ListNode { int m_nValue; ListNode* m_pNext; }; ListNode* CreateListNode(int value) { ListNode* pNode = new ListNode();
2017-07-15 20:19:39
289
原创 剑指offer--面试题22:链表中倒数第k个节点
#include#include typedef struct node { int data; struct node *next; }Node,*LinkList; Node *FindKthToTail(LinkList L, unsigned int k) { if (L->next == NULL || k == 0
2017-07-15 16:07:44
264
原创 剑指offer--面试题21:调整数组顺序使奇数位于偶数前面
#include void Reorder(int *pData, unsigned int length, bool (*func)(int));bool isEven(int n);void ReorderOddEven(int *pData, unsigned int length){ Reorder(pData, length, isEven);}void Reo
2017-07-15 15:51:47
180
原创 剑指offer--面试题20:表示数值的字符串
#include #includebool scanUnsignedInteger(const char** str) //判断是否是0-9之间的数字;{ const char* before = *str; while(**str != '\0' && **str >= '0' && **str <= '9') ++(*str); // 当str
2017-07-15 14:40:40
448
原创 剑指offer--面试题19:正则表达式匹配
#include /*在每轮匹配中,Patttern第二个字符是'*'时:1、第一个字符不匹配('.'与任意字符视作匹配),那么'*'只能代表匹配0次,比如'ba'与'a*ba',字符串不变,模式向后移动两个字符,然后匹配剩余字符串和模式2、第一个字符匹配,那么'*'可能代表匹配0次,1次,多次,比如'aaa'与'a*aaa'、'aba'与'a*ba'、'aaaba'与'a*ba'。匹配
2017-07-14 20:50:21
317
原创 剑指offer--面试题18:删除链表的结点
#include #includestruct ListNode{ int m_nValue; ListNode* m_pNext;};ListNode* CreateListNode(int value){ ListNode* pNode = new ListNode(); pNode->m_nValue = value; pN
2017-07-14 20:33:52
244
原创 剑指offer--面试题17:打印从1到最大的n位数
#include #include void PrintNumber(char* number);bool Increment(char* number);// ====================方法一====================void Print1ToMaxN_1(int n) { if (n<= 0) return;
2017-07-14 15:45:09
259
原创 剑指offer--面试题16:数值的整数次方
#include #include double PowerWithUnsignedExponent(double base, unsigned int exponent){ if (exponent == 0) return 1; if (exponent == 1) return base; double result = P
2017-07-12 21:54:56
293
原创 剑指offer--面试题15:二进制中1的个数
#include int NumberOf1_Solution1(int n){ int count = 0; unsigned int flag = 1; while (flag) { if (n & flag) count++; flag = flag << 1; } return
2017-07-12 11:23:11
259
原创 剑指offer--面试题14:剪绳子
#include #include// ====================动态规划====================int maxProductAfterCutting_solution1(int length){ if(length < 2) return 0; if(length == 2) return 1; if
2017-07-12 10:32:50
1912
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人