Phone Book Directory
Monday, 21 April 2014
Gosh.
Thank gosh I'm done. I spent so much time on that program LOL. Anyway, all the problems that I encountered are in the problems and solutions page.
Sunday, 13 April 2014
Nearly done.
I'm (obviously) not done yet - I still have quite a few holes to fix up, but I've finished most of what I need to get today. Tomorrow, I'll get up bright 'n early to read post colonialism and finish up the rest of the program. I think I'll go early and visit Ryk just to get all my questions answered. As if it's not last minute enough. gosh, i really hate handing programs in so late (or even writing them so late).
I have tomorrow morning put aside for computer science and english, tomorrow night for computer science and advanced functions. And then Tuesday morning for studying for comp sci test on Wednesday, and most likely the whole SES thing going on. Gosh, as if it wasn't hectic enough this is crazy!
I'm going to ask Ryk if I can hand in my program on Tuesday, that way I can use my spare(s).
I have tomorrow morning put aside for computer science and english, tomorrow night for computer science and advanced functions. And then Tuesday morning for studying for comp sci test on Wednesday, and most likely the whole SES thing going on. Gosh, as if it wasn't hectic enough this is crazy!
I'm going to ask Ryk if I can hand in my program on Tuesday, that way I can use my spare(s).
Okay..
I guess I forgot to update the stuff yesterday, but oh my..this assignment is so stressful.
Well more like..my life is really stressful right now, so I just uh...computer science is adding to this. I thought I would be done the Mahjong by now (I like to have my assignments done in advance..). But a whole bunch 'o tests and stuff came up, so I'm here programming last minute (and I hate it).
Anyway, I did quite a bit yesterday. Here's just a few things:
Well more like..my life is really stressful right now, so I just uh...computer science is adding to this. I thought I would be done the Mahjong by now (I like to have my assignments done in advance..). But a whole bunch 'o tests and stuff came up, so I'm here programming last minute (and I hate it).
Anyway, I did quite a bit yesterday. Here's just a few things:
- Created the menu asking the user whether they want to use a directory from a certain text file (and for them to provide a name for it - still haven't programmed that bit, but it shouldn't be too hard).
- Created a menu asking the user whether they want to insert/add, delete, edit, search, print or exist the program.
- I have methods for the insert, delete, and search, but I'm still rather confused about them because in the notes, there were 2 versions of it - one in the tree class to test whether the tree is empty, and if it isn't, it kicks off the recursive one in the node class (that makes sense). The thing I'm confused about is how to print it in preorder because all the code is in inorder right now.
- I'm pretty sure it's the same thing, but it starts at the root and then goes to the left and then the right. But this is the thing that's confusing the heck out of me.
- My goal for now is to complete everything but the preorder because the changing to preorder is a matter of changing one or two pieces of code - ish in the recursion.
I'll get on those other things now :P
Thursday, 10 April 2014
Alternative Assignment
Write a program that contains a set of routines for manipulating a personal phone directory. The directory should be maintained as a binary search tree with each node containing a reference to an object containing fields for a family name, given name, address and telephone number. The tree’s node should be ordered using family names as keys. If there are entries with identical family names, given names should be as a secondary keys. No entries will have identical family and given names.
The program should be menu driven with the user being offered a choice of 6 commands:
- Insert
- Delete
- Edit
- Search
- Exit and give choice of print.
I'm currently thinking about the logistics of programming it, and I think it can be in the console window - it shouldn't matter all that much. Here are the things that might be important:
- Inserting the Entry
- Console Window asking
- Other List Class
- First Name
- Last Name
- Address
- Telephone
- Left Child
- Right Child
- There are examples of inorder in the examples, so I can flip it around and do preorder.
- Family Names
- This is how they are organized in the tree.
- If alphabetically, the thing goes before the given name, add it to the left. If not, add it to the right.
Here's the criteria for the assignment:
Criteria
|
Application:
|
You use reusable classes and methods AND reuse them. Well, I'm going to be calling methods back and forth and be reusing the set and gets.
|
Thinking & Inquiry:
|
Your program runs correctly. Test for invalid or incorrect input. Oh. Uh. Well I'll handle that when I'm done?
|
Dynamic Data Structures in My Program:
I'm using binary search trees in my program. It's a phone directory that is sorted by one's given name (last name). In the notes, this would be known as the "key." If the user decides to start fresh (new directory), the first thing that they enter will be the root. Then, when they go to enter something else, the insert method (the recursive one) will go through the left or right subtree depending on whether it is before the root or after the given name of the root (if it is before, it goes to the left subtree; if it is after, it goes to the right subtree). If the user decides to use a preexisting directory that was printed using this program, it will read in all the information in preorder (root, left subtree, then right subtree). The create method (which I have yet to write) will end up creating a binary search tree using this information. The only problem with this is that we can't exactly "delete" notes from a tree, it's just a matter of setting a boolean in that node to be false, and so if it is set to false, the program won't save it (not printing it to the file).
Differences Between Different Dynamic Data Structure Types and Why I Chose Binary Search Trees:
I'm currently using binary search trees in my program because it said I had to use them for the assignment. But in reality, if given the choice, I would've have used linked lists. I understand linked lists much better because of the different nodes and whatnot, but I don't fully understand binary search trees because linked lists just make more sense in my head. I guess binary search trees have their pros and cons; pros being that it separates alphabetically the left and right subtree (anything alphabetically before the root is on the left subtree while anything alphabetically after is on the right subtree). But then there is a problem (or two) with binary search trees because you can't quite delete a node - you can have a boolean that determines whether it is deleted or not (false if not; true if it is) and then just not end up saving it (so it'll be pointing to null next time you open the directory). With linked lists, I think it would be much easier to delete an item (since I already have the method written for the mahjong program, and the 3-way switch makes a lot more sense in my head) versus just setting a boolean true or false. I could have used a stack, but it doesn't really apply to the phone book program because if I wanted to delete an entry given a certain name, I wouldn't be able to take it out otherwise the stack would "fall over" (imagining a stack of books here). But in reality, I can't actually delete it, and I can't exactly organize it alphabetically either. And it is the same with with queues, it wouldn't be helpful in this program because FIFO applies, and the phone book contacts don't want to be disappearing in the order that the user enters it.
Subscribe to:
Comments (Atom)