Write a function in Java that uses recursion (no loops) to check if the String str
has any char a
. Return true
if it does and false
if it...
Exercises
Iterate through the given array and return the number of fours.
Complete the following binary search method. Find the number num
in the array array
. Return -1 if the number is not found. You may assume...
Write a function in Java that takes in the int[] array
, sorts it using bubble sort, then returns back the sorted array.
May Tricks owns a chain of magic shops. She hands you a list of her store locations and asks you to find a way of quickly looking up the...
What would be the Big O Complexity for the following method?
public boolean crossRoad(boolean isSafe, int height, int length) { if...
Given is an adjacency matrix and a starting index.
Complete the depth first traversal method. Comments noted with //_________________ are...
When a method is directly recursive, what does it call?
Which operation has a different Big O complexity from the others?
If the class Pug
extends the class Dog
, what can't be said about the classes?
Write a function in Java that takes the int array arr
and returns a new array with each number being doubled. Be sure to make use of...
What would be the Big O Complexity for the following method?
public static void arrayDoubleValue(int[] nums, int[][] nums2) { for (int i...
Design a class Dog, making sure it is appropriately encapsulated. The class will have the properties 'name' and 'breed' (both Strings), a...
Given an int[] nums
array, return the sum of the first five elements from the array. Note that nums
could have fewer than five elements,...
Create an enhanced for loop that iterates to each String in the array words
and returns true when there is at least one String with more...
"Determine which exception is needed for each case and put them in the corresponding catch statement with the appropriate variable. Do ...
Complete the method so that the number num
is set to index point index
in the array named array
. Be sure to handle the exception with the...
Surround the appropriate lines of code with a try catch block so that first, an exception is caught when the String index is out of...
Create a method that returns the third character from the String word
. Be sure to use a try catch block and use the appropriate exception...
Considering the following lines of code, what will be the output?
try { String str = null; System.out.println(str.charAt(0)); }...
Return an array with the same contents, but double the size of the array passed in. The new slots will be filled with zeros. Use the...
Which of the following JUnit tests will fail?
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, characterized by the fact that every number...
Write a function findEvenQueue
that returns the first even number in the Queue. The function looks at the value at the front of the queue...
Return the index of first four in an array. Return -1 if there are none.