RAM
BAN USERSolution for offliine instance:
create N min proirity queues for N servers
give priority to each id = no of sub requests
this will finish request with few sub request first then go for huge subrequest it will reduce total finish time. Please let me know if you have another efficient solution
first example:
finish time of inut with out any reordering
id:1 time to finsh : 4
id:2 time to finish : 2
id:3 time to finsh : 4
id:4 time to finish : 4
sum = 14
time to finish is to finish last sub request
time to finish output
id:1 time to finsh : 1
id:2 time to finish : 2
id:3 time to finsh : 3
id:4 time to finish : 4
totol sum = 10
I hope this explains how to calculate for second input also
//1 is for true
//0 is for false
int regrex(char *s1, char *s2)
{
int flag = 0;
while(*s1 != '\0' && *s2 != '\0')
{
if(*s1 == '*')
{
s1++;
flag=1;
}
else
{
if( *s1 != *s2 )
{
if(flag)
s2++;
else
return 0;
}
else
{
flag=0;
s1++;
s2++;
}
}
}
if(*s2 != '\0')
return 0;
while(*s1 != '\0')
if( *s1 != '*')
return 0;
return 1;
}
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int N=8; // N*N matrix
int main() {
int i,j;
int b[4][(N*N)/4];
int c[2*N][4];
int a[N][N];
int dev=N/2;
srand(time(NULL));
//creating and printing input
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
{
a[i][j]=rand()%100;
printf("%2d ",a[i][j]);
}
printf("\n");
}
/* actaul copying done here */
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
{
b[((i/dev)*2)+(j/dev)][(j%dev) + dev*(i%dev)]=a[i][j];
c[((i/2)*dev)+j/2][(i%2)*2 + j%2]=a[i][j];
}
}
//printing output1
for(i=0;i<4;i++)
{
for(j=0;j<(N*N)/4;j++)
{
printf("%2d ",b[i][j]);
}
printf("\n");
}
//printing out other output
for(i=0;i<2*N;i++)
{
for(j=0;j<4;j++)
{
printf("%2d ",c[i][j]);
}
printf("\n");
}
return 0;
}
1)There will be no compilation error in any of the implementation.
2) The first implementation there won't be any issues in memory allocation or free.
3)second implementation you can't free(S) because s is pointing to constant memory you can modify s to another pointer but you can't free the current memory allocated.
Rephoychrista, Blockchain Developer at ASU
Worked with Clients to guide them through the event details about copier leasing companies and served as their personal coordinator ...
- RAM November 01, 2013