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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education