Quick-Sort && Stack Quick-Sort(快速) 12345678910111213 PARTITION(A,p,r)x=A[r]r=p-1for(j=p; j<r; j++){ if(A[j]<=x) { i++ exchange A[i] with A[j] } } exchange A[i+1] with A[r]return i+1 Stack(栈) 12345678910111213141516171819 Stack-Empty(s) (置空)if(s.top==0){ return True}else return FalsePush(s,x) (进栈)s[s.top++]=xPop(s) (出栈)if(Stack-Empty(s)){ error "underflow"}else s.top--return s.[s.top++] 赞微海报分享
近期评论