Re: [algogeeks] FUNCTION POINTER IN C

2011-09-06 Thread Puneet Ginoria
i didn't go you..
It will be helpful if you could give me some running example or give me some
link..
Thnx in Advance..

-- 
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] FUNCTION POINTER IN C

2011-09-06 Thread Puneet Ginoria
i am getting things in C++ but i need all this to be done in C.

-- 
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] max product!

2011-08-07 Thread Puneet Ginoria
find the first three largest nos. and 3 smallest number(negatives).. then
easily you can fig. out the solution..

O(6n) solution i guess which is O(n)

-- 
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] Fwd: max product

2011-08-07 Thread Puneet Ginoria
find the first three largest nos. and 3 smallest number(negatives).. then
easily you can fig. out the solution..

O(6n) solution i guess which is O(n)

-- 
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] MS: BST

2011-07-11 Thread Puneet Ginoria
@saurabh:

finding succesor may not be O(1)... it can be O(logn)

-- 
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] Number Series

2011-07-10 Thread Puneet Ginoria
A[n] = n*(n+1)*(n+2)

1*2*3 = 6
2*3*4 = 24
3*4*5 = 60
4*5*6 = 120
so next numbers are 210,336

-- 
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: find sol!!

2011-07-10 Thread Puneet Ginoria
n*n! = (n+1)! - n!

-- 
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: Java Book

2011-06-13 Thread Puneet Ginoria
Java in 60 Minutes A Day..
by Rich Raposa..

its a good book for begginers...

-- 
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: Divide 2 nos. without DIVISON

2011-05-22 Thread Puneet Ginoria
thnxx all.. i got the soln..
Qdumanshu: i was asking for quotient and remainder when we divide 2 nos.
without actually dividing them...




-- 
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: nearest neighbour

2011-05-19 Thread Puneet Ginoria
I guess the sorting in this case is not O(nlogn)
If the nos. we are associating with each person from the number line , it
can be sorted in O(n) time, if those nos. are in from {1,2,..n}.
Correct me if I am Wrong

-- 
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] ThreeListSum

2011-01-14 Thread Puneet Ginoria
Sorry.. u need 2 sort only one array. whichever u likei was thinking to
sort 1 array and wrote to sort all 3 anyway ... sort only one

On Tue, Jan 11, 2011 at 1:18 PM, MOHIT  mohit...@gmail.com wrote:

 @ puneet then we have to sort only one array, on which we doing binary
 search why all 3?

  --
 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.



Re: [algogeeks] ThreeListSum

2011-01-10 Thread Puneet Ginoria
sort all 3 arrays. then for any every combination of numbers in 2 arrays
say, a and  b do a binary search for element -(a+b) in the third array. It
would be a O(N^2 logN) algorithm
On Tue, Jan 11, 2011 at 12:04 PM, Decipher ankurseth...@gmail.com wrote:

 Given three lists: A, B and C of length n each. Write a function which
 returns true if any 3 three numbers (1 from each list), sum up to zero. Else
 return false, if there is no such combination.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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] DIVIDE TWO VARYING LENGTH NUMBERS.

2010-12-26 Thread Puneet Ginoria
I think that won't be feasible bcoz of high time complexity. Either you can
use Python language which provides its own big number pakage or check this
link.

http://www.cse.iitd.ernet.in/~suban/CSL102/rsa/node21.html

On Mon, Dec 27, 2010 at 2:17 AM, Aniket aniket...@gmail.com wrote:

 DIVIDE TWO VARYING LENGTH NUMBERS
 EX: ONE CAN BE UPTO 60 DIGIT AND OTHER 40 DIGIT

 Well,I thought of an approach.Store each digit of  each number in two
 separate integer arrays(From right to left).Then apply the subtraction
 method.Will it be feasible?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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: Don't Sort

2010-12-25 Thread Puneet Ginoria
I can use bucket sort.But sorting is strictly prohibited. The question gives
a hint which says use your data structure theory to figure this one out.

On Sat, Dec 25, 2010 at 9:16 PM, juver++ avpostni...@gmail.com wrote:

 You may use bucket sort if extra space is enough.
 Second approach - find (log n)-th statistic and then (log n + sqrt n).
 After doing so you may output all students that have marks below
 corresponding bounds.
 There is O(n) algorithm for finding such values.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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: Find all the subset of an array whose sum is equal to some number

2010-12-25 Thread Puneet Ginoria
This attachment contains the code for the above program in SML language and
it uses lambda calculus.

On Sat, Dec 25, 2010 at 9:18 PM, juver++ avpostni...@gmail.com wrote:

 What you need to get for the answer - amount of such subsets or display
 them?
 First problem can be solved using DP.
 Second - brute force.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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: Find all the subset of an array whose sum is equal to some number

2010-12-25 Thread Puneet Ginoria
sorry i forgot to attach here it is

On Sat, Dec 25, 2010 at 10:34 PM, Puneet Ginoria punnu.gino...@gmail.comwrote:

 This attachment contains the code for the above program in SML language and
 it uses lambda calculus.


 On Sat, Dec 25, 2010 at 9:18 PM, juver++ avpostni...@gmail.com wrote:

 What you need to get for the answer - amount of such subsets or display
 them?
 First problem can be solved using DP.
 Second - brute force.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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.


fun depthfirst next pred x =
let
fun dfs([]) = []
  | dfs(x::xs)  =
if pred(x) then x::dfs(xs)
else dfs(next(x) @ xs)
in
dfs([x])
end;


fun sum([]) = 0 | sum(x::xs) = x + sum(xs);

fun check n ls = (sum(ls)=n);

fun last([]) = []
|last(x::xs) = if xs=[] then [x] else last(xs);

fun filt([],soln) = []
|filt(x::xs,soln) = 
let
fun helper(x::xs,[y]) = if x=y then xs else 
helper(xs,[y])
in
if last(soln) = [] then (x::xs) else 
helper(x::xs,last(soln))
end;


fun listify(soln,[]) = []
|listify(soln,x::xs) = (op@(soln,[x]))::listify(soln,xs);

fun nextset ls soln = listify(soln,filt(ls,soln));

fun subset ls n = depthfirst (nextset ls) (check n) [];


Re: [algogeeks] random function

2010-12-24 Thread Puneet Ginoria
volume 2 , chapter 3

On Fri, Dec 24, 2010 at 11:13 AM, Puneet Ginoria punnu.gino...@gmail.comwrote:

 There is a book called The art of computer programming by donald knuth.
 He had discussed the random function in great detail.


 On Tue, Dec 21, 2010 at 8:06 PM, snehal jain learner@gmail.comwrote:

 How do you write your own random function?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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] random function

2010-12-23 Thread Puneet Ginoria
There is a book called The art of computer programming by donald knuth. He
had discussed the random function in great detail.

On Tue, Dec 21, 2010 at 8:06 PM, snehal jain learner@gmail.com wrote:

 How do you write your own random function?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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] Answer This

2010-12-18 Thread Puneet Ginoria
@Terence : I think this could be the best reason

On Fri, Dec 17, 2010 at 1:58 PM, Terence technic@gmail.com wrote:

  I think nobody dies on the first 19 days and everyone dies on the 20th
 day.
 (I have no difference with other green-eyes. Why I have to suicide ealier?
 : )

 Given: a) there was at least one green-eyed among them,
 we could get the following conclusions:
 1) If there is exactly 1 green-eye,  he committed suicide on the first day.

 2) If there is exactly 2 green-eye,  they all committed suicide on the
 second day.
 ...
 n) If there is exactly N green-eye,  they all committed suicide on the N'th
 day.

 1) is obvious. (No one else he saw is green-eye)
 For n), each of the N green-eyed persons saw (N-1) green-eye persons.
 If there were only (N-1) green-eyed persons, they had committed suicide on
 the (N-1) th day, according to the previous conclusion.
 So no suicides on the first (N-1) days means there were more green-eyed
 persons, ie. he is one of them.
 Each of the N green-eyed persons realized this on the N'th day, and
 commited suicide.



 On 2010-12-17 15:34, Iqbal Nouyed wrote:

 I think Aditya is correct,

 1) it never says nobody dies on the first 19 days, just says by the 20th
 day all the green eyed commit suicide.
 2) God said that, He also assured them that there was at least one
 green-eyed among them.


 Cheers.


 On Fri, Dec 17, 2010 at 1:30 PM, Krishna Narasimhan 
 krishna.n...@gmail.com wrote:

 Aditya,

  1) Nobody dies on the first 19 days everyone dies on the 20th day.
 2) Even if it wasnt the case, why should he die just because nobody else
 did? Is there any condition on THERE SHOULD BE ATLEAST ONE GREEN EYED GUY?


 On Fri, Dec 17, 2010 at 12:52 PM, Aditya Agrawal adit6...@gmail.comwrote:

 20 green eys ppl ..
 At the end of first day person realize no body dies so he is the one with
 green eye's so he commit sucide ...
 Similarly on second  day .. hence forth 20 people commit suicide in 20
 days ..


 On Fri, Dec 17, 2010 at 11:05 AM, punnu punnu.gino...@gmail.com wrote:

 In an ancient village, there were some green-eyed and blue-eyed
 persons. One fine day,
 God instructed them, the day on which you come to know that you are a
 green-eyed,
 you should commit suicide ... He also assured them that there was at
 least one green-eyed
 among them. Well, all the villagers were very intelligent and strict
 followers of
 God. But, no one knew color of his own eyes! They didn't have mirrors.
 They
 couldn't even communicate with each other. All that they could do is
 to see color
 of other's eyes. It happened that on 20th day, all the green-eyed
 people committed
 suicide. So, how many green-eyed were there ?

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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.




  --
 
 I dare do all that may become a man; Who dares do more, is none - Macbeth,
 twelfh night!
 Regards
Krishna
  --
  You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@googlegroups.com.
To unsubscribe from this group, send 

Re: [algogeeks] Re: zero sum subarray

2010-11-30 Thread Puneet Ginoria
You may solve it using depth first search. it will give you all possible
solutions

On Sun, Nov 7, 2010 at 12:11 AM, Raj rajmangaltiw...@gmail.com wrote:

 Compute PrefixSum Array.
 PrefixSum[i]=a[0]+a[1]+a[2]++a[i-1]+a[i]

 Now problem reduces to finding two elements having same value.


 For  PrefixSum[i], search an element having value PrefixSum[i] in
 array PrefixSum from indices 0 to i-1.
 Linear search would cost O(n^2), balanced tree O(nlogn), hash O(n).


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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.