Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

starter code: in java pls and thank you!

public class LinkedList {

    private Node head;
    private Node tail;
   
    public void add(String item) {
       
        Node newItem = new Node(item);
       
        // handles the case where the new item
        // is the only thing in the list
        if (head == null) {
            head = newItem;
            tail = newItem;
            return;
        }
       
        tail.next = newItem;
        tail = newItem;
    }
   
   
    public void print() {
        Node current = head;
        while (current != null) {
            System.out.println(current.item);
            current = current.next;
        }
    }
   
   
    public void printWithSkips() {
        // TODO your code here
    }

   
    class Node {
        String item;
        Node next;
       
        public Node(String item) {
            this.item = item;
            this.next = null;
        }
    }
}
and 
public class Driver {

    public static void main(String[] args) {
        LinkedList list = new LinkedList();
        list.add("Falcons");
        list.add("Bears");
        list.add("Titans");
        list.add("Eagles");
        list.add("Panthers");
        list.add("Cowboys");
        list.add("Steelers");
        list.add("49ers");
        list.add("Vikings");
        list.add("Saints");
        list.add("Seahawks");
       
        list.print();
        System.out.println("\n");
        list.printWithSkips();
    }
}
!!!
PDF
Skipping through a List (1).pdf X +
50
79°F
Clear
1
File C:/Users/19377/Downloads/Skipping%20through%20a%20List%20(1).pdf
T
For this practice lab you will need to download the starter code. This code contains a class called
Linked List with two methods implemented - add and print. There is also a class called Driver, which has
a main method that creates a new list, adds some items, and prints them out.
Your task is to write a third method in the LinkedList class, called printWithSkips. This method should
have the following behavior:
Prints the first item in the list, skips zero
Prints the second item in the list, skips one
Prints the fourth item in the list, skips two
Prints the seventh item in the list, skips three
and so on until it reaches the end of the list
Note: Be sure to handle the case where the last item in the full list is not one that should be printed.
Example output:
Full List:
Falcons
Bears
Titans
Eagles
Panthers
Cowboys
Steelers
➡ | D | A | Ⓡ
→
T
49ers
Vikings
Saints
Seahawks
Print with skips:
Falcons
Bears
Eagles
Steelers
Seahawks
W
|
1+
11:10 PM
6/30/2022
O
+
A
expand button
Transcribed Image Text:!!! PDF Skipping through a List (1).pdf X + 50 79°F Clear 1 File C:/Users/19377/Downloads/Skipping%20through%20a%20List%20(1).pdf T For this practice lab you will need to download the starter code. This code contains a class called Linked List with two methods implemented - add and print. There is also a class called Driver, which has a main method that creates a new list, adds some items, and prints them out. Your task is to write a third method in the LinkedList class, called printWithSkips. This method should have the following behavior: Prints the first item in the list, skips zero Prints the second item in the list, skips one Prints the fourth item in the list, skips two Prints the seventh item in the list, skips three and so on until it reaches the end of the list Note: Be sure to handle the case where the last item in the full list is not one that should be printed. Example output: Full List: Falcons Bears Titans Eagles Panthers Cowboys Steelers ➡ | D | A | Ⓡ → T 49ers Vikings Saints Seahawks Print with skips: Falcons Bears Eagles Steelers Seahawks W | 1+ 11:10 PM 6/30/2022 O + A
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY