Project 2 - A Text Editor/Analyzer

Due - Thursday, April 20, 2006

The goal of this project is to give you experience using linked lists and recursion. You will write a program that stores a phrase as a linked list of strings. Your program will allow the user to perform the following editing operations:
  1. Insert a word
  2. Remove a word
  3. Move cursor forward 1 word
  4. Move cursor back 1 word
  5. Reverse the phrase
  6. Recursively count the number of repeated occurrences of a word
  7. Search and replace

Implementation Requirements and Hints

  1. Your user interface will have a main control loop that will (1) allow the user to select an operation, (2) perform the operation, and (3) print the resulting phrase.
  2. You will extend your LinkedList implementation to include a cursor. The cursor is simply a pointer to a particular node in the list. If the user asks to move the cursor forward, the pointer will advance to the next node in the list; if the user asks to move the cursor backward it will retreat to the previous node in the list.
  3. You will need to modify your LinkedList print function to indicate the location of the cursor. For example, you might print "cs is^ fun" to indicate that the cursor is on the string "is".
  4. If the user chooses to perform an insert, the new word should be inserted immediately after the node indicated by the cursor. If the user chooses to perform a delete, the node indicated by the cursor should be deleted.
  5. Using a singly linked list, the move cursor backward operation will have O(n) complexity. That's okay, but consider doing the extra credit portion!
  6. You do not need to reverse the phrase letter-by-letter. For example, reversing the phrase "cs is fun" would yield "fun is cs".
  7. The search and replace operation will ask for the search string and the replace string. It will then replace all instances of the search string with the replace string.
  8. Make sure to handle all special cases, for example the case when the user tries to advance a cursor that is already at the last node of the list.

Extra Credit Opportunity

For extra credit, implement and use a doubly linked list for this assignment rather than the singly linked list. Note that the doubly linked list will actually make some of the operations easier to implement.

Due 2:40PM Thursday April 20, 2006

  1. Complete and submit your working code.
  2. Make sure that each function is well documented. Your documentation should specify the type and function of the input parameters and output.
  3. Run your program on a variety of inputs ensuring that all error conditions are handled correctly.
Note: No portion of your code may be copied from any other source including another text book, a web page, or another student (current or former). You must provide citations for any sources you have used in designing and implementing your program.
Sami Rollins