[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: segmentation fault
the quicksort function uses recursion , but is there some terminating condition in it ?
At 8/21/00 8:23:00 AM, you wrote:
>Hai lip,
>I am getting segmentation fault while running the following quicksort program.
>My queries are
>1)what is segmentation fault?
>2)Will it always lead to dumping of core
>I hereby paste the program throwing segmentation fault
>//program starts here
>#include<stdio.h>
>void quicksort(int [],int,int);
>int partition(int [],int,int);
> main()
>{
> int i=10,x[10];
> printf("enter the numbers\n");
> for(i=0;i<10;i++)
> scanf("%d",&x[i]);
> quicksort(x,0,9);
> printf("elements of the array are\n");
> for(i=0;i<10;i++)
> printf("%d",x[i]);
>}
> void quicksort(int x[],int lb,int ub)
>{
> int j;
> j=partition(x,lb,ub);
> quicksort(x,lb,j-1);
> quicksort(x,j+1,ub);
>}
>int partition(int x[],int lb,int ub)
>{
>int t=x[lb];
>int down=lb,up=ub;
>int temp;
>if(lb>=ub)
>return 0;
>while(down<up)
>{
>while(t>=x[down])
>down++;
>while(t<=x[up])
>up--;
>if(down<up)
>{
> temp=x[down];
> x[down]=x[up];
> x[up]=temp;
>}
>}
>temp=x[up];
>x[up]=t;
>x[lb]=temp;
>return up;
>}
>//program ends here
>thanks in advance
>kamesh jayachandran
>
>------------------------------------------------------------
> Get your FREE web-based e-mail and newsgroup access at:
> http://MailAndNews.com
>
> Create a new mailbox, or access your existing IMAP4 or
> POP3 mailbox from anywhere with just a web browser.
>------------------------------------------------------------
>
>
>---------------------------------------------
>Find out more about this and other Linux India
>mailing lists at http://lists.linux-india.org/
>
>
-----------------------------
reply soon
bye
__ deepak __
have a great day
ICQ 30662394
-- Obstacles are what you see when you take your eyes off your goal.