摘要: 解题思路:注意时间复杂度要求是O(n) void MySort( ElementType A[], int N ) { int i; ElementType b[3]= {0}; for(i=0; i<N; i++) { b[A[i]]++; } i=0; while(b[1]--) A[i++]= 阅读全文
posted @ 2020-04-21 15:52 跃鱼 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 解题思路:小顶堆之向上高速+向下调整 void PercolateUp( int p, PriorityQueue H ){ H->Elements[0]=H->Elements[p]; int i; for(i=p/2;i>0;i/=2) { if(H->Elements[0]>=H->Eleme 阅读全文
posted @ 2020-04-21 15:35 跃鱼 阅读(508) 评论(0) 推荐(0) 编辑
摘要: 解题思路:递归判断 int Isomorphic( Tree T1, Tree T2 ) { if(!T1&&!T2) return 1; else if(T1&&!T2) return 0; else if(!T1&&T2) return 0; else { if(T1->Element==T2- 阅读全文
posted @ 2020-04-21 12:39 跃鱼 阅读(348) 评论(0) 推荐(0) 编辑
摘要: 解题思路:计算后缀表达式的值 1、遇到数字入栈 2、遇到符号则出栈计算 3、或栈中仅剩1个数,则栈中值即为所求,否则,错误 ElementType EvalPostfix( char *expr ) { ElementType stack[Max_Expr]; char b[Max_Expr]; i 阅读全文
posted @ 2020-04-21 11:19 跃鱼 阅读(1002) 评论(0) 推荐(0) 编辑