VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 02:06:00 03/20/02 Wed
Author: Hjálmtýr
Subject: Re: shellsort
In reply to: 's message, "shellsort" on 12:57:36 03/19/02 Tue

>Af hverju er deilt með níu í fyrri for lykkjunni í
>program 6.5 bls 286
>for(h = 1; h<=(r-l)/9 ; h = 3 *h+1)
>
>og þá líka afhverju deilirðu með 4 í lausninni á
>verkefni 5 á vikublaði 10

Ástæðan fyrir deilingu með 9 er að forðast það að byrja með fyrsta h-ið of nálægt N (eða r-l). Ef h-gildið er of
nálægt N, þá gerir fyrsta umferðin í Shellröðuninni frekar lítið. Til dæmis ef N = 100 og fyrsta h = 50, þá er verið
að raða 50 hlutlistum, hverjum af stærðinni 2. Sú umferð gefur þá frekar lítið af sér og það væri betra að hafa
fyrsta h-ið lægra. Hversu mikið lægra er ekki augljóst, en í forritinu í bókinni hafa þeir valið að hafa það í mesta
lagi 1/9 af N-inu. Ég ákvað að prófa aðra tölu hjá mér, ég veit ekki hvort hún er betri, en ég hefði líka geta fylgt
bókinni og notað t.d. 9 eða alpha*alpha.

Í öllu falli þá er ekki rangt að fara með h-ið upp að N (eða r-l), en það er örugglega hraðvirkara að byrja aðeins
neðar.

[ Next Thread | Previous Thread | Next Message | Previous Message ]


Replies:


Post a message:
This forum requires an account to post.
[ Create Account ]
[ Login ]
[ Contact Forum Admin ]


Forum timezone: GMT-8
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.