[algogeeks] [brain teaser ] 6april

2011-04-06 Thread Lavesh Rawat
* The Ball Puzzle *How can you throw a ball as hard as you can and have it come back to you, even if it doesn't bounce off anything? There is nothing attached to it, and no one else catches or throws it back to you. Update Your Answers at : Click

Re: [algogeeks] [brain teaser ] 6april

2011-04-06 Thread balaji a
when u throw it above u. On Wed, Apr 6, 2011 at 1:16 PM, Lavesh Rawat lavesh.ra...@gmail.com wrote: * The Ball Puzzle *How can you throw a ball as hard as you can and have it come back to you, even if it doesn't bounce off anything? There is nothing attached to it, and no one else

Re: [algogeeks] [brain teaser ] 6april

2011-04-06 Thread Akash Agrawal
throw opposite to gravity... Regards, Akash Agrawal http://tech-queries.blogspot.com/ On Wed, Apr 6, 2011 at 1:26 PM, balaji a peshwa.bal...@gmail.com wrote: when u throw it above u. On Wed, Apr 6, 2011 at 1:16 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: * The Ball Puzzle *How can

[algogeeks] i am new

2011-04-06 Thread a_SillyGuy
hi , i've recently joined this group in a mood to master the algorithms. Will someone tell ,weather i will be benifitted by this group or not. ??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] i am new

2011-04-06 Thread Carl Barton
Yes On 6 April 2011 11:36, a_SillyGuy ammukumar...@gmail.com wrote: hi , i've recently joined this group in a mood to master the algorithms. Will someone tell ,weather i will be benifitted by this group or not. ??? -- You received this message because you are subscribed to the Google

Re: [algogeeks] [brain teaser ] 6april

2011-04-06 Thread kunal srivastav
toughest puzzle ever :P On Wed, Apr 6, 2011 at 1:27 PM, Akash Agrawal akash.agrawa...@gmail.comwrote: throw opposite to gravity... Regards, Akash Agrawal http://tech-queries.blogspot.com/ On Wed, Apr 6, 2011 at 1:26 PM, balaji a peshwa.bal...@gmail.com wrote: when u throw it above

[algogeeks] Interview Question

2011-04-06 Thread Umer Farooq
Hello friends, The following question has appeared in two top companies of my city. I'd appreciate if anyone is able to answer it. Given a singly liked list comprising of three nodes Delete the middle node such that: 1- A temp pointer is pointing to the first node 2- A temp pointer is pointing

Re: [algogeeks] Output of the code

2011-04-06 Thread Umer Farooq
btw, true is defined in cpp. On Mon, Mar 28, 2011 at 12:54 PM, Umer Farooq the.um...@gmail.com wrote: The compiler doesn't want to get killed like poor

Re: [algogeeks] Re: 28march

2011-04-06 Thread Abhishek Sharma
@sourabh: could u please elaborate how u came to that conclusion. Dave's logic seems to be right.. On Thu, Mar 31, 2011 at 11:00 AM, sourabh jakhar sourabhjak...@gmail.comwrote: answer is 6 races On Mon, Mar 28, 2011 at 11:53 PM, Dave dave_and_da...@juno.com wrote: 7 races. For the

Re: [algogeeks] Output of the code

2011-04-06 Thread Umer Farooq
java: System.out.println(Hamara cricket sey kiya waasta yaaro! \nHamara tou qaumi khail Hockey hai!); On Tue, Mar 29, 2011 at 2:29 PM, pacific :-) pacific4...@gmail.com wrote: ruby : putsIndia will win the worldcup 2011 On Mon, Mar 28, 2011 at 9:04 PM, shady sinv...@gmail.com wrote:

[algogeeks] C puzzle

2011-04-06 Thread navin
see this c code. #includestdio.h void fn (int *ptr) { const int val=100; ptr=val; } void fn1(int *ptr) { *ptr = 100; } main() { int i=10; printf(%d , i); fn(i); printf(%d , i); fn1(i); printf(%d , i); } What is the difference

Re: [algogeeks] [brain teaser ] 1april

2011-04-06 Thread Kamakshii Aggarwal
B On 4/1/11, Praveen praveen200...@gmail.com wrote: B On Fri, Apr 1, 2011 at 1:38 PM, Rajeev Kumar rajeevprasa...@gmail.comwrote: Similar question; http://www.techinterview.org/post/518744816/more-hat-puzzles On Fri, Apr 1, 2011 at 1:02 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote:

Re: [algogeeks] Are U a Student Must Read this Frwd This Please If u Like We R student like You TOO

2011-04-06 Thread Abhishek Sharma
@Carl: the one at the bottom works.. On Fri, Apr 1, 2011 at 1:17 AM, hary rathor harry.rat...@gmail.com wrote: everybody want to be mark. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: Check out One More Interesting Challenging Question...Longest Consecutive Elements Sequence.

2011-04-06 Thread Patidarchat Gmal
this is one of the Standards problems , i don't believe there is any solution in O(n) best solution from wiki also have complexity O(nlog(n)) http://en.wikipedia.org/wiki/Longest_increasing_subsequence how did you made this criteria..search O(n) space O(1) , On 28-03-2011 18:37, Kunal

Re: [algogeeks] Re:

2011-04-06 Thread Umer Farooq
hhahahahahahahhahaha Bohat aalaa sir! :D caught red-handed :D :P Ow please tell us the solution, I'm interested in knowing the answer :D On Sun, Apr 3, 2011 at 9:02 PM, Carl Barton odysseus.ulys...@gmail.comwrote: Haha On 3 April 2011 15:28, Arpit Sood soodfi...@gmail.com wrote:

Re: [algogeeks] Application of Data Structure System Design

2011-04-06 Thread Ashim Kapoor
int max_calls[no_of_customers][30]; On any phone call -- max_calls[customer_id][day]++; On hangup -- max_call[customer_id][day]--; This would store max calls for each customer on each day. Does the length of the call have to be taken into account ? Your question is not clear on that. On Tue,

Re: [algogeeks] Ties The Rope With Minimum Cost ..Interesting For Geeks

2011-04-06 Thread Anurag Sharma
I think the greedy method of taking the current minimum sized 2 ropes and tying them will do. Consider this algo:- int getMinCost(){ priority_queue pq; insert all thread sizes to pq; int sum=0; while(!pq.empty()){ int a=pq.extractmin(); //O(logn) int b=pq.extractmin(); sum+=a+b;

Re: [algogeeks] Application of Data Structure System Design

2011-04-06 Thread Ashim Kapoor
no this is wrong. maintain 2 arrays int max_calls[no of cust][31] int current_no_of_calls[no of customers] both array of customers are initialized to zero. on call current_no_of_calls[cust_id]++; if above max[id][day] then max_calls[id][day] = above on hangup current_no_of_calls[cust_id]--;

Re: [algogeeks] finds a pair of close numbers

2011-04-06 Thread Ashim Kapoor
On Fri, Apr 1, 2011 at 6:02 PM, snehal jain learner@gmail.com wrote: For a set S of n real numbers, a pair of elements x, y belong to S, where x y, are said to be close if y – x = ( max(S) – min(S) ) / (n-1) Suppose you are given an unsorted array A[1 : n] of distinct real numbers.

Re: [algogeeks] Re: How to check whether a language isTuring Complete?

2011-04-06 Thread Wladimir Tavares
Rather, your question is not stupid. The general definition of computability is not well defined. We define the notion of computability by Turing Machine and the Church-Turing thesis states that all computer models come into agreement . But the new models of computation pose a challenge to modern

Re: [algogeeks] [brain teaser ] 29march

2011-04-06 Thread Vijay Thakur
*1, 1+3^0, 2+3^1, 5+3^2, 14+3^3, 41+3^4=(122)* On Thu, Mar 31, 2011 at 11:20 AM, rahul rahulr...@gmail.com wrote: 1+1+0, 2+2+1, 5+5+4, 14+14+13, 41+41+40 On Tue, Mar 29, 2011 at 1:05 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: *Series Problem Solution* 1, 2, 5, 14, 41, x Whats

Re: [algogeeks] [brain teaser ] 2april

2011-04-06 Thread Kamakshii Aggarwal
'E' On Mon, Apr 4, 2011 at 4:24 PM, Vandana Bachani vandana@gmail.comwrote: Letter 'e' On Mon, Apr 4, 2011 at 1:14 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: *WHAT AM I Problem Solution* * *The beginning of eternity. The end of time and space. The beginning of every end and the

Re: [algogeeks] Output of the code

2011-04-06 Thread Umer Farooq
The compiler doesn't want to get killed like poor manihttp://www.allvoices.com/s/event-8408191/aHR0cDovL2JsYWNrY29icmEucG9zdGVyb3VzLmNvbS9leHRyZW1pc3QtaW5kaWEta2lsbHMtdGhlLXBvb3ItcGFycm90LWZvci1wcmU=, therfore it is giving a compiler error :P On Mon, Mar 28, 2011 at 10:43 AM, balaji a

Re: [algogeeks] Ties The Rope With Minimum Cost ..Interesting For Geeks

2011-04-06 Thread Patidarchat Gmal
i think the answer of the question will be constant to if S=sum of length of all the rops , N=number of rops then total cost will be *S*log(N)* just make pair of two - two sticks tie them , repeat it again again, Explanation of answer: since every time we tie the cost at that level

Re: [algogeeks] Re: Check out One More Interesting Challenging Question...Longest Consecutive Elements Sequence.

2011-04-06 Thread Ashim Kapoor
One more query, insert into bst is O(n) and then do inorder to get them in sorted order. This is an example of sorting in O(n) time. is this correct? On Mon, Mar 28, 2011 at 6:06 PM, Ashim Kapoor ashimkap...@gmail.com wrote: How do you use inorder traversal to find longest sub sequence? On

Re: [algogeeks] Re: Median of Binary Tree

2011-04-06 Thread Anurag Bhatia
@bittu: Can we modify the tree to store extra info? On Mon, Mar 28, 2011 at 4:16 PM, bittu shashank7andr...@gmail.com wrote: @all try to understand the question as usual we have to do it in min. time space complexity ..in mean Time O(n) space o(1) At-most just tell em after doing in-order

Re: [algogeeks] Re: Check out One More Interesting Challenging Question...Longest Consecutive Elements Sequence.

2011-04-06 Thread Ashim Kapoor
How do you use inorder traversal to find longest sub sequence? On Mon, Mar 28, 2011 at 6:03 PM, bittu shashank7andr...@gmail.com wrote: its (not aplicable). sorting nlogn i said time O(n) O(1) space i think we can use BST , put all elements in BST O(n) then do inorder to find longest

Re: [algogeeks] Re: How to Implement a HashMap

2011-04-06 Thread Wladimir Tavares
The hashmap of Java is implemented using hash tables, we note that the parameters that affect performance: initial capacity and load factor. http://download.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html The associative array of C + + (map) is implemented using red-black tree ( balanced

Re: [algogeeks] Re: finds a pair of close numbers

2011-04-06 Thread Ashim Kapoor
Hi , Use Hashing for That , for sum =12 arr[]={2,4,3,6,5,8,7}; store in to hashtable for each index=0 in loop find sum-arr[index] so fro sum =12 if we do index=1 a[1]=4 sum-a[1]=8 so stop it we have done..hope make d perfect code. time Complxity o(n) space size of hashtable Let me

Re: [algogeeks] i am new

2011-04-06 Thread Umer Farooq
This is a great group. Here, we share our knowledge and get to know a lot of new algorithmic techniques. On Wed, Apr 6, 2011 at 4:08 PM, Carl Barton odysseus.ulys...@gmail.comwrote: Yes On 6 April 2011 11:36, a_SillyGuy ammukumar...@gmail.com wrote: hi , i've recently joined this group in

Re: [algogeeks] [brain teaser ] 6april

2011-04-06 Thread Umer Farooq
haha :) On Wed, Apr 6, 2011 at 4:12 PM, kunal srivastav kunal.shrivas...@gmail.comwrote: toughest puzzle ever :P On Wed, Apr 6, 2011 at 1:27 PM, Akash Agrawal akash.agrawa...@gmail.comwrote: throw opposite to gravity... Regards, Akash Agrawal http://tech-queries.blogspot.com/ On

Re: [algogeeks] Re: Facebook Interview Question....Heavy Number

2011-04-06 Thread Nikhil Jindal
Ok. Here's a possible O(n) solution. Assuming last digit of a is 0. for(n=a;n=b;n+=10) { Calculate the sum of digits, leaving the last digit. Find the minimum value of last digit for it to be a heavy number. Increment count by 10-that number. } So here, complexity will be: O(n/10*(d-1)) where, d

Re: [algogeeks] [brain teaser ] 1april

2011-04-06 Thread Pratik Kathalkar
if B and C have same color than A can speak the colour else B will. On Fri, Apr 1, 2011 at 1:02 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: *Christmas Tree Problem * * *Four angels sat on the Christmas tree amidst other ornaments. Two had blue halos and two – yellow. However, none of

[algogeeks] Re: Check out One More Interesting Challenging Question...Longest Consecutive Elements Sequence.

2011-04-06 Thread SVIX
I don't think you should sort, should u? the problem is to find the longest sequence of consecutive elements in the given array right? On Mar 28, 6:07 am, Kunal Patil kp101...@gmail.com wrote: @Bittu: Can you elaborate more how Constructing BST (I hope it stands for Binary Search Tree) would

[algogeeks] Re: finds a pair of close numbers

2011-04-06 Thread Don
// O(n) solution using binning findClose(int n, double A[n]) { // Find min and max min = max = A[0]; for(i = 1; i n; ++i) { if (A[i] max) max = A[i]; if (A[i] min) min = A[i]; } // Set up bins int bins = n-1; double binWidth = (max - min) / bins; double binTable[bins]

Re: [algogeeks] Re: Algo to identify loose ends of each cable in minimum time.

2011-04-06 Thread Munish Goyal
I think Dave is right and his solution also seems correct. Answer is 20KM i.e. 2 trips. Good work @Dave. On Wed, Apr 6, 2011 at 7:43 PM, Dave dave_and_da...@juno.com wrote: @Bittu: Actually, this is an easier problem than the Graham-Knowlton Problem. It the GKP, you can only connect wires at

Re: [algogeeks] Interview Question

2011-04-06 Thread Anurag atri
in case you are given a pointer to the first node simply do temp -next = ( temp - next ) - next . if you are given a pointer to the second node do , temp - data = ( temp - next ) - data ; temp - next = NULL ; correct me if I am wrong . On Mon, Apr 4, 2011 at 9:48 PM, Umer Farooq

Re: [algogeeks] Re: Median of Binary Tree

2011-04-06 Thread Pratik Kathalkar
What exactly the median of a Binary Tree means? On Mon, Mar 28, 2011 at 4:38 PM, Anurag Bhatia abhati...@gmail.com wrote: @bittu: Can we modify the tree to store extra info? On Mon, Mar 28, 2011 at 4:16 PM, bittu shashank7andr...@gmail.com wrote: @all try to understand the question as

[algogeeks] Re: Please help in verifying the speed of this algorithm - factorizing or prime finder.

2011-04-06 Thread Don
The General Number Field Sieve is the fastest known method of factoring large numbers, but the elliptic curve method may be faster in some cases. Either one is much faster than your method. Don On Apr 6, 12:58 pm, harish hareeshgn...@gmail.com wrote: Hi all, I have developed an algorithm to

[algogeeks] Re: C puzzle

2011-04-06 Thread Don
In fn, ptr is a local variable passed by value. Changing ptr in the function does not change anything in main. Don On Mar 31, 10:35 pm, navin navin.myhr...@gmail.com wrote: see this c code. #includestdio.h void fn (int *ptr) {        const int val=100;        ptr=val;} void fn1(int

Re: [algogeeks] Re: C puzzle

2011-04-06 Thread rohit agarwal
I fn we are simply changing the address in ptr means ptr will now points to another variable i.e val In fn1 we are changing the value of a variable to which ptr is pointing i.e i so i will be changed. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Re: another google telephone interview question

2011-04-06 Thread Bala
I think one way to solve is to build a max heap of the array(in place). Now remove the max element and keep it at the end and reheapify. This algorithm takes O(nlogn). I am not able to think how to make O(nlogk). -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: 28march

2011-04-06 Thread Manish Pathak
There are two answers 11 and 7 On Thu, Mar 31, 2011 at 12:23 PM, Abhishek Sharma jkabhishe...@gmail.comwrote: @sourabh: could u please elaborate how u came to that conclusion. Dave's logic seems to be right.. On Thu, Mar 31, 2011 at 11:00 AM, sourabh jakhar sourabhjak...@gmail.comwrote: