03 2022 档案

摘要:并发控制理论: 事务的正确性标准ACID 1.原子性Atomicty:一个事物的行为要么全部完成,要不一个都不完成; 执行一个事务可能的结果: 所有行为完成,事务提交; 执行部分行为后终止事务; 确保一致性的方式: 日志:dbms记录所有行为,以便在终止事务后可以撤销(undo)所有行为; 影子页面 阅读全文
posted @ 2022-03-06 21:30 fwx 阅读(163) 评论(0) 推荐(0) 编辑
摘要:排序 sql中的排序用于ORDER BY、DISTINCT等语句; 如果被排序的数据能够全部放在内存中,则直接进行排序即可;但如果数据无法全部放入内存中,我们需要使用分而治之的策略; 把数据分成能够适配内存大小的块,然后进行排序,然后放回内存; 将块合并成一个更大的有序块(可以使用两两merge) 阅读全文
posted @ 2022-03-06 00:16 fwx 阅读(108) 评论(0) 推荐(0) 编辑
摘要:书接上文,这次我来到了project2的学习,2021年第二个项目是要实现动态扩展索引(ExtendibleHash),2020年实现的是b+树,因为b+树用途更加广泛,故将2021年和2020年的project2都做了一下~ 2021年:EXTENDIBLE HASH INDEX 1. hash方 阅读全文
posted @ 2022-03-03 20:27 fwx 阅读(327) 评论(0) 推荐(0) 编辑
摘要:583. 两个字符串的删除操作 class Solution { public: int minDistance(string word1, string word2) { int len1 = word1.size(); int len2 = word2.size(); int dp[len1 + 阅读全文
posted @ 2022-03-02 22:48 fwx 阅读(30) 评论(0) 推荐(0) 编辑
摘要:309. 最佳买卖股票时机含冷冻期 class Solution { public: int maxProfit(vector<int>& prices) { int p_len = prices.size(); int dp[p_len][3]; memset(dp, 0 ,sizeof(dp)) 阅读全文
posted @ 2022-03-02 22:45 fwx 阅读(29) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: int findTargetSumWays(vector<int>& nums, int target) { int sum = target; for_each(begin(nums), end(nums), [&sum](int x){ sum 阅读全文
posted @ 2022-03-02 22:37 fwx 阅读(17) 评论(0) 推荐(0) 编辑
摘要:416. 分割等和子集(背包) class Solution { public: // dp[i][j] 能获得的最大价值: // i --> 代表前i件商品 // j --> 能得到的重量j // 0/1背包状态转移方程: // dp[i][j] = max(dp[i-1][j-w[i]] + v 阅读全文
posted @ 2022-03-02 18:06 fwx 阅读(21) 评论(0) 推荐(0) 编辑
摘要:状态转移方程: class Solution { public: int longestCommonSubsequence(string text1, string text2) { int len1 = text1.size(); int len2 = text2.size(); int dp[l 阅读全文
posted @ 2022-03-02 15:40 fwx 阅读(19) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: int wiggleMaxLength(vector<int>& nums) { int len = nums.size(); if(len == 1) return 1; int up = 1; // key !!! int down = 1; / 阅读全文
posted @ 2022-03-02 15:35 fwx 阅读(26) 评论(0) 推荐(0) 编辑
摘要:按照算法导论的说法,如果把每一个数对理解为一个活动的开始和结束时间,那么我们的目的是尽可能多的进行更多的活动。 此时对于贪心算法,我么直观上应该选择这样一个活动,选出它后剩下的资源应能被尽量多的其他任务所用。因此,应该选择最早结束的活动,因为他剩下的资源可供他之后尽量多的活动使用。这也是为什么要按照 阅读全文
posted @ 2022-03-02 12:49 fwx 阅读(30) 评论(0) 推荐(0) 编辑
摘要:最长递增子序列 // 方法一:动态规划O(N^2) class Solution { public: int lengthOfLIS(vector<int>& nums) { int num_len = nums.size(); int dp[num_len]; dp[0] = 1; int res 阅读全文
posted @ 2022-03-02 12:27 fwx 阅读(19) 评论(0) 推荐(0) 编辑
摘要:343. 整数拆分 class Solution { public: int integerBreak(int n) { if(n <= 2) return 1; int dp[n+1]; dp[1] = 1; dp[2] = 1; for(int i=3;i<=n;++i){ dp[i] = 1; 阅读全文
posted @ 2022-03-02 10:40 fwx 阅读(27) 评论(0) 推荐(0) 编辑
摘要:64. 最小路径和 class Solution { public: int minPathSum(vector<vector<int>>& grid) { int len_x = grid.size(); int len_y = grid[0].size(); int dp[len_y]; dp[ 阅读全文
posted @ 2022-03-02 10:27 fwx 阅读(20) 评论(0) 推荐(0) 编辑
摘要:【动态规划】198. 打家劫舍 213. 打家劫舍 II class Solution { public: int rob(vector<int>& nums) { int num_len = nums.size(); if(num_len == 1) return nums[0]; else if 阅读全文
posted @ 2022-03-02 10:10 fwx 阅读(44) 评论(0) 推荐(0) 编辑
摘要:前段时间学习了CMU15-445 2021fall的DBMS课程,最近春招将近,作为复习,将四个project的实验重新梳理一下。 上图中的buffer pool部分即为本project的主要内容。 buffer pool可以用memory mapping (mmap)将文件中的内容存储在程序的地址 阅读全文
posted @ 2022-03-01 21:59 fwx 阅读(218) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: void dfs(int index, vector<string> &cur_board){ if (index == nn){ result.push_back(cur_board); } else{ int x, y = index; for( 阅读全文
posted @ 2022-03-01 16:54 fwx 阅读(18) 评论(0) 推荐(0) 编辑
摘要:位运算可以大大降低运算难度!!! class Solution { public: void print(vector<vector<char>>& board){ for(auto b: board){ for(auto a: b){ cout << a << " "; } cout << end 阅读全文
posted @ 2022-03-01 16:51 fwx 阅读(21) 评论(0) 推荐(0) 编辑
摘要:78. 子集 class Solution { public: void dfs(vector<int>& nums, vector<int> &cur, int index){ if(index > num_len) return; result.push_back(cur); for(int i 阅读全文
posted @ 2022-03-01 16:45 fwx 阅读(21) 评论(0) 推荐(0) 编辑
摘要:组合总和 class Solution { public: void dfs(vector<int>& candidates, vector<int> &cur, int index, int sum){ if(sum == target) result.push_back(cur); else{ 阅读全文
posted @ 2022-03-01 16:41 fwx 阅读(21) 评论(0) 推荐(0) 编辑
摘要:未优化剪枝版: class Solution { public: void dfs(vector<bool> &record, vector<int> &cur, int index){ if(cur.size() == kk) result.emplace_back(cur); else{ for 阅读全文
posted @ 2022-03-01 16:27 fwx 阅读(8) 评论(0) 推荐(0) 编辑
摘要:注意是对原数组进行交换!!! class Solution { public: void dfs(vector<int>& nums, int index){ if(index == num_len){ result.push_back(nums); return; } for(int i=inde 阅读全文
posted @ 2022-03-01 16:24 fwx 阅读(20) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: bool is_get(int x, int y){ if(x >= 0 && x < len_x && y >= 0 && y < len_y) return true; return false; } int dfs(vector<vector< 阅读全文
posted @ 2022-03-01 14:15 fwx 阅读(12) 评论(0) 推荐(0) 编辑
摘要:无脑深搜两次,一次判断是否位于内部,一次变‘X’ class Solution { public: bool is_inside(int x, int y){ if (x > 0 && x < len_x - 1 && y > 0 && y < len_y - 1) return true; ret 阅读全文
posted @ 2022-03-01 14:00 fwx 阅读(17) 评论(0) 推荐(0) 编辑
摘要:就开心愉快的dfs即可~ class Solution { public: int get_record(int *record, int x, int y){ return record[x * len_y + y]; } void set_record(int *record, int x, i 阅读全文
posted @ 2022-03-01 13:54 fwx 阅读(19) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: bool is_cross(string &word1, string &word2){ bool flag = true; for(int i=0;i<word_length;++i) if(word1[i] != word2[i]) if(fla 阅读全文
posted @ 2022-03-01 13:52 fwx 阅读(24) 评论(0) 推荐(1) 编辑
摘要:和路径权重的最短路径有些类似,可以用相同的方式做。 class Solution { public: int numSquares(int n) { queue<int> n_q; int dp[n+1]; bool is_go[n+1]; for(int i=1;i<=n;++i) { dp[i] 阅读全文
posted @ 2022-03-01 13:21 fwx 阅读(21) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: void bfs(vector<vector<int>>& grid){ record[0][0] = 1; p_q.push(make_pair(0,0)); int cur_x, cur_y; int len_x = grid.size(); i 阅读全文
posted @ 2022-03-01 12:47 fwx 阅读(20) 评论(0) 推荐(0) 编辑
摘要:思路:dfs, 然后用map记录每个数字对应的树,以优化搜索。 map中key为自定义数据结构时,使用仿函数来添加键的比较方式。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *l 阅读全文
posted @ 2022-03-01 12:19 fwx 阅读(54) 评论(0) 推荐(0) 编辑
摘要:用运算符作为分割,对两边的表达式进行求值,分而治之; class Solution { public: int calc(int left, int right, char op){ switch (op){ case '+': return left + right; case '-': retu 阅读全文
posted @ 2022-03-01 11:59 fwx 阅读(21) 评论(0) 推荐(0) 编辑
摘要:思路:记录字符串s中每个字母出现的最右边的位置(如果要记录左侧位置,则需要排序,这里可以不用),然后遍历字符串,记录left和right两个下标, left:区间的左边界; right:区间的右边界; 如果当前遍历的字符的最右边位置大于等于右边界,则更新右边界,如果当前遍历的下标大于右边界,则将le 阅读全文
posted @ 2022-03-01 11:50 fwx 阅读(28) 评论(0) 推荐(0) 编辑
摘要:身高 h 降序、个数 k 值升序,然后将某个学生插入队列的第 k 个位置中。 class Solution { public: vector<vector<int>> reconstructQueue(vector<vector<int>>& people) { sort(people.begin( 阅读全文
posted @ 2022-03-01 11:39 fwx 阅读(19) 评论(0) 推荐(0) 编辑

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