Topic — Add New » Posts Last Poster Freshness
Traverse Knight in ChessBoard problem 1 vpshastry 1 week

I've written a code to traverse a knight to all the squares on a chess board only once. The problem with this(below) code is, its working till 7x7 and doing nothing after 8x8. The code is
Here [b]chessBoardSize[/b] defines the size(8=> 8x8)

#include<stdio.h>
#include<stdlib.h>
#define chessBoardSize 8

int chessBoard[chessBoardSize][chessBoardSize] = {0};
typedef struct point{
	int x, y;
}POINT;
int count=0;

int nextPosition(int x, int y, POINT* array){
	int m=...
Are dynamic storage allocation and recursion related? 2 cofex 2 weeks

Is it necessary for a language to have dynamic storage for supporting recursion? If yes, then how are they related?

Swap 2 arrays of different size inplace 5 camster 2 months

2 arrays are stored contiguously in memory and sizes of both arrays are known. Swap the contents of both arrays . Initially, you only have the pointer to element 1 of array 1 .
eg if array 1 is 1234 and array 2 is 567 , they are stores in memory as 1234567.After swapping , it should become 5671234.

Microsoft Interview Question for Software Engineer/Developer (Fresher) about CPuzzles 3 4 months

If len is the length of the string and num is the number of
characters printed on the screen
Give the relation between num and len.

void abc (char *s){
  if(s[0]== 0)
    return;

  abc(s+1);
  abc(s+1);
  printf("%c ", s[0]);
}

a) num=2^len
b )num=2^len-1
c) num=2*len-1
d) None of the above

Microsoft
[closed] what is the output of this recursion func 2 kartik 4 months
int fun(int a, int b)
{
   if (b == 0)
       return 0;
   if (b % 2 == 0)
       return fun(a+a, b/2);

   return fun(a+a, b/2) + a;
}

int main()
{
  printf("%d", fun(4, 3));
  getchar();
  return 0;
}
Amazon Online Interview Question 1 9 months

There are K pegs. Each peg can hold discs in decreasing order of radius when looked from bottom to top of the peg. There are N discs who have radius 1 to N; Given the initial configuration of the pegs and the final configuration of the pegs, output the moves required to transform from the initial to final configuration. You are required to do the transformations in minimal number of moves.
A move consists of picking the topmost disc of any one of the pegs and placing it on top of anyoth...

Recursion of main() 2 10 months
#include<stdio.h>
#include<conio.h>
static int i;
int main()
{
    if(i==5)
       printf("\n thanks...");
    i++;
    return (i=main());
}

When i run this program it is showing the output as thanks... But it is still in the output window and i am not able to get back to the program window.. why is it so ? Can you explain please..

Space Complexity? 3 ashish 11 months
double foo(int n)
{
   int i;
   double sum;
   if(n==0)
      retrun 1;
  else
  {
      sum = 0;
      for (i=0; i<n; i++)
            sum+=foo(i);
      retrun sum;
  }
}

wht is the space complwexity of thsi???

Binary tree of integer is given find a path in tree that's maximum 1 1 year

1) Path can be from root to leaf
2) Path can be from root to non leaf nodes
3) Path can be from non root node to leave node
4) path can be from non root node to non leaf node
5) one single node can also be a candidate

6) no need to consider the path like this
Max Sum path in Left tree + Max Sum path in Left tree + current Node
where current node can be any node in the tree...

Looking for time complexity space complexity

Google Interview Question for Software Engineer/Developer about Algorithms 4 m@}{ 1 year

write code for a recursive solution that you created, can be any problem.

Google
Microsoft Interview Question 3 kartik 1 year
#include<stdio.h>
void fun(int x)
{
	if(x > 0)
	{
		fun(--x);
		printf("%d\t", x);
		fun(--x);
	}
}

int main()
{
	int a = 4;
	fun(a);
        getchar();
	return 0;
}

what is the output of the following program

Recursion help!! 3 1 year
int Max(int a[],int n)
{
	int max;
	if(n==1)
		return a[0];
	else
		max=Max(a,n-1);
	if(max>a[n-1])
		return max;
	else
		return a[n-1];
}

Hi, the above is a code to find the max in an array recursively. I find very difficult in understanding the flow of recursive programs. Can someone help me out in explaining the flow of the program with stack sections if possible.
Thanks!!

Interview Question for Software Engineer/Developer (Fresher) about CPuzzles 2 kartik 1 year

using only one '+' operator, write a C function sum(x, y, z) that returns sum of x, y and z.

Explain functionality of the given recursive C function 2 1 year
int func(int i)
{
  if(i%2) return (i++);
  else return func(func(i-1));
}