随笔分类 -  数据结构

摘要:#include <stdio.h> #include <stdlib.h> #include <string.h> /** * 字典树 * 1、根节点(Root)不包含字符,除根节点外的每一个节点都仅包含一个字符; * 2、从根节点到某一节点路径上所经过的字符连接起来,即为该节点对应的字符串; * 阅读全文
posted @ 2022-05-04 16:58 bug_killer 阅读(189) 评论(0) 推荐(0)
摘要:1 /** 2 约瑟夫环:借助数组 3 len: 表示人数 4 target: 表示喊到该口号的出局。 5 flag: 表示当前哥们喊的口号 范围【1,2,3】 6 default: 从1开始数 7 **/ 8 int YSF(int len,int target,int start){ 9 int 阅读全文
posted @ 2021-11-06 12:59 bug_killer 阅读(58) 评论(0) 推荐(0)
摘要:package 分而治之; import utils.Utils; public class 数组最大子序列和 { //time O(n^3) space O(1) public static int getMaxSumOfSequence01(int[] a){ int maxsofar = 0; 阅读全文
posted @ 2021-03-26 09:42 bug_killer 阅读(94) 评论(0) 推荐(0)
摘要:四个条件 1.循环等待 2.请求与占有 3.不可抢占 4.互斥 处理策略 鸵鸟策略 : 不理不睬 乐观态度 死锁检测与死锁恢复 检测有向图是否有环,可以用深度优先或者拓扑排序 死锁恢复 利用抢占恢复 利用回滚恢复 通过杀死进程恢复 死锁预防 破坏四个条件 死锁避免 银行家算法 阅读全文
posted @ 2021-03-15 10:40 bug_killer 阅读(77) 评论(0) 推荐(0)
摘要:#include <stdio.h> //数组当中只出现一次的那个数 int getSingle(int* arr,int len){ int single = 0,i; if(len == 1) return *arr; for(i=0;i<len;i++) single ^= arr[i]; r 阅读全文
posted @ 2020-04-03 12:15 bug_killer 阅读(181) 评论(0) 推荐(0)
摘要:#include "head.h" int* mergeTwoSeqArr(int* a,int la,int* b,int lb){ int i = 0,j=0; int *stack = (int*)malloc(sizeof(int)*(la+lb)); int top = 0; while(i<la&&j<lb){ if(a[i]<=b[j]){ stack[top++] = a[i++] 阅读全文
posted @ 2019-09-26 16:51 bug_killer 阅读(200) 评论(0) 推荐(0)
摘要:package 二叉树; import java.util.*; public class 二叉树根到叶子节点的路径和 { public static TreeNode root; public static Set<List<Integer>> set = new HashSet<>(); public static List<Integer> list = new ArrayList<>(); 阅读全文
posted @ 2019-09-24 21:59 bug_killer 阅读(1419) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-05-28 13:09 bug_killer 阅读(1033) 评论(0) 推荐(0)
摘要:struct ListNode* oddEvenList(struct ListNode* head) { if(head==NULL || head->next==NULL) return head; struct ListNode *odd = head; struct ListNode *even = head->next,*even_head = even; ... 阅读全文
posted @ 2019-04-16 13:13 bug_killer 阅读(128) 评论(0) 推荐(0)
摘要:void InsertSort(struct ListNode* L){ struct ListNode *p = L->next,*pre=NULL; struct ListNode *r = p->next; p->next = NULL; p = r; while(p!=NULL){ r = p->next; pre ... 阅读全文
posted @ 2019-04-16 12:24 bug_killer 阅读(306) 评论(0) 推荐(0)
摘要://采用不带头结点的链表 非递归实现 public static ListNode merge(ListNode list1,ListNode list2){ if(list1==null) return list2; else if(list2==null) return list1; ListNode newHead=null; ListNode tmp=null; ... 阅读全文
posted @ 2019-04-12 14:32 bug_killer 阅读(1064) 评论(0) 推荐(0)
摘要:package problem.回溯; public class EightQueue { public static int max = 8,sum = 0; public static int[] queen = new int[max]; //存储列元素值 //皇后元素形式:(i,queue[i]) public void displayQue... 阅读全文
posted @ 2019-04-11 10:30 bug_killer 阅读(263) 评论(0) 推荐(0)
摘要:package 排序; import common.Utils; public class HeapSort { public static void Adjust(int[] arr,int startIndex,int len){ int childIndex = 0; int threshold = len-1; for(;2*... 阅读全文
posted @ 2019-04-11 10:28 bug_killer 阅读(364) 评论(0) 推荐(0)