> p<-c(3,5,6,7,9,8)
> position<-function(p,left,right)
+ {
+ left=1
+ right=6
+ ch=p[1]
+ while(left<right)
+ {
+ while(p[right]>=ch)
+ {right=right-1}
+ if(left<right)
+ {
+ temp=p[right]
+ p[right]=p[left]
+ p[left]=temp
+
+ }
+ while(p[left]<=ch)
+ {left=left+1}
+ if(left<right)
+ {
+ temp=p[left]
+ p[left]=p[right]
+ p[right]=temp
+ }
+ }
+ p[left]=ch
+ return (left)
+ }
> position(p,1,6)
Error in while (p[right] >= ch) { : argument is of length zero
>