Solution:First part:Insertationof binary tree can be implemented in next way:
void insertBTree
(Node
*ptr
, Data data
) { if (ptr
== NULL) { ptr
= new Node
; ptr
->data
= data
; } else if (data
< ptr
->data
) insertBTree
(ptr
->left
, data
); else insertBTree
(ptr
->right
, data
);}Second part:Code.#include <iostream>
#include <cstdio>
#include <string>
#define MAX_NUM 10
using namespace std
; int main
() { stringname
[MAX_NUM
]; int numberOfVotes
[MAX_NUM
]; int num
; // the number of candidates
int total
= 0
; // total number of votes
int winner
= 0
; // Input
cout
<< "Enter number ofcandidates: "
; cin
>> num
; cout
<< "Entercandidates:\n"
; for (int i
= 0
; i
< num
; i
++) { cin
>> name
[i
] >> numberOfVotes
[i
]; // Compute total numberof votes
total
+= numberOfVotes
[i
]; // Determine winner
if (numberOfVotes
[i
] > numberOfVotes
[winner
]) { winner
= i
; } } // Output
printf
("ss s\n"
, "Candidate"
, "VotesRecieved"
, "% of TotalVotes"
); for (int i
= 0
; i
< num
; i
++) { printf
("sd .2f\n"
, name
[i
].c_str
(), numberOfVotes
[i
], (float
) numberOfVotes
[i
] * 100
/ total
); } printf
("Total %d\n"
, total
); printf
("The winner of theelection is %s"
,name
[winner
].c_str
()); return 0
;}Sample run.Enter number of candidates: 5
Enter candidates:
Johnson 6000
Miller 7000
Duffy 8000
Robinson 3000
Sam 2000
Candidate Votes Recieved % of Total Votes
Johnson 6000 23.08
Miller 7000 26.92
Duffy 8000 30.77
Robinson 3000 11.54
Sam 2000 7.69
Total 26000
The winner of the election is Duffy