Thread View: csu.cs.200
3 messages
3 total messages
Started by Chris Vaughn-Uding
Tue, 15 Sep 1998 00:00
help with sort.h
Author: Chris Vaughn-Uding
Date: Tue, 15 Sep 1998 00:00
Date: Tue, 15 Sep 1998 00:00
4 lines
613 bytes
613 bytes
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
Re: help with sort.h
Author: Michael Szczepaniak
Date: Tue, 15 Sep 1998 00:00
Date: Tue, 15 Sep 1998 00:00
27 lines
1802 bytes
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
Re: help with sort.h
Author: Michael Szczepaniak
Date: Tue, 15 Sep 1998 00:00
Date: Tue, 15 Sep 1998 00:00
40 lines
2173 bytes
2173 bytes
One small correction: The last line in the 3rd paragraph read: "...Based on this test, you either update next or not...." It should have read "Based on this test, you either update index or not." Sorry if this caused any confusion, Michael Sz. Michael Szczepaniak wrote: > 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads