Recent

Author Topic: External: SIGSEGV error when using quicksort  (Read 2951 times)

pashbrown

  • New Member
  • *
  • Posts: 25
External: SIGSEGV error when using quicksort
« on: November 23, 2012, 01:25:55 pm »
Code: [Select]
Procedure TForm1.Quicksort(var NumberArray:TNumberList; first:integer; last:integer);
var
  PivotValue,right,temp:integer;
  left2:integer;
begin
  first:=1;
  last:=max;
  If First<Last then
  begin
    PivotValue:=NumberArray[first];
    Left2:=First+1;
    Right:=Last;
    While Left2<=Right do
    begin
      While (NumberArray[left2]<PivotValue) and (Left2<=Right) do
      begin
        Left2:=Left2+1;
      end;
      While (NumberArray[Right]>PivotValue) and (left2<=right) do
      begin
        right:=right-1;
      end;
      if left2<right then
      begin
        Temp:=NumberArray[right];
        NumberArray[right]:=NumberArray[left2];
        NumberArray[Left2]:=temp;
      end;
    end;
    PivotValue:=Right;
    Temp:=NumberArray[first];
    NumberArray[first]:=NumberArray[PivotValue];
    NumberArray[PivotValue]:=temp;
    QuickSort(NumberArray,First,PivotValue-1);
    Quicksort(NumberArray,PivotValue+1,Last);
  end;
  ArrayToStringGrid;
end;

Here is my code for a quicksort, when i click the button i get the error 'External: SIGSEGV'. Please help :)
Cruse™ Powered

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: External: SIGSEGV error when using quicksort
« Reply #1 on: November 23, 2012, 01:44:13 pm »
Try stepping through the code with a debugger.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

LEEANN

  • Newbie
  • Posts: 1
    • abercrombie france
Re: External: SIGSEGV error when using quicksort
« Reply #2 on: November 24, 2012, 09:05:19 am »
it is a big bug for this

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: External: SIGSEGV error when using quicksort
« Reply #3 on: November 24, 2012, 09:16:21 am »
Quote
it is a big bug for this
yes, a big bug from the coder, for not defining TNumberList and use debugger for debugging and simply ask other people to debug his/her whole code.

 

TinyPortal © 2005-2018