Problem: A A class octopus has a dummy head which has four pointers left, right, top and bottom. You have to build link list in these 4 directions depending on the input commands. There will be four types of commands -L, R, T and B. Their specifications are given below: L x: insert x in the left link list Rx: insert x in the right link list Tx: insert x in the top link list Bx: insert x in the bottom link list // Where x is an integer number. Input: Test case will start with a number n indicating the number of lines following it. Output: you have to give output that which link list (Left, Right, Top and Bottom) has maximum sum of values. See the sample input and output.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 1TF
icon
Related questions
icon
Concept explainers
Question
Problem: A
A class octopus has a dummy head which has four pointers – left, right, top and bottom. You have to
build link list in these 4 directions depending on the input commands. There will be four types of commands
- L, R, T and B. Their specifications are given below:
Lx: insert x in the left link list
Rx: insert x in the right link list
T x: insert x in the top link list
// Where x is an integer number.
Bx: insert x in the bottom link list
Input: Test case will start with a number n indicating the number of lines following it.
Output: you have to give output that which link list (Left, Right, Top and Bottom) has maximum sum of
values. See the sampl
and output.
Нead
17
3
13
Sample input
Sample output
Right Link List Has Maximum Sum 32
14
L 3
L 15
L 1
R 17
T 9
T 10
В 13
T 5
R 3
В 2
В З
В 4
∞31 N34
H H M H LR R BBB
Transcribed Image Text:Problem: A A class octopus has a dummy head which has four pointers – left, right, top and bottom. You have to build link list in these 4 directions depending on the input commands. There will be four types of commands - L, R, T and B. Their specifications are given below: Lx: insert x in the left link list Rx: insert x in the right link list T x: insert x in the top link list // Where x is an integer number. Bx: insert x in the bottom link list Input: Test case will start with a number n indicating the number of lines following it. Output: you have to give output that which link list (Left, Right, Top and Bottom) has maximum sum of values. See the sampl and output. Нead 17 3 13 Sample input Sample output Right Link List Has Maximum Sum 32 14 L 3 L 15 L 1 R 17 T 9 T 10 В 13 T 5 R 3 В 2 В З В 4 ∞31 N34 H H M H LR R BBB
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning