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 inorder(struct node* p)
ReplyDelete{
stack s;
do
{
while(p != NULL)
{
s.push(p);
p = p->left;
}
if(!s.empty())
{
p = s.top();
s.pop();
cout<data<right;
}
}while(!s.empty() || p != NULL);
}
void preorder(struct node* p)
{
stack s;
do
{
while(p != NULL)
{
s.push(p);
cout<data<left;
}
if(!s.empty())
{
p = s.top();
s.pop();
p = p->right;
}
}while(!s.empty() || p != NULL);
}
void postorder(struct node* p)
{
stack s;
do
{
INSERT:
while(p != NULL)
{
s.push(p);
p = p->left;
}
if(!s.empty())
{
p = s.top();
s.pop();
if(p->right == NULL)
cout<data<<endl;
else goto INSERT;
}
}while(!s.empty() || p != NULL);
}