Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么我用快速排序居然会出现Time Limit Exceed, 难道我的排序算法有错????

Posted by 200593141 at 2007-07-12 08:17:59
int partion( int array[], int start, int end )
{
    int temple = array[start] ;

	while( start < end )
	{
	    while( end > start && array[end] >= temple ) end-- ;
		array[start] = array[end] ;
		while( start < end && array[start] <= temple ) start++ ;
		array[end] = array[start] ;
	}

	array[end] = temple ;

	return end ;
}

void QuickSort( int array[], int start, int end ) 
{
   if( start >= end )
	   return ;

   int middle = partion( array, start, end ) ;

   QuickSort( array, start, middle - 1 ) ;
   QuickSort( array, middle + 1, end ) ;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator