From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,45ddc3833360d8d8,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g19g2000yqc.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Shell Sort Date: Fri, 9 Jul 2010 10:28:51 -0700 (PDT) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 174.28.205.195 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1278696531 3260 127.0.0.1 (9 Jul 2010 17:28:51 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 9 Jul 2010 17:28:51 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g19g2000yqc.googlegroups.com; posting-host=174.28.205.195; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.10) Gecko/20100504 Firefox/3.5.10 ( .NET CLR 3.5.30729; .NET CLR 4.0.20506),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:12292 Date: 2010-07-09T10:28:51-07:00 List-Id: I'm having some trouble with a Shell Sort I'm writing; I think I screwed up the internal insertion sort. Type ARR is Array (Integer Range <>) of Integer; 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 declare Inc : Integer:= Gaps(GapIndex); Index : Integer; Temp : Integer; begin For Gap_Index in Input'First..Input'Last-Inc loop Index:= Gap_Index; Temp:= Input(Index); while Index+Inc in Input'Range loop if Temp >= Input(Index+Inc) then Swap( Input, Index, Index+Inc ); end if; Index:= Index + Inc; end loop; end loop; end; end loop; end if; end Sort;