Answer:
First we understand what is hash function.A hash function is mostly used in Hashmaps. It maps different keys to a set of values.There may occur a case when we have same key but different values.This case is called collision.So we have to use different collision handling techniques that are open addressing and separate chaining.
A perfect hash function maps key-value pair such that there are no collisions.
Answer:
- import java.util.Arrays;
- public class Main {
-
- public static void main(String[] args) {
- String [] first = {"David", "Mike", "Katie", "Lucy"};
- String [] middle = {"A", "B", "C", "D"};
- String [] names = makeNames(first, middle);
-
- System.out.println(Arrays.toString(names));
- }
-
- public static String [] makeNames(String [] array1, String [] array2){
-
- if(array1.length == 0){
- return array1;
- }
-
- if(array2.length == 0){
- return array2;
- }
-
- String [] newNames = new String[array1.length];
-
- for(int i=0; i < array1.length; i++){
- newNames[i] = array1[i] + " " + array2[i];
- }
-
- return newNames;
- }
- }
Explanation:
The solution code is written in Java.
Firstly, create the makeNames method by following the method signature as required by the question (Line 12). Check if any one the input string array is with size 0, return the another string array (Line 14 - 20). Else, create a string array, newNames (Line 22). Use a for loop to repeatedly concatenate the string from array1 with a single space " " and followed with the string from array2 and set it as item of the newNames array (Line 24-26). Lastly, return the newNames array (Line 28).
In the main program create two string array, first and middle, and pass the two arrays to the makeNames methods as arguments (Line 5-6). The returned array is assigned to names array (Line 7). Display the names array to terminal (Line 9) and we shall get the sample output: [David A, Mike B, Katie C, Lucy D]
Answer:
Assuming this is 0 based array indexing, it would look like this...
[ 5, 6, 10, 7, 3, 2.5 ]
[ 0, 1, 2, 3, 4, 5, 6 ]
The index of 7 would be 3.
Answer:
There are two customers in the PostalCode.
SQL statement for select all the fields and the rows from the Customers table where PostalCode is 44000.
SELECT * FROM Customers WHERE PostalCode = "44000";
Explanation:
The SELECT statement retrieve zero or more than one row from 1 or more than one the database tables or the database views.
In most of the applications, the SELECT query is most commonly used for DQL(Data Query Language) command.
SQL is the declarative programming language and the SELECT statement specifies the result set, but they do not specifies how to calculate it.