LeetCode – Minimum Depth of Binary Tree

题目: 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. Note: A leaf is a node with no children. Example: Given binary tree [3,9,20,null,null,15,7], 1 2 3 4 5 3 / \ 9 20 / \ 15 7 return its minimum depth = 2. ...

2020-06-23 · 2 min · 256 words · Garlic Space

Linux Swap 启停及swappiness设置

可以通过磁盘分区和文件两种方式进行操作

2020-06-21 · 2 min · 406 words · Garlic Space

The XY Problem

原文链接 The XY Problem

2020-06-21 · 1 min · 77 words · Garlic Space

安全攻防技能-安全基础概念

cybersecurity: 网络空间安全涉及旨在保护设备,网络,程序和数据免受攻击和未经授权的访问的一系列实践,流程和技术; 网络安全不仅可以保护数据,还可以保护存储数据的资源和技术。

2020-06-20 · 3 min · 501 words · Garlic Space

LeetCode – Binary Tree Level Order Traversal Solution

题目: Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7], 1 2 3 4 5 3 / \ 9 20 / \ 15 7 return its level order traversal as: 1 2 3 4 5 [ [3], [9,20], [15,7] ] 解题: 两种方式处理, 广度优先搜索借助队列,一层一层处理,并放入二维数组; 深度优先搜索借助栈, 一个一个处理, 将每一个元素方式所属层对应的一维数组中。 ...

2020-06-09 · 2 min · 304 words · Garlic Space

Timers and time management in the Linux kernel. Part 7.

这篇文章 Timers and time management in the Linux kernel. Part 7. 是出自 linux-insides

2020-06-07 · 10 min · 1923 words · Garlic Space

/proc/buddyinfo文件

/proc/buddyinfo 文件可以查看Linux机器上可用的内存页, 可以查看每个节点,不同区域的每个order大小的块的可用数量, 下面是我们虚拟机的信息:

2020-06-06 · 2 min · 355 words · Garlic Space

LeetCode –Binary Tree Postorder Traversal

题目: Given a binary tree, return the postorder traversal of its nodes’ values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [3,2,1] Follow up: Recursive solution is trivial, could you do it iteratively? 解题: 遍历顺序“根-左-右” 实现: 使用栈实现 从根节点开始,先将根节点压入栈,保存结果值,然后移动到右节点, 保证“根-右边”顺序, 为空后出栈,取其左节点入栈中。这样入栈就保证了访问顺序为“根-右-左”, 出栈实现“左-右-根”。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 class Solution { public: vector<int> postorderTraversal(TreeNode* root) { vector<int> res; stack<TreeNode*> ss; TreeNode *p= root, *t; while(!ss.empty()||p){ if (p){ ss.push(p); res.insert(res.begin(), p->val); p = p->right; } else { p=ss.top(); ss.pop(); p= p->left; } } return res; } }; 实现: 递归实现 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 class Solution { public: vector<int> postorderTraversal(TreeNode* root) { vector <int> res; postorder(root, res); return res; } void postorder(TreeNode *root, vector<int> &res){ if (!root) { return; } if (root->left) { postorder(root->left, res); } if (root->right){ postorder(root->right, res); } res.push_back(root->val); } }; 参考: [LeetCode] 145. Binary Tree Postorder Traversal 二叉树的后序遍历

2020-06-04 · 1 min · 175 words · Garlic Space

功能点分析法整理

由于工作需要,需要在项目立项前都需要进行功能点估算, 为后续计算项目组的的工作效率做准备。目前做了几次估算,在这里整理和总结一下。 我们目前使用的评估的标准参考 IFPUG: ISO/IEC 20926:2009 概述 定义: 1 2 3 The function point is a "unit of measurement" to express the amount of business functionality an information system (as a product) provides to a user. 功能点是业务功能的单位, 也就是从用户视角的进行评估, 是可以和用户交流的。对于我现在实施的外包项目来说就是用一种方法和甲方达成共识。相比较与之前的根据经验评估更有依据些。 步骤 1. 功能点应用的分类 开发项目: 从无到有 升级项目: 功能升级 应用项目: 基线评估 2. 识别应用边界 被测应用与用户间的边界。 3. 确认功能点 被测应用与用户间的边界。 数据功能 ILF: 容纳本应用维护的一组业务数据, 控制数据 ELF: 容纳外部应用维护的数据, 对于外部数据来说是他的ILF 处理功能 EI: 处理来自应用外部的的数据, 主要实现ILF的维护, 应用的控制 EO: 通过ILF生成新数据, 已报表,数据流形式送到应用以外 EQ: 请求来自应用外部, 处理过程包含输入,输出, 但输入不进行ILF文件的维护 复杂度 1. 复杂度评估涉及三种元素 RET & DET & FTR DET :用户可识别的,非重复的域 RET :用户可识别的数据的子集合 FTR: 引用文件类型 2. ILF & EIF 的复杂度 ILF & EIF 1 to 19 DET 20 to 50 DET 51 or more DET 1 RET Low Low Average 2 to 5 RET Low Average High 6 or more RET Average High High ILF: Functional Complexity Rating Unadjusted Function Points Low 7 Average 10 High 15 EIF: Functional Complexity Rating Unadjusted Function Points Low 5 Average 7 High 10 3. EI & EO & EQ 的复杂度 EI: 1 to 4 DET 5 to 15 DET 16 or more DET 0 to 1 FTR Low Low Average 2 FTRs Low Average High 3 or more FTRs Average High High EO & EQ 1 to 5 DET 6 to 19 DET 20 or more DET 0 to 1 FTR Low Low Average 2 to 3 FTRs Low Average High 4 or more FTRs Average High High EI & EQ: Functional Complexity Rating Unadjusted Function Points Low 3 Average 4 High 6 EO: Functional Complexity Rating Unadjusted Function Points Low 4 Average 5 High 7 关于复杂度我们实际场景中目前取的都是平均数, 没有对功能点负责度进一步分析,后续会对数据进行统计, 折算出应用的固定的权重。 ...

2020-06-04 · 3 min · 527 words · Garlic Space

buddy memory allocation相关整理

概述 wiki上的定义: The buddy memory allocation technique is a memory allocation algorithm that divides memory into partitions to try to satisfy a memory request as suitably as possible. This system makes use of splitting memory into halves to try to give a best fit. 伙伴内存分配技术是一种内存分配算法,它将内存划分为多个分区,以尝试尽可能适当地满足内存请求。 该系统利用将内存分成两半来尝试提供最佳匹配。 算法 伙伴系统有多种形式; 将每个块细分为两个较小块的块是最简单,最常见的一种。 选定块的大小要根据实际情况选取,太小则需要更多的内存记录跟踪内存分配, 太大又容易产生空间浪费,另外,就是如果选择2的次幂单位的话, 最大的块有可能不会覆盖整个内存. 例子 同样是wiki的例子,申请的内存调整了下 Step 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 1 24 2.1 23 23 2.2 22 22 23 2.3 21 21 22 23 2.4 20 20 21 22 23 2.5 A:20 20 21 22 23 3 A:20 20 B: 21 22 23 4 A:20 C:20 B: 21 22 23 5.1 A:20 C:20 B: 21 21 21 23 5.2 A:20 C:20 B: 21 D: 21 21 23 6 A:20 C:20 21 D: 21 21 23 7.1 A:20 C:20 21 21 21 23 7.2 A:20 C:20 21 22 23 8 20 C:20 21 22 23 9.1 20 20 21 22 23 9.2 21 21 22 23 9.3 22 22 23 9.4 23 23 9.5 24 初始化状态,每块64K, 最大的块包含 24 个块, 一个4阶块. ...

2020-05-29 · 3 min · 534 words · Garlic Space