Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Urgent to me very urgent This question, too And also my previous question (you did not receive an answer to it since yesterday) I have

Urgent to me very urgent This question, too And also my previous question (you did not receive an answer to it since yesterday)

I have a question in java

Adds the Classes here IntNode, IntList

They may be needed

Class IntNode:

public class IntNode {

private int _value;

private IntNode _next;

public IntNode(int val, IntNode n) {

_value = val;

_next = n;

}

public IntNode(int val) {

_value = val;

_next = null;

}

public IntNode getNext() {

return _next;

}

public void setNext(IntNode node) {

_next = node;

}

public int getValue() {

return _value;

}

public void setValue(int val) {

_value = val;

}

public String toString() {

return ("" + _value);

}

}

Class IntList

public class IntList

{

private IntNode _head;

public IntList( ) {

_head = null;

}

public IntList(IntNode node) {

_head = node;

}

public boolean empty( ) {

return _head == null;

}

public IntNode nextElement (IntNode node) {

return node.getNext();

}

public int getValueOfNode (IntNode node) {

return node.getValue();

}

}

I have here three methods relating to the classes representing a linked list and a binary tree.

The insert method (p, x) takes as a pointer parameters to the member p in the list and an integer x and inserts the number x as an member after the member p. If p is null, x will go to the top of the list.

public static IntList what1(Node t)

{

IntList list=new IntList();

what2(t, list);

return list;

}

public static void what2(Node t, IntList list)

{

if(t!=null)

{

int x=t.getInfo();

if (what3(t.getLeft(),x) && what3(t.getRight(),x))

list.insert(null,x);

what2(t.getLeft(),list);

what2(t.getRight(),list);

}

}

public static boolean what3(Node t, int x)

{

if(t==null)

return true;

if(t.getInfo()==x)

return false;

return what3(t.getLeft(), x) && what3(t.getRight(),x);

}

part 1:

What does the what3 method do above given it a t junction and an integer x?

One correct answer must be chosen

a. Returns true if the number x is at the intersection t and false otherwise

b. Returns false if the number x is at the intersection of t and another true.

c. Returns true if the number x is in a tree rooted in t and false otherwise.

d. Returns false if the number x is in a tree rooted t and true otherwise.

e. There is no correct answer between e-d

part 2:

Given the tree t below,

3 = root

Right son:

10 child of 3

9, 7 children of 10 (7 right side of 10, 9 left side of 10)

10 other son of 7 (on the right side of 7)

7 other son of 9 (on the left side of 9)

Left son:

3 other child of 3 root

3 (who is in level 2) has two children: another 3 (on the right side of 3 in level 2), 1 on the left side (the child of the 3rd in level 2)

3 (we will go out in level 3) He has a child 2 (on the right side of level 3)

So:

( root ) 3

3 10

1 3 9 7

2 7 10

What will be the result of the summons

System.out.println (what1 (t))

Assuming list printing prints the

The organs in it from left to right (the organ at the top of the list is the leftmost).

One correct answer must be chosen

a. [10,7, 7, 9, 10, 2,3,1,3,3]

b. [10,7,7,9,2,3,1]

c. [3,3,13,2,10,9,7,7,10]

d. [1,3,2,9,7,7,10]

e. [1,3,3,2,3,7,9,10,7,10]

f. [10,7,9,7,3,2,1]

h. There is no correct answer between a-f

*****

I have this method:

public static boolean secret(Node t)

{

if (t.getLeft()==null && t.getRight()==null)

return true;

if (t.getLeft()==null || t.getRight()==null)

return false;

if (t.getLeft().getInfo()>0)

return false;

if (t.getRight().getInfo()<0)

return false;

return secret(t.getLeft()) && secret (t.getRight());

}

The following two claims are made:

There exists a t tree that contains only positive values (greater than 0), so the secret (t) method returns true.

2. There is no t tree that does not contain positive values, so a secret (t) operation will return true

Discounts for both claims:

1. In t there are at least two nodes.

2. A node cannot contain the value 0

One correct answer must be chosen:

a. Both claims are incorrect.

b. Claim 1 is correct and Claim 2 is incorrect.

c. Claim 1 is incorrect and claim 2 is correct.

d. Both claims are correct.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago

Question

why do consumers often fail to seek out higher yields on deposits ?

Answered: 1 week ago