Description
The purpose of this challenge is to implement an MRU (Most Recently Used list) using a linked list as a backing data structure
Requirements
The MRU (Most Recently Used) list is a very common ADT used in various software applications. They’re very frequently used to show the most Recent Files in menus.
A Recent Files list in Microsoft Word, for example, would look like this:
- Term Paper
- Class Notes
- Document1
- Resume
- Loan Application
If you select the Class Notes document, it will be opened in Word. When you close it and return to the Recent Files list, it will look like this:
- Class Notes
- Term Paper
- Document1
- Resume
- Loan Application
If you now select the Resume document, it will be opened in Word. When you close it and return to the Recent Files list, it will look like this:
- Resume
- Class Notes
- Term Paper
- Document1
- Loan Application
Whatever is selected becomes the first item in the list. If the top is selected, nothing changes. If a new document is created or opened that is not in the list, it gets added to the top.
Using a linked list, implement the above behavior as described below. When your program runs:
- Ask the user to enter a string
- If this string is already in the list, don’t add it. Instead, find its current location in the list and make it the front of the list (head)
- If the string is not already in the list, add it to the front of the list (head)
- After any additions or repositions, show the list, with the new arrangement
- You may use an infinite loop in main or watch for the entry of a special string such as “quit” to make the program stop asking
- You can write as many functions or variables as needed
CATALOG ID: CPP-CHAL00052