I-have-a-progran-which-prompts-a-user-for-an-integer-(n)-and-then-builds-a-linked-1is t-with-nunbers-between-1-and-n.5 For-example, -if-the-user-enters-5,-the-program-wil1-build-a-linked-1ist-with-1-throug h-5,-and-display-it-as-5, -4,-3,-2,-1.5 I-would-1ike-to-also-display-every-ather-node-data-in-this-progran-Le-5,-3,-1-for-t he-above-example.S Given-the-following-class-for-the-nodes-in-a-linked-list:9 public-class-Node-(9 public-Node-satNcat)-(...}......//-return-next-fields ---public-int-setata) -{-.---.-..--//-returns-datas Assuning-that-the-variable-head-points-to-(Le-contains-the-address-of)-the-first-no de-of-the-linked-list,-write-thes statenent(s)-to-print-the-data-value-in-every-other-node-of-the-1inked-1ist-to-the-co nsole.-5 For-exanple-if-the-1ist-has-5-4->3->2->1,- the-output-should-be-5-3-1-1.e.-the-number s-only-with-spaces-in-between. S If-the-1ist-is-enpty-8-size),-you-code-should-not-print-out-anything.5 You-nay-declare-additional-variables-and-assune-that-the-list-may-have-any-number-of- nodes-including-zero.S If-the-list-is-empty, -do-not-print-anything, -otherwise-print-the-data-separated-by-h ite-spaces.5

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Getting to every node in the linkedlist

38*
+
Email
AutoSave
P Search (Alt+Q)
A Harris Siddiqui HS
ff
Document6 - Word
File
Home
Insert
Draw
Design Layout
References
Mailings
Review
View Help
Table Design
Layout
P Comments
A Share
P Find
- A A Aa v
As E - E- E
Consolas
v 10
No Spacing
Heading 1
e Replace
Normal
Paste
BIU.
I U v ab
x, x' A ·
A.
= E E E ♥
Dictate
Editor
A Select v
Undo
Clipboard s
Font
Paragraph
Styles
Editing
Voice
Editor
I- have-a-program-which- prompts-a-user-for-an-integer (n)-and - then-builds-a-linked -lis
t-with-numbers-between 1. and n.9
Enter-list-size: -09
List data:5
For example, -if-the user enters-5, the-progran-will-build-a-linked-list-with-1-throug
h-5, and-display it as 5, 4, 3, 2, 1.9
Every other- data:
I- Would-like-to-also-display-every-other - node data-in-this-program-ie-5, 3, 1. for•t
he above exanple.9
Given - the following class- for the-nodes -in-a-linked-list:9
public-class- Node (9
***...9
*** public- Node-getNexte) {...}........//-return-next-fieldg
..* public-int-SatDatAL) {...}........//-returns datag
19
Assuming-that - the-variable- head- points-to (ie contains the-address-of) the first no
de of the-linked-list, write theg
statement (s)-to-print-the data value-in-every-other node-of the linked-list to-the co
nsole. 9
For example-if-the-list-has-5->4->3->2->1, the output should-be-5-3-1-1.e. the number
S-only-with-spaces in-between.
If the 1ist-is empty 0.size), you-cade-should-not print out anything.9
You-may-declare-additional- variables-and -assune that the list-may-have-any - number•of.
nodes including-zero.9
If the-list-is - empty, do-not print-anything, otherwise print - the-data-separated-by- wh
ite spaces.9
Page 1 of 2
Text Predictions: On
& Accessibility: Investigate
O Focus
243 words
68%
1:16 PM
P Type here to search
a
C3
Hi
35°F
12/6/2021
...
Transcribed Image Text:38* + Email AutoSave P Search (Alt+Q) A Harris Siddiqui HS ff Document6 - Word File Home Insert Draw Design Layout References Mailings Review View Help Table Design Layout P Comments A Share P Find - A A Aa v As E - E- E Consolas v 10 No Spacing Heading 1 e Replace Normal Paste BIU. I U v ab x, x' A · A. = E E E ♥ Dictate Editor A Select v Undo Clipboard s Font Paragraph Styles Editing Voice Editor I- have-a-program-which- prompts-a-user-for-an-integer (n)-and - then-builds-a-linked -lis t-with-numbers-between 1. and n.9 Enter-list-size: -09 List data:5 For example, -if-the user enters-5, the-progran-will-build-a-linked-list-with-1-throug h-5, and-display it as 5, 4, 3, 2, 1.9 Every other- data: I- Would-like-to-also-display-every-other - node data-in-this-program-ie-5, 3, 1. for•t he above exanple.9 Given - the following class- for the-nodes -in-a-linked-list:9 public-class- Node (9 ***...9 *** public- Node-getNexte) {...}........//-return-next-fieldg ..* public-int-SatDatAL) {...}........//-returns datag 19 Assuming-that - the-variable- head- points-to (ie contains the-address-of) the first no de of the-linked-list, write theg statement (s)-to-print-the data value-in-every-other node-of the linked-list to-the co nsole. 9 For example-if-the-list-has-5->4->3->2->1, the output should-be-5-3-1-1.e. the number S-only-with-spaces in-between. If the 1ist-is empty 0.size), you-cade-should-not print out anything.9 You-may-declare-additional- variables-and -assune that the list-may-have-any - number•of. nodes including-zero.9 If the-list-is - empty, do-not print-anything, otherwise print - the-data-separated-by- wh ite spaces.9 Page 1 of 2 Text Predictions: On & Accessibility: Investigate O Focus 243 words 68% 1:16 PM P Type here to search a C3 Hi 35°F 12/6/2021 ...
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY