Re: [algogeeks] Re: Million Numbers

2011-06-10 Thread Vetri Balaji
@ankit: pls explain the time complexity.. i dont think its O(log n) On Thu, Jun 9, 2011 at 11:57 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Dumanshu: In each iteration, we r removing the smallest number. If at any iteration we can't find the next smallest no., it means that no. is

Re: [algogeeks] Re: Million Numbers

2011-06-10 Thread varun pahwa
@ankit :please explain by taking an example. On Fri, Jun 10, 2011 at 12:13 PM, Vetri Balaji vetribal...@gmail.comwrote: @ankit: pls explain the time complexity.. i dont think its O(log n) On Thu, Jun 9, 2011 at 11:57 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Dumanshu: In each

Re: [algogeeks] Re: Million Numbers

2011-06-10 Thread ankit sambyal
@Balaji: Sorry, the time complexity was not O(log n). It is O(n). On Thu, Jun 9, 2011 at 11:43 PM, Vetri Balaji vetribal...@gmail.com wrote: @ankit: pls explain the time complexity.. i dont think its O(log n) On Thu, Jun 9, 2011 at 11:57 PM, ankit sambyal ankitsamb...@gmail.com wrote:

Re: [algogeeks] Re: Million Numbers

2011-06-10 Thread varun pahwa
can anyone explain Since there are less than 2^32 numbers in the file there is bound to be one number in the array that is less than 2^16. in dumanshu's solution. On Fri, Jun 10, 2011 at 12:39 PM, varun pahwa varunpahwa2...@gmail.comwrote: @ankit :please explain by taking an example. On Fri,

[algogeeks] SPOJ THRBL

2011-06-10 Thread kartik sachan
http://www.spoj.pl/problems/THRBL/ my code is i am getting TLE # includeiostream # includecstdio using namespace std; //int search(long long int [],long long ) int main() { while(1) { int n,m; int count=0; long long int a[50010]={0}; int b[50010],c[50010]; if((scanf(%d%d,n,m))==EOF) break; int

Re: [algogeeks] Re: Million Numbers

2011-06-10 Thread ankit sambyal
Lets say we have 9 numbers from 1 to 10 and one number is missing. We hv a RAM which can accomodate only 3 nos. 9,6,7,4,3,2,1,5,10 So, we split the file into 3 smaller files each containing 3 nos. File1: 9,6,7 File2: 4,3,2 File3: 1,5,10 Now take each file into memory one by one and min heapify

Re: [algogeeks] Re: Million Numbers

2011-06-10 Thread Vetri Balaji
@ankit: think u missed heapify.. time complexity is O(n logn) On Fri, Jun 10, 2011 at 12:55 PM, ankit sambyal ankitsamb...@gmail.comwrote: Lets say we have 9 numbers from 1 to 10 and one number is missing. We hv a RAM which can accomodate only 3 nos. 9,6,7,4,3,2,1,5,10 So, we split the file

Re: [algogeeks] Re: Million Numbers

2011-06-10 Thread ankit sambyal
@Balaji : No, I didn't miss it. Since we had broken the file containing 300 million integers into smaller files containing much less numbers. So, the time complexity of min heapify is not O(logn), but it is O(log(no. of numbers in smaller file)), which is constant. Correct if I am wrong. On

[algogeeks]

2011-06-10 Thread aanchal goyal
There is a binary tree(Not a BST) in which you are given three nodes x,y,z .Write a function which finds whether y lies in the path b/w x and z. -- Regards,* Aanchal Goyal*. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] [brain teaser ] Find next number in series 10 june

2011-06-10 Thread • » νιρυℓ « •
42, 47 just guessing according to the pattern. On Fri, Jun 10, 2011 at 1:37 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: *Find next number in series * * * ** *What are the next two numbers in this sequence? 7, 14, 17, 21, 27, 28, 35, 37, ?, ? * * * *Update Your Answers at* : Click

Re: [algogeeks]

2011-06-10 Thread sunny agrawal
find common Ancestor of both. see if y lies on path from x or z to this ancestor O(lgn) On Fri, Jun 10, 2011 at 1:20 PM, aanchal goyal goyal.aanch...@gmail.comwrote: There is a binary tree(Not a BST) in which you are given three nodes x,y,z .Write a function which finds whether y lies in the

Re: [algogeeks]

2011-06-10 Thread Harshal
can be solved using dfs. On Fri, Jun 10, 2011 at 2:27 PM, sunny agrawal sunny816.i...@gmail.comwrote: find common Ancestor of both. see if y lies on path from x or z to this ancestor O(lgn) On Fri, Jun 10, 2011 at 1:20 PM, aanchal goyal goyal.aanch...@gmail.comwrote: There is a binary

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread abhishek iyer
@Karthik : Can you please the logic ??. Would be nice .. On Fri, Jun 10, 2011 at 12:42 PM, kartik sachan kartik.sac...@gmail.comwrote: http://www.spoj.pl/problems/THRBL/ my code is i am getting TLE # includeiostream # includecstdio using namespace std; //int search(long long int [],long

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread kartik sachan
what i understand from the problem was that. n no of higests are given and a and b and city no i.e from city a a ball is thrown to city no b so i have done from array a[] i.e hieght { n...no of times} find all the element between b[i].city A and

[algogeeks] Re: MS Interview

2011-06-10 Thread Dumanshu
Nothing is specified but lets take it as 2MB ram On Jun 10, 10:14 am, hary rathor harry.rat...@gmail.com wrote: dumnanshu  you should first mention memory size in your computer  so that i could know that how many number i can have in main memory at time -- You received this message because

Re: [algogeeks]

2011-06-10 Thread sunny agrawal
but that will be O(n) i think On Fri, Jun 10, 2011 at 2:38 PM, Harshal hc4...@gmail.com wrote: can be solved using dfs. On Fri, Jun 10, 2011 at 2:27 PM, sunny agrawal sunny816.i...@gmail.comwrote: find common Ancestor of both. see if y lies on path from x or z to this ancestor O(lgn)

Re: [algogeeks]

2011-06-10 Thread Harshal
@Sunny I am assuming that the tree is rooted. There is no 'parent' pointer. A / \ B C* / \ D* F* / \ J K / \

Re: [algogeeks]

2011-06-10 Thread sunny agrawal
thats why i mentioned x OR z and i m considering parent pointer :) without parent pointer both solutions will be O(n) :) On Fri, Jun 10, 2011 at 3:02 PM, Harshal hc4...@gmail.com wrote: @Sunny I am assuming that the tree is rooted. There is no 'parent' pointer. A

[algogeeks] Re: Million Numbers

2011-06-10 Thread Dumanshu
Hey the file has random 300 million numbers (9 digit)...there might be duplicates... not a particular sequence out of the many missing numbers we have to print just one... someone please try to understand the solution given alongwith the question. On Jun 10, 12:49 pm, ankit sambyal

Re: [algogeeks] [brain teaser ] Find next number in series 10 june

2011-06-10 Thread ankur aggarwal
42, 49 2011/6/10 • » νιρυℓ « • vipulmehta.1...@gmail.com 42, 47 just guessing according to the pattern. On Fri, Jun 10, 2011 at 1:37 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: *Find next number in series * * *** * * ** *What are the next two numbers in this sequence? 7, 14, 17,

Re: [algogeeks]

2011-06-10 Thread ross
@sunny agarwal : i dont think, it is O(lgn) its not a BST and further u need to check for existence of y in the path from lca to x or lca to z., so it l be O(n).. On Jun 10, 1:57 pm, sunny agrawal sunny816.i...@gmail.com wrote: find common Ancestor of both. see if y lies on path from x or z to

[algogeeks] write an algo that deletes all negative integers without changing the order of remaining elements of the queue

2011-06-10 Thread Sangeeta
write an algo that deletes all negative integers without changing the order of remaining elements of the queue -- 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

Re: [algogeeks]

2011-06-10 Thread sunny agrawal
@ross if a parent pointer is there lca can be found in lgn and path can be traversed in lgn too why it cannot be lgn what is the problem ?? On Fri, Jun 10, 2011 at 3:06 PM, sunny agrawal sunny816.i...@gmail.comwrote: thats why i mentioned x OR z and i m considering parent pointer :) without

Re: [algogeeks] write an algo that deletes all negative integers without changing the order of remaining elements of the queue

2011-06-10 Thread sunny agrawal
First algorithm taht comes in mind deque a element if +ve enque again if(-ve) do nothing now question is terminating condition On Fri, Jun 10, 2011 at 3:44 PM, Sangeeta sangeeta15...@gmail.com wrote: write an algo that deletes all negative integers without changing the order of remaining

Re: [algogeeks] [brain teaser ] Find next number in series 10 june

2011-06-10 Thread nicks
@ankur..how did you get that...explain..plz On Fri, Jun 10, 2011 at 3:11 AM, ankur aggarwal aggarwal11...@gmail.comwrote: 42, 49 2011/6/10 • » νιρυℓ « • vipulmehta.1...@gmail.com 42, 47 just guessing according to the pattern. On Fri, Jun 10, 2011 at 1:37 PM, Lavesh Rawat

Re: [algogeeks] write an algo that deletes all negative integers without changing the order of remaining elements of the queue

2011-06-10 Thread sunny agrawal
initialy cal size of queue then apply a for loop On Fri, Jun 10, 2011 at 4:00 PM, sunny agrawal sunny816.i...@gmail.comwrote: First algorithm taht comes in mind deque a element if +ve enque again if(-ve) do nothing now question is terminating condition On Fri, Jun 10, 2011 at 3:44 PM,

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread nicks
i agree with the logici also implemented it...and getting TLE...there must exist some better method :( On Fri, Jun 10, 2011 at 2:18 AM, kartik sachan kartik.sac...@gmail.comwrote: what i understand from the problem was that. n no of higests are given and a and b and city no

Re: [algogeeks]

2011-06-10 Thread aanchal goyal
@sunny finding lca in logn is fine, but how can we traverse the path in logn.. ? On Fri, Jun 10, 2011 at 3:50 PM, sunny agrawal sunny816.i...@gmail.comwrote: @ross if a parent pointer is there lca can be found in lgn and path can be traversed in lgn too why it cannot be lgn what is the

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread kartik sachan
how should we get TLE loop total running less than 10^6?? -- 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

Re: [algogeeks]

2011-06-10 Thread sunny agrawal
using parent pointers untill we reach to lca. On Fri, Jun 10, 2011 at 3:59 PM, aanchal goyal goyal.aanch...@gmail.comwrote: @sunny finding lca in logn is fine, but how can we traverse the path in logn.. ? On Fri, Jun 10, 2011 at 3:50 PM, sunny agrawal sunny816.i...@gmail.comwrote: @ross

Re: [algogeeks] [brain teaser ] Find next number in series 10 june

2011-06-10 Thread varun pahwa
may be 42,47. actually table of seven and a digit 7. On Fri, Jun 10, 2011 at 3:29 AM, nicks crazy.logic.k...@gmail.com wrote: @ankur..how did you get that...explain..plz On Fri, Jun 10, 2011 at 3:11 AM, ankur aggarwal aggarwal11...@gmail.comwrote: 42, 49 2011/6/10 • » νιρυℓ « •

[algogeeks] Re: solve the series

2011-06-10 Thread bittu
@sunny. ..lol..dude..20 June is My Bro's B'day 18th Nov is of My mom ...:P Shashank Computer Science Engg. Birla Institute of Technology, Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: [brain teaser ] Find next number in series 10 june

2011-06-10 Thread abhishekriyer
42,50 On Jun 10, 3:29 pm, nicks crazy.logic.k...@gmail.com wrote: @ankur..how did you get that...explain..plz On Fri, Jun 10, 2011 at 3:11 AM, ankur aggarwal aggarwal11...@gmail.comwrote: 42, 49 2011/6/10 • » νιρυℓ « • vipulmehta.1...@gmail.com 42, 47 just guessing

Re: [algogeeks] Re: [brain teaser ] Find next number in series 10 june

2011-06-10 Thread Anika Jain
42,47 On Fri, Jun 10, 2011 at 4:50 PM, abhishekriyer abhishekr.iye...@gmail.comwrote: 42,50 On Jun 10, 3:29 pm, nicks crazy.logic.k...@gmail.com wrote: @ankur..how did you get that...explain..plz On Fri, Jun 10, 2011 at 3:11 AM, ankur aggarwal aggarwal11...@gmail.com wrote:

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread saurabh singh
Use Range Maximum Query. On Fri, Jun 10, 2011 at 4:15 PM, kartik sachan kartik.sac...@gmail.comwrote: how should we get TLE loop total running less than 10^6?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] write an algo that deletes all negative integers without changing the order of remaining elements of the queue

2011-06-10 Thread Kunal Patil
Yups...that seems best.. :) On Fri, Jun 10, 2011 at 4:03 PM, sunny agrawal sunny816.i...@gmail.comwrote: initialy cal size of queue then apply a for loop On Fri, Jun 10, 2011 at 4:00 PM, sunny agrawal sunny816.i...@gmail.comwrote: First algorithm taht comes in mind deque a element if

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread keyan karthi
u construct a tree nlogn , every node answers a query.. (or u get ans with a recursion) in log(n) , so when u r doing a lot of query RMQ proves to be very fast On Fri, Jun 10, 2011 at 6:28 PM, nicks crazy.logic.k...@gmail.com wrote: ya i saw that in the comments on spoj someone suggested to use

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread saurabh singh
Suppose you are given an array a[]={2,3,1,4,6,7,10} now for successfully transferring the ball,from ith city to jth city,a[i] max(a[i..j-1]). A naive approach would be to calculate all possible max[i][j] that is max for each interval and then answer the query in 0(1) time.Another approach would

[algogeeks] Reverse the bits.

2011-06-10 Thread dinesh bansal
How do you reverse the bits between j to k in a 32 bit integer. For e.g.: n = 11100011; j = 2 and k = 5 output: 1101 (bits from 2 to 5 are reversed.) n = 11010110; j = 1 and k = 5 output: 11101000 O(1) method is preferred. Thanks, -- Dinesh Bansal The Law of Win says, Let's not do it

Re: [algogeeks] write an algo that deletes all negative integers without changing the order of remaining elements of the queue

2011-06-10 Thread ADITYA KUMAR
since a queue is given ...only queue operations are allowed just dequeue all elements from the queue and if a number is +ve enqueue them to other queue after this just copy the 2nd queue to 1st one O(n) On Fri, Jun 10, 2011 at 3:44 PM, Sangeeta sangeeta15...@gmail.com wrote: write an algo that

Re: [algogeeks] C Question

2011-06-10 Thread ADITYA KUMAR
anything that is declared volatilecompiler dont apply its optimization on that storage i.e it dont remove the redundant memory accesses in case of a normal volatile variable ,its value is checked everytime it is used in the program compiler dont make any assumptions similarly in case of

[algogeeks] Print 1 to n without loops

2011-06-10 Thread Navneet Gupta
Take n from user and print 1 to n. No loops like for/while/do-while are allowed to use. --Navneet -- 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,

Re: [algogeeks] FOR ALL INDIANS PLZ READ IT

2011-06-10 Thread coder dumca
so what ? supporting anna hazare is not a bad idea. On Thu, Jun 9, 2011 at 12:54 PM, Naveen Kumar naveenkumarve...@gmail.comwrote: There is no such condition put up by the govt. If you give a missed call you are showing your support to Anna Hazare Please read

Re: [algogeeks] Please explain this problem

2011-06-10 Thread ADITYA KUMAR
just visit spoj forums On Fri, Jun 10, 2011 at 9:42 AM, keyan karthi keyankarthi1...@gmail.comwrote: the nos can repeat :) ie the valid set may contain multiple instance of a same number.. hope this helps :) On Fri, Jun 10, 2011 at 9:31 AM, saurabh singh saurab...@gmail.comwrote:

[algogeeks] Re: MS Interview

2011-06-10 Thread sarath prasath
ex-or operation on all the elements give you the answer. On Jun 9, 5:45 am, Dumanshu duman...@gmail.com wrote: Q1. I  have a file in which there are supposed to be 4 billion numbers, starting from 1 to 4,000,000,000 but unfortunately one number is missing, i.e there are only 3,999,999,999

Re: [algogeeks] write an algo that deletes all negative integers without changing the order of remaining elements of the queue

2011-06-10 Thread Monang Setyawan
I think you don't need other queue to do this, simply enqueue the non-negative dequeued element to the original queue. On Fri, Jun 10, 2011 at 11:32 AM, ADITYA KUMAR aditya...@gmail.com wrote: since a queue is given ...only queue operations are allowed just dequeue all elements from the queue

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread nagajyothi gunti
Can goto statement be used? On Fri, Jun 10, 2011 at 11:42 AM, Navneet Gupta navneetn...@gmail.comwrote: Take n from user and print 1 to n. No loops like for/while/do-while are allowed to use. --Navneet -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Kunal Patil
IF allowed ??? If yes...Use recursion.. On Fri, Jun 10, 2011 at 9:12 PM, Navneet Gupta navneetn...@gmail.comwrote: Take n from user and print 1 to n. No loops like for/while/do-while are allowed to use. --Navneet -- You received this message because you are subscribed to the Google

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Navneet Gupta
No. On Fri, Jun 10, 2011 at 9:26 PM, nagajyothi gunti nagajyothi.gu...@gmail.com wrote: Can goto statement be used? On Fri, Jun 10, 2011 at 11:42 AM, Navneet Gupta navneetn...@gmail.comwrote: Take n from user and print 1 to n. No loops like for/while/do-while are allowed to use.

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Navneet Gupta
Using recursion would be like using loops only. Also i believe the recursion used would be tail recursion and one can change tail recursion to loop based non recursive method. Okay, giving all a hint. Think classes and objects. On Fri, Jun 10, 2011 at 9:26 PM, Navneet Gupta

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Radhika Renganathan
we can declare a class with construction printing value class A { private: static int i; public: A() { cout++i endl; } }; A::i=0; main() { int n=5; A ob[n]; } this will print from 1 to 5 am i right? On Fri, Jun 10, 2011 at 9:30 PM, Navneet Gupta navneetn...@gmail.comwrote: Using recursion

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Navneet Gupta
Good Answer Radhika. You are correct. On Fri, Jun 10, 2011 at 9:40 PM, Radhika Renganathan radi.coo...@gmail.comwrote: we can declare a class with construction printing value class A { private: static int i; public: A() { cout++i endl; } }; A::i=0; main() { int n=5; A ob[n]; }

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread Radhika Renganathan
sorry i meant 'constructor' ! On Fri, Jun 10, 2011 at 9:40 PM, Radhika Renganathan radi.coo...@gmail.comwrote: we can declare a class with construction printing value class A { private: static int i; public: A() { cout++i endl; } }; A::i=0; main() { int n=5; A ob[n]; } this

Re: [algogeeks] Print 1 to n without loops

2011-06-10 Thread nicks
this problem was discussed some time before on this group i am picking up a solution discussed there which you would love to see int i=1; #define PRINT1 couti++endl; #define PRINT2 PRINT1 PRINT1 #define PRINT4 PRINT2 PRINT2 #define PRINT8 PRINT4 PRINT4 #define PRINT16 PRINT8 PRINT8 #define

[algogeeks] searching a number in circular sorted array

2011-06-10 Thread coder dumca
hi frndz given an array which is circularly sorted like 6 ,7,8 ,1 ,2 ,3 ,4,5 search a given number. -- 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

Re: [algogeeks] Re: [brain teaser ] Find next number in series 10 june

2011-06-10 Thread shashankreddy509
42,47 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/mi5D7Az5nssJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this

Re: [algogeeks] Reverse the bits.

2011-06-10 Thread Kunal Patil
How about this??? * unsigned int flip_j_to_k_bits (unsigned int n,unsigned int j,unsigned int k) { unsigned int temp; int num_of_on_bits = k-j+1; temp = (1num_of_on_bits)-1; temp = j; return (n^temp); }* I dont know whether shift operation is O(1) or not ! But i think

Re: [algogeeks] C Question

2011-06-10 Thread shashankreddy509
@Aditya; Thanks.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/UO6vAXBXhXEJ. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] Reverse the bits.

2011-06-10 Thread Vetri Balaji
int flip(int j,int k,int n) { int t1=(1j)-1; int t2=(1k)-1; t1=t2^t1; return n^t1; } correct me if im wrong On Fri, Jun 10, 2011 at 10:09 PM, Kunal Patil kp101...@gmail.com wrote: How about this??? * unsigned int flip_j_to_k_bits (unsigned int n,unsigned int j,unsigned int k) {

[algogeeks] Re: searching a number in circular sorted array

2011-06-10 Thread L
Use ternary search to find the minimum number. (In this case 1) Then you have two sorted arrays, one ascending and one descending. Now, you can apply binary search. First, check the number with the last element and the first element and chose the appropriate array for searching. Time complexity:

Re: [algogeeks] Re: Puzzle

2011-06-10 Thread Kunal Patil
@ross: seems logically correct..nice solution.. -- 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] Re: write an algo that deletes all negative integers without changing the order of remaining elements of the queue

2011-06-10 Thread scifi
Y do we need to deque and enque the nodes again the problem is similar to the node given in the linked list and delete that node. solution is : copy the next node data to the node to be deleted(ie node holding -ve number) and delete the next node. in this way order won't be changed. Correct me if

Re: [algogeeks] Re: write an algo that deletes all negative integers without changing the order of remaining elements of the queue

2011-06-10 Thread sunny agrawal
in this question i assumed that we need to write a function which takes an input a queue and function implements the required. we don't know how the queue is implemented, means we don't know about structure of the node. only 2 standard functions of queue enqueue and dequeue are known On Fri, Jun

Re: [algogeeks] Re: [brain teaser ] Find next number in series 10 june

2011-06-10 Thread snehi jain
42, 47 On Fri, Jun 10, 2011 at 9:57 PM, shashankreddy509 shashankreddy...@gmail.com wrote: 42,47 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Re: MS Interview

2011-06-10 Thread Kunal Patil
@ Dumanshu: With memory restriction also XOR method works.. :) In this case difference is just that you will be working with 400/ X number of files..where X is size of the RAM...just maintain a variable Curr_XOR_value and go on XORing it with element read from the file. When you are done

Re: [algogeeks] Re: searching a number in circular sorted array

2011-06-10 Thread Rujin Cao
Binary search is sufficient for this particular case. To help the explain, we assume the circular sorted array is ascending if probably rotated. we use *d[0..n - 1]* to represent the array with n elements and *v* to represent the searched number. Observing the circular sorted sequence d[0..n -

[algogeeks] HASHIT

2011-06-10 Thread KK
This is the link to the SPOJ problem HASHIT : http://www.spoj.pl/problems/HASHIT/ i donno whts the mistake... i keep getting wrong answer even though the Q is Straightforward :( #includeiostream #includestring using namespace std; int hash(string str) { int sum = 0; int len =

[algogeeks] Re: SPOJ THRBL

2011-06-10 Thread KK
Search Topcoder Tutorial Range Minimum Query @ Google... By few intuitive changes u can implement Range Maximum Query as well... -- 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.

[algogeeks] Re: MS Interview

2011-06-10 Thread Dumanshu
@kunal: could u plz explan ur XOR approach by using a small set of numbers. lets say we have numbers from 1 to 5 and one number is missing. so u mean 1 XOR 2 XOR 4 XOR 5 would give me 3??? On Jun 10, 11:41 pm, Kunal Patil kp101...@gmail.com wrote: @ Dumanshu: With memory restriction also XOR

[algogeeks] Re: MS Interview

2011-06-10 Thread Dumanshu
@kunal... yeah it will work. thnx :) On Jun 10, 11:41 pm, Kunal Patil kp101...@gmail.com wrote: @ Dumanshu: With memory restriction also XOR method works.. :) In this case difference is just that you will be working with 400/ X number of files..where X is size of the RAM...just

[algogeeks] Re: write an algo that deletes all negative integers without changing the order of remaining elements of the queue

2011-06-10 Thread monn
We know the size (number of elements) of the queue right? On Jun 10, 1:33 pm, ADITYA KUMAR aditya...@gmail.com wrote: @monang wats the terminating codition..?? On Fri, Jun 10, 2011 at 9:21 PM, Monang Setyawan mon...@gmail.com wrote: I think you don't need other queue to do this,

Re: [algogeeks] [brain teaser ] Famous Probability puzzle SHOOT

2011-06-10 Thread Anika Jain
Mr. White On Wed, Jun 8, 2011 at 8:07 PM, amit kumar amitthecoo...@gmail.com wrote: Mr. White On Wed, Jun 8, 2011 at 2:30 PM, nicks crazy.logic.k...@gmail.com wrote: what does the highest chance of survival ? mean.. is it about black's survival or overall survival.i'm confused

Re: [algogeeks] Reverse the bits.

2011-06-10 Thread Anika Jain
@balaji: right , just one change required i think so coz in question they are asking for change of one more bit i.e. for j=2,k=5.. bits 2,3,4,5 are modified..ur code is doing i guess only 2,3,4.. i think just one change needed int t2=(1(k+1))-1; On Fri, Jun 10, 2011 at 10:22 PM, Vetri Balaji

Re: [algogeeks] Reverse the bits.

2011-06-10 Thread Vetri Balaji
no..it will work just fine On Sat, Jun 11, 2011 at 3:31 AM, Anika Jain anika.jai...@gmail.com wrote: @balaji: right , just one change required i think so coz in question they are asking for change of one more bit i.e. for j=2,k=5.. bits 2,3,4,5 are modified..ur code is doing i guess only