Answer:
The algorithm is as follows:
Step 1: Start
Step 2: Parties = [All delegates in the party]
Step 3: Lent = Count(Parties)
Step 4: Individual = 0
Step 5: Index = 1
Step 6: For I in Lent:
Step 6.1: If Parties[Individual] == Parties[I]:
Step 6.1.1: Index = Index + 1
Step 6.2: Else:
Step 6.2.1 If Index == 0:
Step 6.2.2: Individual = I
Step 6.2.3: Index = 1
Step 7: Else
Step 7.1: Index = Index - 1
Step 8: Print(Party[Individual])
Step 9: Stop
Explanation:
The algorithm begins here
Step 1: Start
This gets the political parties as a list
Step 2: Parties = [All delegates in the party]
This counts the number of delegates i.e. the length of the list
Step 3: Lent = Count(Parties)
This initializes the first individual you come in contact with, to delegate 0 [list index begins from 0]
Step 4: Individual = 0
The next person on the list is set to index 1
Step 5: Index = 1
This begins an iteration
Step 6: For I in Lent:
If Parties[Individual] greets, shakes or smile to Party[i]
Step 6.1: If Parties[Individual] == Parties[I]:
Then they belong to the same party. Increment count by 1
Step 6.1.1: Index = Index + 1
If otherwise
Step 6.2: Else:
This checks if the first person is still in check
Step 6.2.1 If Index == 0:
If yes, the iteration is shifted up
Step 6.2.2: Individual = I
Step 6.2.3: Index = 1
If the first person is not being checked
Step 7: Else
The index is reduced by 1
Step 7.1: Index = Index - 1
This prints the highest occurrence party
Step 8: Print(Party[Individual])
This ends the algorithm
Step 9: Stop
The algorithm, implemented in Python is added as an attachment
<em>Because there is an iteration which performs repetitive operation, the algorithm running time is: O(n) </em>