You are given n real numbers in an array. A number in the array is called a decimal dominant if it occurs more than n/10 times in the array. Give an O(n) time algorithm to determine if the given array has a decimal dominant.
Implement a function getbits, that returns the(right adjusted) n bits that begin at position p of an integer. Assume bit position 0 is at the right end and that n and p are sensible positive values.
void insert(struct node **s, void *data,unsigned int n)
ReplyDelete{
struct node *temp,*r;
int i;
if(*s == NULL)
{
temp = malloc(sizeof(struct node));
temp->data = malloc(n);
for (i = 0; i < n; i++)
*(char *)(temp->data + i) = *(char *)(data + i);
temp->link = NULL;
*s = temp;
}
else
{
temp =*s;
while(temp->link != NULL)
temp = temp->link;
r = malloc(sizeof(struct node));
r->data = malloc(sizeof(n));
for (i = 0; i < n; i++)
*(char *)(r->data + i) = *(char *)(data + i);
r->link = NULL;
temp->link = r;
}
}
In order to display the value You need to send the type of data it is storing as a parameter.