[algogeeks] Re: partition array

2011-01-19 Thread manoj
if you don't distroy the oder in which elements are stored in array
then this problem is just a cake walk.

Requirement of question?

On Jan 19, 11:49 am, Aditya adit.sh...@gmail.com wrote:
 this could be solved by using dynamic programing (knapsack problem)

 On 1/19/2011 12:30 AM, juver++ wrote:

  Did you mean absolute difference between two subsets is minimal? --
  You received this message because you are subscribed to the Google
  Groups Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Regards Aditya

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: google mcqs

2011-01-19 Thread bittu
Q4 its  One Binary Semaphore problem  try different combination while
preserving original values of S  T

Q2   A  Please Read Out SJF (CPU Scheduling Algorithm)

Q3  C.. Please Read What is Paging  Page Fault --performance is
Answer Chosen By Navies not Experts.. Actual Answer is Less Page
Faults
why answer is not segmentation fault  because its related
to memory area that is not permitted   user tries to access ..so
memory violation..




Thanks  Regards
Shashank  Don't B Evil U Can Learn While U Earn

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Building A Special Tree

2011-01-19 Thread bittu
How we can  build a tree with only one traversal ..i think to build a
tree atlesat two traversal  required e.g

N
 /  \
N   N
   /  \  /   \
  N   L   NL
  / \  /   \
N  NN  N

 so preorder  is given by NLL

Therefore, following combination can uniquely identify a tree.

Inorder and Preorder.
Inorder and Postorder.
Inorder and Level-order.

And following do not.

Postorder and Preorder.
Preorder and Level-order.
Postorder and Level-order.

This is Very important Question Asked  In Amazon Please Have a Closer
look at Question...   Please let me know any solution exist

Thanks  Regards
Shashank Mani


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Building A Special Tree

2011-01-19 Thread juver++
@bittu
We have complete binary tree. Preorder information about nodes and leaves is 
enough.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: find triplets in an integer array A[] which satisfy condition: a[i]^2 + a[j]^2 = a[k]^2

2011-01-19 Thread bittu
Algo

loop down  array find 2 elements such that c= sqrt(a*a + b*b)
 compare if( c*c ==a*a+b*b) //can be optimized we can leave this line
just writing fro clarification  if yes prints all the combination

For This I Have  A Gud Working Solution  which has time complexity of
O(n^2)

Lets genralize this question fro some k  say k=100 means we wants to
find out all triplets which is less then kth (here 100)   number

so
 int n=100;
 void doit()
 {
int n2 = n*n;
int count = 0;

for (int a=0; a=n; ++a)
for (int b=a; b=n  a*a+b*b=n2;++b)
{
int c = (int) Math.sqrt(a*a + b*b);
if (c*c == a*a + b*b)
{
printf(( + a + ,  + b + ,  + c + 
) );
count++;
}
}

printf(There are  + count +  combinations.);
}

In Case of Array we need to put a[i] e.g. array elements for which we
need to find out triplets that is also On^n)
solution .Optimization with Others are welcomes.
But this algo will works fine. will not led any error.

Please Write Comment if Anything Wrong with above program or how we
can improve optimize it..because after analyzing u will find that so
many steps
unnecessary calculated ..although we don't want that...


Thanks  Regards
Shashank Mani don't B evil U Can Earn While U Learn



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Sites for Interview Questions

2011-01-19 Thread Aviral Gupta
http://coders-stop.blogspot.com/

On Jan 19, 12:47 pm, Decipher ankurseth...@gmail.com wrote:
 Careercup.com is best but for beginners you can also see geeksforgeeks.org .

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Amazon Again

2011-01-19 Thread bittu
@radha krishnanan do u  means this

http://en.wikipedia.org/wiki/Matrix_exponential

anyways got it.

Regards
Shashank

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Largest BST in Binary Tree

2011-01-19 Thread bittu
@balaji...Gud work..man

Keep goin On

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Google Question

2011-01-19 Thread bittu
Given

1. A
2. Ctrl+A
3. Ctrl+C
4. Ctrl+V

If you can only press the keyboard for N times (with the above four
keys), please write a program to produce maximum numbers of A. If
possible, please also print out the sequence of keys.

So the input parameter is N (No. of keys that you can press), the
output is M (No. of As that you can produce).


Thanks  Regards
Shashank Mani

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Google Question

2011-01-19 Thread juver++
Keys 23 may be combined, cause there is no sense to use them separately. 
It's cost of pressing is 2, however.
For all other keys the cost is 1 though.
DP[i][n] - maximum number of A's we can produce with cost of pressings = i 
and we have string of A's with size n in a clipboard.
DP[N][any] - result. There are 

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Building A Special Tree

2011-01-19 Thread juver++
@above
You create your binary tree from scratch. Where is an input data with 
preorder labels?

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Google Question

2011-01-19 Thread Raj
http://www.ihas1337code.com/2011/01/ctrla-ctrlc-ctrlv.html

On Jan 19, 8:28 pm, bittu shashank7andr...@gmail.com wrote:
 Given

 1. A
 2. Ctrl+A
 3. Ctrl+C
 4. Ctrl+V

 If you can only press the keyboard for N times (with the above four
 keys), please write a program to produce maximum numbers of A. If
 possible, please also print out the sequence of keys.

 So the input parameter is N (No. of keys that you can press), the
 output is M (No. of As that you can produce).

 Thanks  Regards
 Shashank Mani

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Google Question

2011-01-19 Thread nishaanth
How about the following dynamic programming solution.

Let dp[i] be the max no of As with i keystrokes.

dp[i]=max(dp[i-1]+1,2*dp[i-3])

dp[N] is the required solution.

Correct me if i am wrong.

On Wed, Jan 19, 2011 at 9:20 PM, Raj rajmangaltiw...@gmail.com wrote:

 http://www.ihas1337code.com/2011/01/ctrla-ctrlc-ctrlv.html

 On Jan 19, 8:28 pm, bittu shashank7andr...@gmail.com wrote:
  Given
 
  1. A
  2. Ctrl+A
  3. Ctrl+C
  4. Ctrl+V
 
  If you can only press the keyboard for N times (with the above four
  keys), please write a program to produce maximum numbers of A. If
  possible, please also print out the sequence of keys.
 
  So the input parameter is N (No. of keys that you can press), the
  output is M (No. of As that you can produce).
 
  Thanks  Regards
  Shashank Mani

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
S.Nishaanth,
Computer Science and engineering,
IIT Madras.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: google mcqs

2011-01-19 Thread nishaanth
RAM Question ;- Ans D... Larger RAM - Larger number of frames per process
- lesser number of pagefaults - increased performance.

Scheduling :- Ans D..All are correct. @all those guys who say only I and
III, why not II ? Preemption doesnt guarantee bounded waiting.Starvation may
still happen.

Correct me if i am wrong.



-- 
S.Nishaanth,
Computer Science and engineering,
IIT Madras.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Amazon Again

2011-01-19 Thread Dave
If the matrix is diagonalizable, then it can be raised to any power in
O(n^3) independent of k. Find the eigenvalue/eigenvector decomposition
of the matrix, raise the eigenvalues to power k, and then multiply on
the right and left by the matrix of eigenvectors and its inverse,
respectively.

Dave

On Jan 12, 6:58 am, bittu shashank7andr...@gmail.com wrote:
 How will you raise a n x n matrix to the power k efficiently. What's
 the time complexity and space complexity of you algorithm? How will
 you optimize this?

 Thanks Regards
 Shashank Don't b Evil U Can Earn While U Learn

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: google mcqs

2011-01-19 Thread Anand
Pipeline : Choice B : 165 ( this pipeline wastes 20 ns between last 2 stages
for each item )
Scheduling : Choice B
Few page faults : Choice D
Synchronization : Choice B



On Wed, Jan 19, 2011 at 10:26 AM, nishaanth nishaant...@gmail.com wrote:

 RAM Question ;- Ans D... Larger RAM - Larger number of frames per process
 - lesser number of pagefaults - increased performance.

 Scheduling :- Ans D..All are correct. @all those guys who say only I and
 III, why not II ? Preemption doesnt guarantee bounded waiting.Starvation may
 still happen.

 Correct me if i am wrong.



 --
 S.Nishaanth,
 Computer Science and engineering,
 IIT Madras.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.