[Solved]-Q1 20p Write Static Member Function Called Removelongestrepeatingsegment Takes String Argu Q37257719
Q1)(20p)Write a static member function calledremoveLongestRepeatingSegment that takes a String argument. Themethod will return a new String by removing the logest segment thatcontains consequtively repeating characters.
public static void main(String []args){
String s=”1111222223333311111111444455552222”;
String res= removeLongestRepeatingSegment(s); will return“11112222233333444455552222”
}
public static String removeLongestRepeatingSegment(Strings){
—————
Q2)15p)Given a list of objects stored (in ascending order) in asorted linked list, implement member method which performs searchas efficiently as possible for an object based on a key. (Note thatthe key type matches the field type by whichthe linked list issorted.). The method returns refenence to the node containing thekey, otherwise null is returned.
——————–

———————–
Q4)
a)(5p)Evaluate the postfix expression30 16 6 2 – / * 8 + using postfixevaluation algorithm by writing necessary pop push operation. (Donot write implementation)
b)(5p)Write the prefix form of expressionA + B * D + E / (F +A) * D + C usingparanthesis method.
c) (10p)Write a method called moveNthFront that takes as aparameter a positive integer n and Queue. The function moves thenth element of the queue to the front while keeping the other itemsin their placeses.
f r
q={4 6 8 9 47 5 12}n=4 f r
after call to the function queue becomes q={9 4 6 8 47 512}
———————————
Q5)(20p) Linked list contains consecutive repeated int numbersas illustreded in example. Write a method shrink()what removesrepeated numbers and leave one copy for each sequence of repeatednumber.
L:6->6->6->6->5->5->5->10->10->10->10->5->5->5->5->3->null
Resultant List after shrink() method
L: 6->5->10->5->3->null
that returns true if two singly linked lists are intersecting Q3) 25p)Write a member function for a LList class isIntersects t (as shown below int the figure), otherwise, the method would return false. Do not make any assumption on the number of nodes of each linked list Show transcribed image text that returns true if two singly linked lists are intersecting Q3) 25p)Write a member function for a LList class isIntersects t (as shown below int the figure), otherwise, the method would return false. Do not make any assumption on the number of nodes of each linked list
Expert Answer
Answer to Q1)(20p)Write a static member function called removeLongestRepeatingSegment that takes a String argument. The method wil… . . .
OR

