Topic — Add New » Posts Last Poster Freshness
Tejas Network Interview Question for Software Engineer/Developer (Fresher) about Algorithms 3 bradboyxrumer 1 month

What is the best approach to implement Fibonacci series?(recursions or without recursion).In case of no recursion could you optimize your approach further?(Consider Branch pruning).

Tejas Network
fibonacci series element 3 vasu 5 months

provide a program which will print nth element in fibonacci series. conditions are
1) O(1) time complexity
2) try to keep the memory consumption minimum
3) n is between 1000 to 10000. ( check for integer overflow)

A Fibonacci Question 2 kartik 6 months
#include<stdio.h>
main()
{
    int a,b,n,fib=0;
    a=0,b=1;
    scanf("%d",&n);
    if(n==0||n==1)
        printf("%d\n",n);
    while(n--!=0)
    {

        fib=a+b;
        a=b;
        b=fib;
        printf("%d+",fib);

    }
}

for n = 3 o/p is 1+2+3+
how to remve that extra '+' at the end of 3 so that o/p become 1+2+3

Google Interview Question for Software Engineer/Developer about Algorithms 6 1 year

Suppose we have N companies, and we want to eventually merge them into one big company. How many ways are there to merge?

Google
Amazon Interview Question for Software Engineer/Developer about Puzzle 3 S 1 year

A number of steps are there. You can go to step n either from step n-1 or from step n-2. In how many ways can you go to step n?

Amazon
Interview Question for Software Engineer/Developer about Algorithms 3 1 year

Discuss different ways to get the nth Fibonacci number, what is the problem with recursive solution?

Google Interview Question for Software Engineer/Developer about Puzzle 3 1 year

You have N steps to get down. You have two options
a. either you come one step down (nth to (n-1)th )
b. or you directly jump to the 3rd step leaving one step in between. ( say from nth to (n-2)th )

Find the total possible ways in which one can get down.

Google
Print large Fibonacci numbers 1 1 year

How to print very large Fibonacci numbers eg fib(1000).
My approach:
When any one of fib(i-1) or fib(i-2) has more than 12 or 13 digits, partition them into groups of 4 digits and put them in a linked list.
fib(i-1) is put in list1, fib(i-2) in list2. Perform the addition of these long numbers and overwrite in list2.
Now to find next fib list1 is taken as fib(i-2) and list2 as fib(i-1) and this repeats until we approach the given number and finally the result is in lis...

What does the given program do 2 1 year
IntQueue q = new IntQueue();
q.enqueue(0);
q.enqueue(1);
for (int i = 0; i < 10; i++) {
    int a = q.dequeue();
    int b = q.dequeue();
    q.enqueue(b);
    q.enqueue(a + b);
    ptint(a);
}