Epic Systems Interview Question for Analysts






Comment hidden because of low score. Click to expand.
1
of 1 vote

Another way is using divide and conquer algorithm,which in O(log n) running time.
+Tricky part is: for base_array[2][2]={{1,1},{1,0}}; => {{A2,A1},{A1,A0}} and for base_array^n, we can get {{An+1,An},{An,An-1}}, and simply return An is enough.
+Algorithm: (bottom to top) base_array=>base_array^2=>base_array^4=>....base_array^n, thus running time is O(log n).

The good part is the running time, but the code is a little bit more since need to calculate the matrix matrix multiplication and when compare to dynamic program, I still recommend dynamic programming method for its simplicity.

- wei April 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

//fibonacci series program
//author : scarlet
#include<stdio.h>
main()
{
int a,b,n,c;
scanf("%d",&n);
a=0;
b=1;
printf("%d %d",a,b);
n=n-2;
while(n>0)
{
c=a+b;
a=b;
b=c;
printf("%d ",c);
n--;
}
}

- scarlet August 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void main()
{
cin>>n;
cout<<fibo(n);


}

int fibo(int n){
if(n==0) return 0;
if(n==1) return 1;
else return(fibo(n-1)+fibo(n-2));
}
}

- Anonymous August 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Dude.. Recursion in this case is O(N!). Avoid at all costs.

- aditya3889 September 08, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

then what is your suggestion?

- Anonymous November 08, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

he probably want you do it in iteration.

int first = 0;
int second =1;
int result =0;
if (n == 1) return second; if (n == 0) return 0;
while (n >=2){
result = first + second;
first = second;
second = result;
n--;
}
return result;

- Anonymous March 06, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

void main()
{
cin>>n;
cout<<fibo(n);


}

int fibo(int n){
if(n==0) return 0;
if(n==1) return 1;
else return(fibo(n-1)+fibo(n-2));
}
}

- Anonymous August 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

use dynamic programming. Store the results of a computation during the first all and reuse subsequently instead of computing at every call.

- Abhishek January 02, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

/*dynamic programming version,using cache O(n), here array's scope is [0,n-1]*/
int fib_one(int n,int *array){

int rs1,rs2;
if(n==0){
return 0;
}
else if(n==1){
return 1;
}
else{
rs1=array[n-1];
if(rs1==-1){
rs1=fib_one(n-1,array);
}
rs2=array[n-2];
if(rs2==-1){
rs2=fib_one(n-2,array);
}
return rs1+rs2;
}
}

- wei April 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="" line="1" title="CodeMonkey52582" class="run-this">
#include <iostream>
#include <cstdio>

using namespace std;

int fib(int n){
unsigned long long fib1=1,fib2=1,fibr;
for(int i=2;i<=n;i++){
fibr= fib1+fib2;
fib1 = fib2;
fib2 = fibr;
}
return fibr;

}

int main(){
int n;
cin>>n;
cout<<fib(n)<<endl;
return 0;
}
</pre><pre title="CodeMonkey52582" input="yes">
</pre>

- Anonymous April 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static int fib(int n)
	{
		if(n==0)
		{
			return 0;
		}
		else
			if(n==1 || n==2)
				return 1;
		
		return fib(n-1)+fib(n-2);
	}
	
	static int fib1(int n)
	{
		int c=0,a=0,b=1;
		for(int i=2;i<=n;i++)
		{
			c=a+b;
			a=b;
			b=c;
		}
		
		return c;
	}

- Anonymous October 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class fibb {

	public static void main(String[] args) {
	int a= fib(10);
	System.out.print(a);


	}
	static int fib(int n)
	{
		if(n==0)
		{
			return 0;
		}
		else
			if(n==1)
				return 1;
		
		return fib(n-1)+fib(n-2);
	}
	
	
}

- disun March 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Python working code.

"""
8:29
@Python 2.7

write a code of fibonacci series.

- sonali on August 03, 2010 Report Duplicate | Flag 
"""

class Fbi(object):
  def __init__(self, n):
    if n is None:
      print 'invalid n'
      raise SystemExit
      
    self._n = n
    
  def find(self, number = None):
    if number is None:
      number = self._n
      
    if number == 0:
      return 0
    elif number == 1:
      return 1
    else:
      return self.find(number-1) + self.find(number-2)
      
if __name__ == '__main__':
  f = Fbi(30)
  print f.find()

- tosay.net March 20, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

//prints the fibonacci series


# include<stdio.h>
# include<conio.h>
void main()
{
int a=0,b=1,i=0;
for(i=0;i<=10;i++)
{
printf("%d",a);
a=a+b;
b=a-b;
}
getch();
}

- Coder August 09, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class Fibonacci{
	
	public static void main(String args[])
	{
		int n = 10;
		int a = 0;
		int b = 1;

		System.out.println(a);
		System.out.println(b);
		for(int i = 2; i<= n; i++){
			int c = a + b;
			System.out.println(c);
			a= b;
			b = c;

		}

	}
}

- Anonymous October 19, 2014 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More