comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Shell Sort
Date: Sat, 10 Jul 2010 09:17:19 -0700 (PDT)
Date: 2010-07-10T09:17:19-07:00	[thread overview]
Message-ID: <609b718c-aede-4696-aaab-4106d277c0a0@e5g2000yqn.googlegroups.com> (raw)
In-Reply-To: a7c61cc8-a961-4406-89b3-a0c82e26e443@g19g2000yqc.googlegroups.com

Never mind, I fixed it.

   Procedure Sort( Input : in out ARR ) is
      Gaps : constant array(Positive Range <>) of Integer:=
           (1, 4, 10, 23, 57, 132, 301, 701, 1750);

      Initial_Gap_Index : Integer;
   begin
      If Input'Length > 1 then

         For Index in reverse Gaps'Range loop
            Initial_Gap_Index:= Index;
            exit when Gaps(Initial_Gap_Index) < Input'Length;
         end loop;

         For GapIndex in reverse Gaps'First..Initial_Gap_Index loop
            Insertion:
            declare
               Inc	: Integer:= Gaps(GapIndex);
               Next	: Integer;
               Done	: Boolean;
            begin
               while True loop
                  Done:= True;
                  For Index in Input'First..Input'Last-Inc loop	--
First Element
                     Next:= Index + Inc;			-- Next Element
                     if Input(Next) < Input(Index) then
                        Swap(Input, Index, Next);		-- Not finished
                        Done:= False;				-- ...keep goin`
                     end if;
                  end loop;
                  Exit When Done;
               end loop;
            end Insertion;
         end loop;
      end if;
   end Sort;



      reply	other threads:[~2010-07-10 16:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-09 17:28 Shell Sort Shark8
2010-07-10 16:17 ` Shark8 [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox