Starting from:
$30

$24

Data Structures Assignment-4 Solution

PART-I




You are asked to write a simple C++ phonebook application program. Here are the requirements for the application.

User shall add a new contact with name and phone information



User shall load contacts from a file



Each line of the input line includes name and phone information of a contact. o A sample input file is given as an example (phonebook.txt)



o User shall load contacts from many files




User shall print the contacts in ascending order



User shall search for a contact with name



User shall list contacts before a particular contact. The resulting list will include all the contacts come before the given contact.



Application is required to structure data using Binary Search Tree.



A sample run:




***MY PHONEBOOK APPLICATION***




Please choose an operation:

A(Add) | L (Load) | S(Search) | P(Print) |F(Filter) |Q(Quit): A




Enter name: MARY SMITH

Enter phone: 5062396




A(Add) | L (Load) | S(Search) | P(Print) |F(Filter) |Q(Quit): A




Enter file name: phonebook1.txt




A(Add) | L (Load) | S(Search) | P(Print) |F(Filter) |Q(Quit): P




BARBARA BROWN :4059171




ELIZABETH JONES :2736877




JENNIFER MILLER :3863726




LINDA WILLIAMS :3532665




MARGARET RODRIGUEZ :350662




MARIA ANDERSON :2211086




MARIA DAVIS :6297086




MARIA SMITH :2211086




MARY SMITH :5062396




PATRICIA JOHNSON :973437




SUSAN GARCIA :6063076




11 contacts...




//The content of phonebook1.txt is given below.




PATRICIA JOHNSON 973437




LINDA WILLIAMS 3532665




BARBARA BROWN 4059171




ELIZABETH JONES 2736877




JENNIFER MILLER 3863726




MARIA DAVIS 6297086




MARIA SMITH 2211086




MARIA ANDERSON 2211086




SUSAN GARCIA 6063076




MARGARET RODRIGUEZ 350662






A(Add) | L (Load) | S(Search) | P(Print) |F(Filter) |Q(Quit): S




Enter name: MARY SMITH

Phone: 5062396





A(Add) | L (Load) | S(Search) | P(Print) |F(Filter) |Q(Quit): F




Enter name: MARIA DAVIS




BARBARA BROWN :4059171




ELIZABETH JONES :2736877




JENNIFER MILLER :3863726




LINDA WILLIAMS :3532665




MARGARET RODRIGUEZ :350662




MARIA ANDERSON :2211086




6 contacts….




A(Add) | S (Search) | D(Delete) |L(List) |Q(Quit): Q Bye




PART- II




In assignment-1, you are asked to implement a similar phone book application, but you were not supposed to use Binary Search Tree. Let’s compare the performance of search operations in both solutions.



Perform a simple search operation with your solution in assignment-1, record the time



Perform a search for the same contact searched in (a) and record the time



Please compare your results.






Hint: you can record the execution time using the following code segment.




#include <ctime




void calculateElapseTime() {




using namespace std;

clock_t begin = clock();




//code_to_time




clock_t end = clock();




double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;

}

Part-I Submission:

Please follow the following steps for each assignment:




Create a separate repository in GitHub



Clone the repository to your local computer.
Modify the files and commit changes to complete your solution in your local repository.



Push/sync the changes up to GitHub.
To turn in the assignment, send the link for the repository as an email to your instructor (fatma.serce@..)



Part-II Submission:

Please upload your answer as a text file to canvas for assignment-4.





More products