sftw241 programming languages architecture i leader : peter wong secretary : su project tracker :...

22
SFTW241 PROGRAMMING LANGUAGES ARCHITECTURE I Leader : Peter Wong Secretary : Su Project Tracker : Jesse Web Admin : Nelson Liaison : Jacky

Upload: damon-james

Post on 13-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

SFTW241 PROGRAMMING LANGUAGES

ARCHITECTURE I

Leader : Peter WongSecretary : SuProject Tracker : JesseWeb Admin : NelsonLiaison : Jacky

Group B3 original Grouping Process Algorithm.Group B3 original Grouping Process Algorithm. Problems of output result in Group B3’s Algorithm.Problems of output result in Group B3’s Algorithm. Modified idea of Grouping Process.Modified idea of Grouping Process. C program implementation.C program implementation. Sample output result.Sample output result. Analysis of our modified version.Analysis of our modified version. Advice and Feedback from Group B3.Advice and Feedback from Group B3.

Leader Array : contains 4 strings corresponding to 4 teams.Member Array : which contain 16 strings. (MA)

Programming Algorithm:

1. Randomly load the information of the four leaders into the leader array.2. Load the rest information of the classmates into the MA.3. Four leader’s information were loaded into the rest positions of the MA.4. Use MA both for information storage and checking.5. The pointer: member Counter is the boundary between un-used information and used information6. If a new member is added, then she or he become the new “leader” whose information will be loaded into the LA instead of the older one.7. If all of the choices of a “leader” have already been in used array, then the corresponding team should stop their grouping.

Walter

WFZH

LJQ

YYY

Walter

WFZH

LJQ

YYY

WFZH

LJQ

YYY

LJQ

POINTERGROUP A

MEMBERLIST

OUTPUT : YYY

Next Search : LJQ

WFZH

LJQ

YYY

LJQ

Walter

WFZH

LJQ

YYY

Walter

WFZH

LJQ

YYY

WFZH

LJQ

YYY

LJQ

REPLACE

GROUP A

MEMBERLIST

POINTER

YYY

WFZH

LJQ

YYY

LJQ

Walter

WFZH

LJQ

YYY

WFZH

LJQ

YYY

LJQ

Walter

LJQ

WFZH

GROUP A

MEMBERLIST

POINTER

OUTPUT : LJQ

Next Search : YYY ( NOT FOUND )LJQ ( HAS USED )WFZH

WFZH

LJQ

YYY

LJQ

Walter

WFZH

LJQ

YYY

WFZH

LJQ

YYY

LJQ

Walter

LJQ

YYY

WFZH

REPLACE

GROUP A

MEMBERLIST

POINTER

YYY

Walter

LJQ

WFZH

YYY

Walter

WFZH

LJQ

YYY

WFZH

LJQ

YYY

LJQ

Walter

LJQ

WFZH

Walter

LJQ

YYY

WFZH

GROUP A

MEMBERLIST

POINTER

OUTPUT : WFZH

Next Search : YYY ( NOT FOUND )LJQ ( HAS USED )Walter

…….

ContinueSearching

• They have a fatal error in producing the output result if there is a looping in member choosing. ( Since the preceding member records have been deleted )• The generated result is always remained the same.• The size of the member array is required to define.• The number of groups rendered cannot be modified.• They haven’t consider the situation of the orphan’s case.• They have used extra space for the storage of group members.• A lot of swapping will be performed during the execution of the program. This will become a big problem if the number of student records increase.

Student should give their own favorite members.

First Choice

Third Choice

Second Choice

Figure : Students’ record link list

PeterJesseNelson Su

JackyThomas

JessePeterTony Peter

Su Eva

John Su Su Jesse

Jesse John

TomJackyJacky Jacky

Peter Peter

N students

This is the linked list created by the initialization part.

Student Name First Choice Second Choice Third Choice

Figure : Groups link list

M Groups

PeterJesseNelson Su

Tom Tim Jacky Barry

Eva John Tony Kent

This is the final grouped list that is created by the main program. ( Already considered the orphan’s situation )

Member 1 Member 2 Member n

Continue…

Initialization of the Program.

/* Global Variable */

List Student[student_size] ;

List Group[group_number] ;

int student_selected[student_size] ;

int remain = student_size ;

Continue…

Essential Functions of the Program.

/*Search the student according to the algorithm*/

char* search_student( char *name) ;

/* Input the information from text file */

void Input_Student_File( ) ;

/*random select student if choices link is break*/

char* random_student( ) ;

Main Procedures of the Program.

Continue…

int main( )

{

Input_Student_File( ) ;

/* Randomly select m student for m groups as the headers and insert to the group link list. */

for ( i = 0 ; i < group_number ; i++ )

random_select( ) ;

/* main loop for selecting student */

for (i = 0 ; remain > 0; i++)

{ if ( student is found in record ) search_student( student_name) ;

else if (student link list is break ) random_select( ) ;

else if ( remain < m) then */ random_select_group */

random_select( ) ;

} }

Main Procedures of the Program.

There are 21 student records and 4 groups need to be created.

There are 21 student records and 6 groups need to be created.

• Fixed the fatal error and random problems for their algorithm.• Provide the solution to solve the orphan’s case.• Use the linked list for the member and the grouped list, this is due to the ease of extension and modification of member lists.• We eliminate the swapping part.• We use the index array to store the location of unselected student record list, it decrease the failures in searching.

Better to implement the student ID number in student records.Better to implement the student ID number in student records. Searching by student ID is faster and more efficient thanSearching by student ID is faster and more efficient than

searching by student Name.searching by student Name. Extra space is still needed for the resulting group linked list.Extra space is still needed for the resulting group linked list.

Flexibility in Number of Members and number of groups.Flexibility in Number of Members and number of groups. Very clear in understanding the programming algorithm.Very clear in understanding the programming algorithm. Good in considering the orphan cases and cycle casesGood in considering the orphan cases and cycle cases

that they haven’t considered and solved.that they haven’t considered and solved.