# CS2230 Computer Science II: Data Structures Homework 1 Intro to Java solved

\$40.00

## Description

5/5 - (1 vote)

Problem 1 (10 points)
A base-paired DNA sequence is one where A’s line up with T’s and G’s line up with C’s. For
example:
base-paired DNA sequence
ATCGAT
TAGCTA
If A is not paired with T, T with A, G with C, or C with G, then the sequence is not base-paired.
For example:
not a base-paired DNA sequence
ATCGAT
TAGCAA
not a base-paired DNA sequence
ATCGAT
TATCTA
A base-paired sequence also needs both sides to have the same length. For example,
not a base-paired DNA sequence
ATCG
TAGCTA
Write a method base_check that takes two arrays of characters as arguments and returns
true if and only if the DNA sequence represented by the arrays is base-paired.
Implement your solution in the file we have provided: BaseCheck.java. Your program should
run and print only “Tests pass” in the console. It is your responsibility to make sure the program
runs properly either in NetBeans OR with the following command line commands.
javac BaseCheck.java
java BaseCheck
Problem 2 (10 points)
Write a method zero_first that takes an array as an argument and changes the array so that
it has all its zeroes at the beginning.
[-1,-2,-2,4] => [-1,-2,-2,-4]
[4,3,2,1,0] => [0,4,3,2,1]
[0, 5, 0, -1, 10, 11] => [0,0,5,-1,10,11]
[-4, 5, -6, 7, 0, 4, 3, 0, 0] => [0,0,0,-4,5,-6,7,4,3]
[0,0,1] => [0,0,1]
Implement your solution in the file we have provided: ZeroFirst.java. Your program should
run and print only “Tests pass” in the console. It is your responsibility to make sure the program
runs properly either in NetBeans OR with the following command line commands.
javac ZeroFirst.java
java ZeroFirst
Problem 3 (10 points)
Write a method max_both that takes two arrays of positive integers as arguments and returns
the maximum integer found in both arrays. If not duplicates are found it returns -1. For
example:
[2,4,6,8,10,12,14]
[7,7,5,4] => 4
[2,4,6,8]
[3,5,7] => -1
[7,6,22,4,4]
[4,5,5,25,6] => 6
Implement your solution in the file we have provided: MaxBoth.java. Your program should
run and print only “Tests pass” in the console. It is your responsibility to make sure the program
runs properly either in NetBeans OR with the following command line commands.
javac MaxBoth.java
java MaxBoth