Write the method findMin
that will return the smallest number in an array of integers.
Exercises
The following method takes an integer array as a parameter. Write code that loops through the array to find the value 1. If 1 is found,...
Return the index of the last occurrence of a given number in an array. Return -1 if the number is not in the array.
[Based on an exercise at https://codeworkout.cs.vt.edu/]
Given a string, return the string made of its first two chars, so the string...
The following method is a Selection Sort method. Within the method, there is an error on one line. You job is to find that line and fix...
Using generics in your program can be very useful considering generic methods and generic classes can handle different datatypes....
You have been handed a mysterious piece of data by an unknown person. Judging by his shifty eyes and maniacal laughter you don't think he...
Given a class Answer<E>
, write a method that converts argument e
into String and returns that value. If the value is a primitve, (...
The method mapNums returns a HashMap that stores values of how many times a given key digit has appeared in an input String. Write a...
Given is the number of edges and vertices in a directed graph. Using this information return the density of the graph.
Number of possible...
Given an int
, return a double
of precisely half the initial value. The int
will need to be converted into a double
before any other...
Roxy has written a method to count the number of people in her neighborhood, excluding children under 16 and individuals who are only...
You’re an employee at an ice cream shop and your shop needs help organizing who’s in line. People usually come to this shop with their...
Finish the code to complete the insertion sort method. Each comment denoted with //_________________ is a single line that needs to be...
What's wrong with the following code? Assume both the interface and class share the same package.
public interface Account { int...
Given a stack with Integers, write a function that pops the top two numbers from the stack, adds them together and pushes the result back...
Octavia has given you a list of movies. She is tired of deciding what to watch by name and now wants to be able to pick them by the...
You are in charge of keeping student records. Those records are recorded in a hash map that uses a student's ID number as the key in...
The LinearNode class is used to represent the individual nodes in a linear LinkedList. This particular LinkedList is doubly linked....
Mars' new colony needs your help. This morning, a flurry of distress signals reached Earth, each encrypted with a secret message....
The mere presence of oversized arrays makes Priscilla Perfect sick to her stomach. Such wasted space is an imperfection she cannot bear....
Use the following recursive method:
public int mysteryMethod(int n) { if (n < 0) { return 5; } else { return mysteryMethod(n - 1) +...
Complete the hashing algorithm for a hash table so that it functions using open addressing. Remember to store both keys and values in...
Priscilla Perfect detests imperfection (hence the name). Write a program to analyze a given array and return true if the array is worthy...
In mathematics, the Perrin Numbers are defined by the recursion relation
P(n) = P(n - 2) + P(n -3) for n > 2
with initial values
P(0)...