Shivaprasad
BAN USERstack_sort(st , 0);
stack_sort(Stack st, num)
{
temp = pop (st_;
if (isstackempty(st))
push (st, temp );
else {
stack_sort(st,temp);
while (stacktop(st < temp)
{
temp1 = pop(st);
push(st1, temp1); //copy to second stack
}
push(st, temp );
// copy the second stack after inserting the temp to proper position
while (isempty(st1) )
{
push(st, pop(st1));
}
}
}
int count;
int main()
{
int K;
printf( "Enter value of K \n");
scanf ("%d", &K);
count = k;
inorder(head);
}
void inorder( struct node *head)
{
if(head == NULL)
return ;
inorder(head->left);
count --;
if (count == 0)
{
printf("Kth smallest element = %d ", head->data);
return;
}
inorder(head->right);
}
boolean same_tree (TREE * head1, TREE *head2 )
{
if((head1 && !head2) || (head2 && !head1))
return false;
else
{
if(head1->data == head2->data )
{
return (same_tree(head1->left, head2->left ) &&
same_tree(head1->right, head2->right))
}
}
return false;
}
Step 1 : Find a transpose of the matrix.
Step 2 : Reverse all rows
Above method tilts the given matrix by 90 degree.
Do that twice
hair and tortoise algorithm
- Shivaprasad April 02, 2012I am making small assumption before writing this code . .
main()
{
char c = getchar();
if( c !='\n')
main();
putchar(c);
}
- Shivaprasad December 11, 2014