🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: csu.cs.200
Article #168

Re: help with sort.h

#168
From: Michael Szczepaniak
Date: Tue, 15 Sep 1998 00:00
27 lines
1802 bytes
Before playing with what I explain below, go through and make sure you know
exactly how the original SelSort function works.

In the original Sort.h function, i, j, and index are used to index array
items.  Even though nodes in an SLL are not numbered, you can pump i, j, and
index into your "Find Node N" function (see 9/8/98 class notes) and have the
function return a pointer that points to the ith, or jth etc. node.

In the if-statement, you'll be comparing last names so you'll need the strcmp
function (in the <strings.h> header file) to be able to tell which last name
comes after which.  Based on this test, you either update next or not.

When it's time for the swap, I used the dummy node as the temporary swap space
(analogous to the "hold" variable).

Someone please comment if this is appropriately "high level" enough or too
detailed!  This all worked for me.  You'll have the most fun with the output
function(s)!!!  Hope this helped.

Michael Szczepaniak

Chris Vaughn-Uding wrote:

> I'm kind of at a loss on how to modify the sort function. Anyone have some
> advice on how to substitute the name fields into the array positions.
>
> Chris Vaughn
Technical Details
Message-ID: <35FF32A8.8B105C9D@earthlink.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6tna64$83b8@yuma.ACNS.ColoState.EDU>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 127144,5a4956090ae5ec48
X-Google-Attributes: gid127144,public
From: Michael Szczepaniak <mszczepaniak@earthlink.net>
Subject: Re: help with sort.h
Date: 1998/09/15
Message-ID: <35FF32A8.8B105C9D@earthlink.net>
X-Deja-AN: 391582434
Content-Transfer-Encoding: 7bit
References: <6tna64$83b8@yuma.ACNS.ColoState.EDU>
X-Posted-Path-Was: not-for-mail
Content-Type: text/plain; charset=us-ascii
X-ELN-Date: Tue Sep 15 20:33:33 1998
Organization: Eclectic systems
Mime-Version: 1.0
Reply-To: mszczepaniak@earthlink.net
Newsgroups: csu.cs.200