1430 - DS_18_CHEN_HW3 Scoreboard

Time

2018/04/10 12:00:00 2018/04/22 23:59:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11877 List of Christmas gifts (CS2351)

11877 - List of Christmas gifts (CS2351)   

Description

 

Objective

  • Implement a linked list to store Christmas gifts
  • Each node stores a gift and its corresponding price
  • Price is a integer and ranges from 0 to 999
  • Each gift price is unique, two duplicate prices will not exist at the same time

 

Examples
(hat, 150) -> (candy, 250) -> (book, 300)  ok
(hat, 150) -> (candy, 150) -> (book, 300)  incorrect

 


Requirements

You should implement 4 functions below

  • InsertBack(gift, price)
  • InsertAfter(gift, price, priceToInsertAfter)
  • Delete(price)
  • Reverse()


InsertBack(gift, price)
Insert a (gift,price) to the end of the linked list

InsertAfter(gift, price, priceToInsertAfter)
Insert (gift,price) after priceToInsertAfter
If price does not exist in the linked list, do nothing

Delete(price)
Remove the (gift,price) matched price from the linked list
If this price does not exist in the linked list, do nothing

Reverse()
Reverse the linked list

(there are some examples in HW3 slides)

 

Input

Input format:

The last line of input is "End", and we only need to print the result when get the "End".

 

 

 

Output

Print:
First line: Empty or List
Second line: List of gifts and their corresponding prices

  1. Connect with symbols "->".
  2. No space in between.
  3. If it's Empty, only need to print the first line.

 

Output format:

 

 

Sample Input  Download

Sample Output  Download

Tags




Discuss