I’m pretty sure it’s “Find and paste”
Answer:
See explaination for the program code
Explanation:
The code below
Pseudo-code:
//each item ai is used at most once
isSubsetSum(A[],n,t)//takes array of items of size n, and sum t
{
boolean subset[n+1][t+1];//creating a boolean mtraix
for i=1 to n+1
subset[i][1] = true; //initially setting all first column values as true
for i = 2 to t+1
subset[1][i] = false; //initialy setting all first row values as false
for i=2 to n
{
for j=2 to t
{
if(j<A[i-1])
subset[i][j] = subset[i-1][j];
if (j >= A[i-1])
subset[i][j] = subset[i-1][j] ||
subset[i - 1][j-set[i-1]];
}
}
//returns true if there is a subset with given sum t
//other wise returns false
return subset[n][t];
}
Recurrence relation:
T(n) =T(n-1)+ t//here t is runtime of inner loop, and innner loop will run n times
T(1)=1
solving recurrence:
T(n)=T(n-1)+t
T(n)=T(n-2)+t+t
T(n)=T(n-2)+2t
T(n)=T(n-3)+3t
,,
,
T(n)=T(n-n-1)+(n-1)t
T(n)=T(1)+(n-1)t
T(n)=1+(n-1)t = O(nt)
//so complexity is :O(nt)//where n is number of element, t is given sum
Answer:
C. Offset.
Explanation:
An offset operator can be defined as an integer that typically illustrates or represents the distance in bytes, ranging from the beginning of an object to the given point (segment) of the same object within the same data structure or array. Also, the distance in an offset operator is only valid when all the elements present in the object are having the same size, which is mainly measured in bytes.
Hence, the offset operator returns the distance in bytes, of a label from the beginning of its enclosing segment, added to the segment register.
For instance, assuming the object Z is an array of characters or data structure containing the following elements "efghij" the fifth element containing the character "i" is said to have an offset of four (4) from the beginning (start) of Z.
Answer:
public class Main
{
public static void main(String[] args) {
System.out.println(starString(4));
}
public static String starString(int n){
double p = Math.pow(2,n);
String s = "";
for(int i=0; i<p; i++)
s += "*";
return s;
}
}
Explanation:
Create a method named starString that takes an integer parameter, n
Get the 2 to the nth power using pow method and set it to the p
Create an empty string that will hold the asterisks
Create a for loop that will iterate p times. Inside the loop, concatenate an asterisk to the s
Return the s
Inside the main method, call the method with an integer parameter