Explain the flow of the code (Do not use flowchart). See attached photo for the problem. (This is not graded) bool add(entry* e) { if(s->contains(e->country) == true) { return false; } int i; for (i = 0; i < index; i++) { entry* existing = array + (i * sizeof(entry)); // 0 + 0 * 5 = 0 if(e->compare(existing)) { break; } }
Explain the flow of the code (Do not use flowchart). See attached photo for the problem. (This is not graded) bool add(entry* e) { if(s->contains(e->country) == true) { return false; } int i; for (i = 0; i < index; i++) { entry* existing = array + (i * sizeof(entry)); // 0 + 0 * 5 = 0 if(e->compare(existing)) { break; } }
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Explain the flow of the code (Do not use flowchart). See attached photo for the problem. (This is not graded)
bool add(entry* e) {
if(s->contains(e->country) == true)
{
return false;
}
int i;
for (i = 0; i < index; i++) {
entry* existing = array + (i * sizeof(entry)); // 0 + 0 * 5 = 0
if(e->compare(existing))
{
break;
}
}
for (int j = index; j >= i; j--) {
*(array + ( sizeof(entry) * (j) ) ) = *(array + ( sizeof(entry) * (j - 1) ) );
}
*(array + ( sizeof(entry) * i ) ) = *e;
if(index < 5)
{
index++;
}
if(( sizeof(entry) * i ) < ( sizeof(entry) * 5 ))
{
return true;
}
else
{
return false;
}
}
entry* get(int pos) {
return array + (sizeof(entry) * (pos-1) );
}
bool ban_indefinitely(entry* e) {
if(s->contains(e->country) == false)
{
s->add(e);
}
int temp = index;
for (int i = 0; i < index; i++) {
entry* existing = array + (sizeof(entry) * i);
if (!strcmp(existing->country, e->country)) {
for (int j = i; j < index - 1; j++) {
*(array + ( sizeof(entry) * (j) ) ) = *(array + ( sizeof(entry) * (j+1) ) );
}
index--;
i--;
}
}
if(temp != index)
{
return true;
}
return false;
}
bool unban(const char* nation) {
if(s->contains(nation) == true)
{
s->remove(nation);
return true;
}
return false;
}
![• bool add(entry* e)
Improve the add method where you will return true if the entry
has been successfully added (i.e. the entry is placed in the top
5), otherwise return false (i.e. if the entry did not make it to the
top 5 or this entry's nation has been banned).
Implement the following additional methods and make sure you
utilize the methods of the StringList field:
• bool ban_indefinitely(entry* e)
Removes all the entries in your BoardArray bearing the country
equal to the country of the given entry and also restricts future
additions bearing this country from ever being added by adding
this to the banned list. Return true if at least one entry has
been removed, otherwise return false.
• bool unban(const char* nation)
Unbans the said nation by removing it from the banned list.
Return true if the nation once exists in the banned list,
otherwise return false.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2cb11186-80ff-4474-bc75-6eff69002743%2Fa9deed7c-f936-402f-8eea-46955b4d19ce%2Ftsg0878_processed.png&w=3840&q=75)
Transcribed Image Text:• bool add(entry* e)
Improve the add method where you will return true if the entry
has been successfully added (i.e. the entry is placed in the top
5), otherwise return false (i.e. if the entry did not make it to the
top 5 or this entry's nation has been banned).
Implement the following additional methods and make sure you
utilize the methods of the StringList field:
• bool ban_indefinitely(entry* e)
Removes all the entries in your BoardArray bearing the country
equal to the country of the given entry and also restricts future
additions bearing this country from ever being added by adding
this to the banned list. Return true if at least one entry has
been removed, otherwise return false.
• bool unban(const char* nation)
Unbans the said nation by removing it from the banned list.
Return true if the nation once exists in the banned list,
otherwise return false.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY