1326 - DS_2017fall_Quiz2 Scoreboard

Time

2017/11/08 18:50:00 2017/11/08 19:50:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11651 DS_2017fall_Quiz2

11651 - DS_2017fall_Quiz2   

Description

There are three step you have to complete:

step1: Implement two linked list of integers by using function below.
(each integer would be a node and integers range from 0 to 99)

(1)InsertBack (int data)  :Insert a data to the end of the linked list
e.g. A->B → InsertBack (C) → A->B->C

(2)InsertAfter (int data1, int data2)  :Insert data2 after data1
If data1 doesn’t exist in the linked list, do nothing
e.g. A->C → InsertAfter (A, B) → A->B->C
e.g. A->C → InsertAfter (D, B) → A->C

(3)Delete (int data) :Remove the data from the linked list
If data doesn’t exist in the linked list, do nothing
e.g. A->B->C → Delete (B) → A->C
e.g. A->B->C → Delete (Y) → A->B->C

(4)Reverse () :Reverse the linked list
e.g. A->B->C → Reverse () → C->B->A

step2: Add two linked list together.

example:
linked list 1: 1->2->3
linked list 2: 1->4
"result":       2->6->3

note:
1.Each node is unique, two duplicate integers won’t exist at the same time in same linked list.
2.Different linked list may have same node.

step3: Using function (which you have done before) to rearrange the "result"

Input

You need to deal with the input by yourself.

Input will contain
1.The number of steps first linked list have to do. ex: M
2.Function name and integer (depend on the type of the function) ex: There will be M instructions
3.The number of steps second linked list have to do. ex: N
4.Function name and integer (depend on the type of the function) ex: There will be instructions
5.ADD (remind you to add two linked list together)
6.The number of steps "result" linked list have to do. ex: K
7.Function name and integer (depend on the type of the function) ex: There will be K instructions

eg:

3
InsertBack 1
InsertAfter 1 2
Reverse 
2
InsertBack 2
InsertBack 4
ADD
1
Reverse

Output

Output the result of the linked list of integers:

eg:1->2->4->5

You must print the final result by yourself.

Sample Input  Download

Sample Output  Download

Tags




Discuss