随笔分类 - 数据结构
摘要:#include <stdio.h> #include <stdlib.h> #include <string.h> /** * 字典树 * 1、根节点(Root)不包含字符,除根节点外的每一个节点都仅包含一个字符; * 2、从根节点到某一节点路径上所经过的字符连接起来,即为该节点对应的字符串; *
阅读全文
摘要: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
阅读全文
摘要:package 分而治之; import utils.Utils; public class 数组最大子序列和 { //time O(n^3) space O(1) public static int getMaxSumOfSequence01(int[] a){ int maxsofar = 0;
阅读全文
摘要:四个条件 1.循环等待 2.请求与占有 3.不可抢占 4.互斥 处理策略 鸵鸟策略 : 不理不睬 乐观态度 死锁检测与死锁恢复 检测有向图是否有环,可以用深度优先或者拓扑排序 死锁恢复 利用抢占恢复 利用回滚恢复 通过杀死进程恢复 死锁预防 破坏四个条件 死锁避免 银行家算法
阅读全文
摘要:#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
阅读全文
摘要:#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++]
阅读全文
摘要: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<>();
阅读全文
摘要: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; ...
阅读全文
摘要: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 ...
阅读全文
摘要://采用不带头结点的链表 非递归实现 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; ...
阅读全文
摘要: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...
阅读全文
摘要: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*...
阅读全文

浙公网安备 33010602011771号