Vandna
BAN USER
Comments (4)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
I think both the solutions need atleast two traversals of the list.
So both are equally efficient.
My solution is
void deletekthnode(struct node * head,int k)
{
struct node * current,temp;
int count = 0;
for (current = head;current->next!= NULL;current = current->next)
count++;
count = count +1 -(k-1) //1 added to add the last node .
for(int i = 0,current = head;i<count;i++)
;
temp = current->next;
current->next = temp->next;
temp->next = NULL;
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Program for matrix multiplication on complex numbers
- Vandna January 08, 2008Here u apply simple matrix multiplication and then
apply rules of complex number.
let no of rows,cols in A be rowsA,colsA
no of rows,cols in B be rowsB,colsB
struct Complex{
int real;
int imaginary;
}
_matrixMultiplication(struct Complex A[][],struct Complex B[][],struct complexresultC[][])
{
int i,j,k;
if(colsA != rowsB)
{
printf("Multiplication not possible");
return Null;
}
else
{
for(i=0,i<rowsA,i++)
{
for(j=0,j<colsA,j++)
{
C[i][j].real = 0;
C[i][j].complex = 0;
for(k=0,k<colsA,k++)
{
C[j][k].real = C[j][k].real + (A[i][k].real*B[k][j].real -A[i][k].imag*B[k][j].imag)
....
simalarliy do for imag part like (a+bi)(c+di) = ab-bd + (ad+bc)i
i hope it was very simple...