Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Group Assignment (maximum number of 10 people per group )

Assignment 2: Due date: 11/11/22

1. Suppose the keys on the middle row of a standard keyboard (ASDFGHJKL) are inserted
in succession into an initially empty binary search tree. Draw the tree after this sequence
of insertions has been made. [10]
2. Suppose the keys on the middle row of a standard keyboard (ASDFGHJKL) are inserted
in succession into an initially empty 2-3 tree. Draw diagrams to illustrate the growth of the
tree, showing the tree just before and just after all splits. [10]
3. The following program compiles and runs. What is the output of this program? [10]

public class MyRectangle


{ private int theLength;
private int theWidth;
public MyRectangle()
{ theLength = 0;
theWidth = 0;
}
public MyRectangle(int length, int width)
{ theLength = length;
theWidth = width; }
public int getArea()
{ return (theLength * theWidth);
}
public boolean isSquare()
{
return (theLength == theWidth);
}
public static void main(String[] args)
{ MyRectangle m1 = new MyRectangle(4,4);
System.out.println("The area = "+ m1.getArea());
System.out.println("Is it a square? " + m1.isSquare());
MyRectangle m2 = new MyRectangle(20,35);
System.out.println("The area = "+ m2.getArea());
System.out.println("Is it a square? " + m2.isSquare()); } }

Page 1 of 1

You might also like