Answered step by step
Verified Expert Solution
Question
1 Approved Answer
( 3 5 points ) Given Node.java and SinglyLinkedList.java, answer the following questions: a . ( 1 5 points ) Write a method that gets
points Given Node.java and SinglyLinkedList.java, answer the following questions: a points Write a method that gets a SinglyLinkedList object of numbers and a value max and removes every number greater than max in the list. Example: if list max list should be shortened by the following method and becomes : public static void removeValuesLargerThanMaxSinglyLinkedList list, int max b points Bob has n pens labeled by n He uses pen # for day of school, pen # for day pen # for day and pen #n for day n of school. For day n of school, he uses pen # again. And this process continues in a roundrobin fashion! Assume that Bob loses a pen every k days; ie he loses a pen on day k another one on day k etc. Write a method using the given SinglyLinkedList that gets the values of n and k and returns the label of last remaining pen before Bob loses all its pens. Example : n k the last pen is # since Bob loses a pen every day and # is the last pen Bob uses. Example : n k After day pens are After day pens are After day pens are After day pens are Last pen is # public static int bobsLastPenint numberOfPens, int k points Solve part a of question using java.util.LinkedList; ie implement the following method: public static void removeValuesLargerThanMaxLinkedList list, int max points Write a Java method that uses java.util.Stack class to implement the following method: public static boolean isBalancedString input, char openingSymbols, char closingSymbols The method checks whether the input string is made of balanced sequence of parentheses, brackets, braces, etc. For example, assuming that input is x openingSymbols is an array made of and and closingSymbols is another array made of and the method must return true. However, if the input is x with the same mentioned opening and closing symbols, the method must return false since the opening and closing symbols are not balanced.
points Given Node.java and SinglyLinkedList.java, answer the following questions:
a points Write a method that gets a SinglyLinkedList object of numbers and a value max and removes every number greater than max in the list.
Example: if list max list should be shortened by the following method and becomes :
public static void removeValuesLargerThanMaxSinglyLinkedList list, int max
b points Bob has n pens labeled by n He uses pen # for day of school, pen # for day pen # for day and pen #n for day n of school. For day n of school, he uses pen # again. And this process continues in a roundrobin fashion! Assume that Bob loses a pen every k days; ie he loses a pen on day k another one on day k etc. Write a method using the given SinglyLinkedList that gets the values of n and k and returns the label of last remaining pen before Bob loses all its pens.
Example : n k the last pen is # since Bob loses a pen every day and # is the last pen Bob uses.
Example : n k
After day pens are
After day pens are
After day pens are
After day pens are
Last pen is #
public static int bobsLastPenint numberOfPens, int k
points Solve part a of question using java.util.LinkedList; ie implement the following method:
public static void removeValuesLargerThanMaxLinkedList list, int max
points Write a Java method that uses java.util.Stack class to implement the following method:
public static boolean isBalancedString input, char openingSymbols, char closingSymbols
The method checks whether the input string is made of balanced sequence of parentheses, brackets, braces, etc. For example, assuming that input is x openingSymbols is an array made of and and closingSymbols is another array made of and the method must return true. However, if the input is x with the same mentioned opening and closing symbols, the method must return false since the opening and closing symbols are not balanced.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started