Grouping_Process_Imp..

Download Report

Transcript Grouping_Process_Imp..

SFTW241
PROGRAMMING LANGUAGES
ARCHITECTURE I
Leader
Secretary
Project Tracker
Web Admin
Liaison
:
:
:
:
:
Peter Wong
Su
Jesse
Nelson
Jacky







Group B3 original Grouping Process Algorithm.
Problems of output result in Group B3’s Algorithm.
Modified idea of Grouping Process.
C program implementation.
Sample output result.
Analysis of our modified version.
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.
2.
3.
4.
5.
6.
7.
Randomly load the information of the four leaders into the leader array.
Load the rest information of the classmates into the MA.
Four leader’s information were loaded into the rest positions of the MA.
Use MA both for information storage and checking.
The pointer: member Counter is the boundary between un-used
information and used information
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.
If all of the choices of a “leader” have already been in used array,
then the corresponding team should stop their grouping.
MEMBER
LIST
YYY
LJQ
LJQ
YYY
WFZH
LJQ
Walter
WFZH
POINTER
GROUP A
YYY
OUTPUT : YYY
LJQ
Next Search : LJQ
WFZH
Walter
MEMBER
LIST
YYY
LJQ
LJQ
YYY
WFZH
LJQ
Walter
WFZH
POINTER
GROUP A
YYY
LJQ
REPLACE
WFZH
Walter
LJQ
YYY
LJQ
WFZH
MEMBER
LIST
YYY
LJQ
WFZH
LJQ
YYY
YYY
WFZH
LJQ
LJQ
Walter
WFZH
Walter
POINTER
GROUP A
LJQ
OUTPUT : LJQ
YYY
LJQ
WFZH
Next Search :
YYY ( NOT FOUND )
LJQ ( HAS USED )
WFZH
MEMBER
LIST
YYY
LJQ
WFZH
LJQ
YYY
YYY
WFZH
LJQ
LJQ
Walter
WFZH
Walter
POINTER
GROUP A
LJQ
WFZH
YYY
LJQ
WFZH
REPLACE
YYY
LJQ
Walter
MEMBER
LIST
YYY
LJQ
WFZH
LJQ
YYY
YYY
WFZH
LJQ
LJQ
Walter
WFZH
Walter
…….
Continue
Searching
POINTER
GROUP A
WFZH
OUTPUT : WFZH
YYY
LJQ
Walter
Next Search :
YYY ( NOT FOUND )
LJQ ( HAS USED )
Walter
•
•
•
•
•
•
•
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
Second Choice
Third Choice
Figure : Students’ record link list
This is the linked list created by the initialization part.
N students
Student Name
First Choice
Peter
Jesse
Nelson
Su
Jacky
Thomas
Jesse
Peter
Tony
Peter
Su
Eva
Second Choice
John
Su
Su
Jesse
Jesse
John
Third Choice
Tom
Jacky
Jacky
Jacky
Peter
Peter
Figure : Groups link list
This is the final grouped list that is created by the main
program. ( Already considered the orphan’s situation )
M Groups
Member 1
Member 2
Member n
Peter
Jesse
Nelson
Su
Tom
Tim
Jacky
Barry
Eva
John
Tony
Kent
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.
/* Input the information from text file */
void Input_Student_File( ) ;
/*Search the student according to the algorithm*/
char* search_student( char *name) ;
/*random select student if choices link is break*/
char* random_student( ) ;
Continue…
Main Procedures of the Program.
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( ) ;
Continue…
Main Procedures of the Program.
/* 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( ) ;
}
}
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.
 Searching by student ID is faster and more efficient than
searching by student Name.
 Extra space is still needed for the resulting group linked list.
 Flexibility in Number of Members and number of groups.
 Very clear in understanding the programming algorithm.
 Good in considering the orphan cases and cycle cases
that they haven’t considered and solved.