There are two sorted arrays
a1 and a2 of size n1 and size n2 respectively.
array a1 is full
array a2 has exactly n1(size of array a1) empty space.
example
a1[]=1234
a2[]=56789_ _ _ _
Write a function to merge these two arrays to form a sorted
array without any extra memory use.
i want a solution in c/c++ language
Answers were Sorted based on User's Feedback
Answer / ajay
class A
{
public static void main(String args[])
{
int[] a1={1,2,3,4};
int[] a2=new int[9];
a2[0]=5; a2[1]=6; a2[2]=7; a2[3]=8; a2[4]=9;
for(int i=8;i>=4;i--)
a2[i]=a2[i-4];
for(int i=0;i<=3;i++)
a2[i]=a1[i];
for(int i=0;i<=8;i++)
System.out.println(a2[i]);
}
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / surjeet gangwar
import java.util.*;
class arrtest
{
int[][] a=new int[3][3];
int[][] b={{1,1,1},{1,1,1},{1,1,1}};
public arrtest()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the matrix:\n");
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
a[i][j]=sc.nextInt();
}
void oper()
{
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
if(a[i][j]==0)
for(int k=0;k<3;k++)
{
b[i][k]=0;
b[k][j]=0;
}
}
void print()
{
System.out.println(" the matrix:\n");
for(int i=0;i<3;i++)
{ for(int j=0;j<3;j++)
System.out.print("\t"+b[i][j]);
System.out.println("\n");
}
}
}
class arrdemo
{
public static void main(String a[])
{
arrtest at=new arrtest();
at.oper();
at.print();
}
}
| Is This Answer Correct ? | 0 Yes | 3 No |
Which of the following is least like the others? a) Cube b) Sphere c) Pyramid d) Circle
10 Answers AIS, Aptech, Circle Source, Cube, EA Electronic Arts, Intel, QX,
In a team of 12 persons, 1/3 are women and 2/3 are men. To obtain a team with 20% women how many men should be hired?
in base representation for a rupee 100 paise,then base 8 representation what is rupee value .
if on a salary of rs."S" per month,one has to pay one tax of x rs. And a second type of tax of y rs then % of salary taken home is?
A can do a piece of work in 20 days, which B can do in 12 days. In 9 days B does ¾ of the work. How many days will A take to finish the remaining work?
A circle and a rectangle have the same perimeter. The sides of the rectangle are 18 cm and 26 cm. What will be the area of the circle? (a) 88 cm2 (b) 1250 cm2 (c) 154 cm2 (d) 128 cm2 (e) None of these
There are no of urns &no of balls. If three balls are placed in each urn then 3 balls is left. If 4 balls are placed in each urn then 1 urn is left. What is the total no of balls?
6 Face of a cube are painted in a manner ,no 2 adjacent face have same colour three colurs used are red blue green. Cube is cut in to 36 smaller cube in such a manner that 32 cubes are of one size and rest of them bigger size and each bigger side have no red side.
Bactria double every 3 mins. It is N in 1 hour, when was it N/4?
plz mail me previous year KVB clerical papers and model of the exam
0 Answers Karur Vysya Bank KVB,
Product of three consecutive nos. 210. What is the sum of two least numbers?
Mr. T has a wrong weighing pan. One arm is lengthier than other. 1 kilogram on left balances 8 melons on right, 1 kilogram on right balances 2 melons on left. If all melons are equal in weight, what is the weight of a single melon?