Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA For each of the following mathematical expressions involving set notation p

ID: 3806991 • Letter: J

Question

JAVA

For each of the following mathematical expressions involving set notation presented in the Mathematical Set Notation slides, provide the value of the expression.

12 is in { 41, 23, -35, 8 }

23 is not in { 41, 23, -35, 8 }

{ } union { 'x', 'y', 'z' }

{ 'x', 'y', 'z' } union { 'x', 'y', 'w' }

{ 'x', 'y', 'z' } intersection { 'x', 'y', 'w' }

{ 'x', 'y', 'z' } intersection { }

{ 'x', 'y', 'z' } { 'x', 'y', 'w' }

{ } { 'x', 'y', 'z' }

{ 1, 2, 3 } is subset of { 2, -2, 3, 1, 7 }

{ 1, 2, 3 } is proper subset of { 1, 2, 3}

|{ 'x', 'y', 'z' }|

entries(< 'b', 'a', 'b', 'c', 'b' >)

Given the following fragments, reassemble the original string by applying the greedy reassembly algorithm presented in the Genome/String Reassembly slides. Show in each step the two strings with the longest overlap and the resulting combination.

TATACAT

AGCTGTTTTCGTT

CACTCCATTTTA

CATTTTAGCTGTT

TTTCGTTATACAT

CTGTTTTCGTTA

Implement the instance method flip declared as follows (this is a Queue<T>):

/**

* Reverses ("flips") {@code this}.

*

* @updates this

* @ensures this = rev(#this)

*/

public void flip();

Rewrite flip, including the contract, so that it is a static method.

/**

* Reverses ("flips") {@code this}.

*

* @updates this

* @ensures this = rev(#this)

*/

public void flip();

Explanation / Answer

NOTE: One question per one post as per Chegg rules. So, i provide the answer for instance method flip using queue and stack methods.

//Method definition for flip by using Queue
public void flip()
{
//Initialize the variables
int i=0;
int num=rev.length();
//Arrange the reverse order of the queue
while(i<num)
{
  test.rotate(-1);
  int j=rev.dequeue();
  rev1.enqueue(k);
}
//Display output
System.out.println("The reverse order of the queue:");
}

//Method definition for flip by using Stack
public static <T> void flip(Stack<T> s)
{
if (s.isEmpty())
{
  return;
}
T e = s.pop();
flip(s);
bottomValue(s, e);
}
private static <T> void bottomValue(Stack<T> s, T num)
{
if (s.isEmpty())
{
  s.push(num);
  return;
}
T temp = s.pop();
bottomValue(s, num);
s.push(temp);
}