Re: [algogeeks] c++ query

2012-01-27 Thread sukhmeet singh
they are same untill u are reading from the memory . As soon as you try to modify or change .. it causes error. On Fri, Jan 27, 2012 at 2:32 PM, rahul sharma wrote: > int abc(char *); > int abc(const char*); > > r theses same or different???...i m using dev comiler and it works..but > isnt char i

Re: [algogeeks] Lets Discuss About Some More Practical Application of Data Structure & Algorithm , Problem Solving - How You WIll The Mutual Friends Between each m*n friends

2012-01-22 Thread sukhmeet singh
@WgpShashank : Suppose 'A' is friends both with 'B' nd 'C' .. Also 'D' has friends 'B' and "C" . also "B" and "C" are connected Note A is not friends with "D" . Now if "A" wants to view the profile of "D" then it shows that B and C are its mutual friends.. (aayush this is the problem statement) No

Re: [algogeeks] Re: Modified binary search

2011-09-27 Thread sukhmeet singh
first find the place where the mismatch occours in the array linearly .. like if the the array is in increasing sorted order than first find a location where it violates this property {8,9,18,19,22,25,36,2,3,5,6,7}; the property is violated at index 7 now u have 2 sorted arrays from index [0-6] a

Re: [algogeeks] Re: APTITUDE QUESTIONS

2011-08-30 Thread sukhmeet singh
^aditi explain On Wed, Aug 31, 2011 at 12:08 PM, aditi garg wrote: > For ques 3,the ans shud be 2...but its not thr in the options... > > > On Wed, Aug 31, 2011 at 2:14 AM, icy` wrote: > >> For the third one by hand, I was just trying to keep track of 1-2 of >> the first digits for each section.

Re: [algogeeks] Regarding Sandisk

2011-08-27 Thread sukhmeet singh
where coming ? On Fri, Aug 26, 2011 at 9:35 PM, NAGARAJAN SIVARAMAN wrote: > Do anyone have ideas regarding Sandisk technical and interview > questions...?? or any link to refer..?? > > Thanks in advance > > -- > You received this message because you are subscribed to the Google Groups > "Algorit

[algogeeks] maximum XOR

2011-08-26 Thread sukhmeet singh
Given n unsigned integer, output 2 integers which has the maximum result after XOR -- 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] array sum

2011-08-26 Thread sukhmeet singh
how to divide an integer array into 2 sub-arrays and make their averages equal? array is unsorted and we can also take any numbers and the numbers in the array need not be contiguous in the original array. how many total such array's are possible. Output them -- You received this message because

Re: [algogeeks] Interview ques

2011-07-30 Thread sukhmeet singh
what if it is a million URL's .. den what say Amol Sharma ?? in dat case even hashing and BST can be costly .. On Sat, Jul 30, 2011 at 11:44 PM, Amol Sharma wrote: > plz be more clearwere u asked about characters or words > if it is characters then problem will become quite simple... >

Re: [algogeeks] Re: Array doubt

2011-07-30 Thread sukhmeet singh
n BST. > > now , scan the order array find its corresponding element in BST and > its frequency, print it that many times. > > let me know if there is any bttr method > thx! > > On Jul 30, 11:58 pm, sukhmeet singh wrote: > > maintain a count array of all elements.. &

Re: [algogeeks] Array doubt

2011-07-30 Thread sukhmeet singh
maintain a count array of all elements.. now traverse the array again and the count array .. and build the new array On Sun, Jul 31, 2011 at 12:24 AM, aditi garg wrote: > Q1) Given an array with some repeating numbers. Like 12,6,5,12,6 > output: 12,12,6,6,5 > > 12 shud come before 6 since it is e

[algogeeks] Boundary of buildings

2011-07-30 Thread sukhmeet singh
Given a set of buildings, defined by (x1,x2,height) how will you determine the silhouette of the buildings (line, the skyline). Buildings can overlap each other. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send emai

Re: [algogeeks] array constant

2011-07-30 Thread sukhmeet singh
just adding to the concept.. this is not allowed since value of max may change during the program .. either by declaring it as a macro or as a const we (as said by ankur and varun ) restrict that the value from changing during the program ..!! On Sat, Jul 30, 2011 at 1:09 PM, Ankur Khurana wrote:

Re: [algogeeks] Makemytrip.com

2011-07-29 Thread sukhmeet singh
CTC ??? On Thu, Jul 28, 2011 at 10:22 PM, Raman Gugnani wrote: > Hi Can anyone please tell me where from and how to prepare for > MAKEMYTRIP.COM intern test..It is coming to NIT Kurukshetra campus > next week..! Also tell how this company is Good /Bad...?? > > -- > You received this message becau

Re: [algogeeks] adobe written round que

2011-07-29 Thread sukhmeet singh
repeated subtraction !! On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora < vivaciousnived...@gmail.com> wrote: > Without using /,% and * operators. write a function to divide a number > by 3. itoa() function is available. > > all i cn thnk of is to use shift operator and addition , x/3=e^(logx-

Re: [algogeeks] C output 3

2011-07-29 Thread sukhmeet singh
I couldn't understand the problem .. u have used %x as indentifier that why it is so On Fri, Jul 29, 2011 at 11:37 PM, Ankur Khurana wrote: > Please explain the output, that why is it in that form in hexadecimal form > > > #include > > int main() > { > printf("%d %x",-1<<1,-1<<1); > return

Re: [algogeeks] Re: binary search tree question!!!!

2011-07-29 Thread sukhmeet singh
no it wouldn't try finding a tree where no left exist in the root On Fri, Jul 29, 2011 at 2:14 PM, shiv narayan wrote: > would it work > temp=root; > for(int i=0;i { > temp=temp->left; > } > > On Jul 29, 10:48 am, sunny agrawal wrote: > > Node* x = TREE_MINIMUM(root); > > for(int i = 0; i <

Re: [algogeeks] Directi Ques

2011-07-29 Thread sukhmeet singh
*http://code.google.com/codejam/contest/dashboard?c=32001* On Fri, Jul 29, 2011 at 10:43 PM, swetha rahul wrote: > Hi, > given a complete binary tree (either a node is a leaf node or > has two children) > > every leaf node has value 0 or 1. > every internal node has value as the AND g

Re: [algogeeks] please help

2011-07-26 Thread sukhmeet singh
provide a sample i/p output..!! On Tue, Jul 26, 2011 at 11:43 PM, coder coder wrote: > Write a program to find the index in an circular array such that the > string that is formed starting from that index is first in > lexicographic order. > > on all the sites the code part is misunderstood for t

Re: [algogeeks] C ouput

2011-07-23 Thread sukhmeet singh
same here in IIIT !! :P On Sat, Jul 23, 2011 at 6:15 PM, sagar pareek wrote: > that question was just asked by amazon in mnnit :) > > > On Sat, Jul 23, 2011 at 6:10 PM, Amol Sharma wrote: > >> &a denotes the address of array >> &a+1 increments &a by size of array and stores in ptr.i.e. ptr

Re: [algogeeks] C ouput

2011-07-23 Thread sukhmeet singh
Amazon ..!! :) &a increments by whole array not just an int value..!! u marked 2 1 ?? On Sat, Jul 23, 2011 at 6:03 PM, Akshata Sharma wrote: > main() > { > int a[5] = {1,2,3,4,5}; > int *ptr = (int*)(&a+1); > > printf("%d %d" , *(a+1), *(ptr-1) ); > } > > output: 2 5 > > can someone please e

Re: [algogeeks] chronus corp..

2011-07-23 Thread sukhmeet singh
Whats the CTC ??? On Sat, Jul 23, 2011 at 11:36 AM, sush57 wrote: > can anyone suggest interview questions for chronus corp...i have > interview on august 1st... > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group,

[algogeeks] Array traversal with rules..

2011-07-22 Thread sukhmeet singh
You are given an array with some values..traverse the array according to the rule that if a[i]=x then you can jump max up to x steps.. (if a[i]=0 then you can't move any forward) find the least number of steps required to traverse the array ... EG:a[]=1 3 5 8 9 7 8 0 2 this requires 3 steps to tra

Re: [algogeeks] Re: MICROSOFT!!!!

2011-07-22 Thread sukhmeet singh
what DS u used in the 3rd question ?? On Fri, Jul 22, 2011 at 8:22 PM, siva viknesh wrote: > @ankur.. as u said i m posting today :) :) > > 10 questions c output, one compiler based(CFG) ,one OS > based (when reading internally it was just a simple percentage > calculation que

Re: [algogeeks] Re: MICROSOFT!!!!

2011-07-22 Thread sukhmeet singh
Algo for gcd(u,v) : gcd(0,v)=v and gcd(u,0)=u; gcd(u,v)=2*(gcd(u/2,v/2)) if u and v are multiples of 2 gcd(u,v)=gcd(u/2 ,v) if u is a multiple of 2 and v is not gcd(u,v)=gcd(u,v/2) if v is a multiple of 2 and u is not gcd(u,v)= gcd((u-v)/2,v) if u and v are not multiples of 2 and u>=v gcd(u,v)=gcd(

Re: [algogeeks] ms ques

2011-07-18 Thread sukhmeet singh
we can use auto_ptr class defined in std to implement garbage collector.. by using reference count method On Mon, Jul 18, 2011 at 10:45 PM, Vivek Srivastava < srivastava.vivek1...@gmail.com> wrote: > Use smart pointers from boost library. > > > On Mon, Jul 18, 2011 at 10:24 PM, sivaviknesh s wrot

Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree

2011-07-16 Thread sukhmeet singh
please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz wrote: > Yep! > > On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul wrote: > >> @Reynald >> Will 75 not be included in the tree that u >>

Re: [algogeeks] C OUTPUT AGAIN

2011-07-16 Thread sukhmeet singh
for problem1 you can use %hi or %hd .. while scanning .. On Thu, Jul 14, 2011 at 12:03 PM, Gaurav Jain wrote: > @Nicks > *Problem 1* > > %d is used to take a signed integer as input. To take a short integer as > input, use %hi. That way, you would get the correct answer as 2. > > *Problem 2:* > a

Re: [algogeeks] Printf ...

2011-07-15 Thread sukhmeet singh
@Anatony the output will be compiler dependent res1 is not defined .. as C don't allow to change the value of a variable more than once between a sequence point.. A sequence point occur while assigning a value , calling a function or returning from it.. Hence both res1 and res2 would give arbitary

Re: [algogeeks] MS Question

2011-07-15 Thread sukhmeet singh
after third printf cpp points to c+1 then c[-1][-1] let it point to c+2+(-1) which is c+1 .. next its easy just add one to the string pointed out ..!! On Fri, Jul 15, 2011 at 10:45 PM, swetha rahul wrote: > Hi, > > > #include > char *c[]={"ENTNG","NST","AMAZI","FIRBE"}; > char **cp[]={c+3,c+2,c

Re: [algogeeks] image processing

2011-06-26 Thread sukhmeet singh
6, 2011 at 2:16 PM, sukhmeet singh wrote: > >> I don't know how far u have been able to conquer the problem .. We tried >> this and used epipolar geometry and 7point algo and found the Homography >> matrix.. try referring to Hartley and Zeisserman book.!! >>

Re: [algogeeks] image processing

2011-06-26 Thread sukhmeet singh
I don't know how far u have been able to conquer the problem .. We tried this and used epipolar geometry and 7point algo and found the Homography matrix.. try referring to Hartley and Zeisserman book.!! On Thu, Jun 23, 2011 at 3:52 PM, DK wrote: > Perspective transformations are non linear becau

Re: [algogeeks] MS

2011-06-17 Thread sukhmeet singh
Can be done by any standard disk scheduling methods.. i guess On Tue, Jun 14, 2011 at 2:01 PM, Akshata Sharma wrote: > Design an elevator system for a 100 story building. Address all issues, > like number of elevators, speed of each (Not numerically), waiting times > etc. There would be 100-200 p

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread sukhmeet singh
ay 28, 2011 at 4:48 AM, sukhmeet singh wrote: > >> follow what Akash said..!! >> in case you still need help just go through http://ideone.com/al0U0 in >> devcpp..!! >> >> On Sat, May 28, 2011 at 2:34 PM, Aakash Johari wrote: >> >>> Precompute the va

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread sukhmeet singh
follow what Akash said..!! in case you still need help just go through http://ideone.com/al0U0 in devcpp..!! On Sat, May 28, 2011 at 2:34 PM, Aakash Johari wrote: > Precompute the values. and then do queries. > > > On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma > wrote: > >> My code gives TLE.

Re: [algogeeks] Re: sum of two

2011-05-27 Thread sukhmeet singh
element of the arrayif the number n is greater >> than k ignore itelse mark a[n]=true and check if a[k-n]==true then we >> get the required result .bt if we reach the end of array without >> entering the if condition the array doesnt contain any such pair. >&g

Re: [algogeeks] Re: sum of two

2011-05-27 Thread sukhmeet singh
lexity...bcoz map takes 0(logN) >> for insertion while array can b accessed in constant time through index. >> >> >> On Fri, May 27, 2011 at 2:39 PM, sukhmeet singh >> wrote: >> >>> k.. got it .. but it was same as putting them into a map ..if the bound >&g

Re: [algogeeks] Re: sum of two

2011-05-27 Thread sukhmeet singh
ay without >> entering the if condition the array doesnt contain any such pair. >> >> >> On Fri, May 27, 2011 at 2:26 PM, sukhmeet singh >> wrote: >> >>> @bhavana : Explain..!! >>> as far as i get you is that it would be same as implementing ma

Re: [algogeeks] Re: sum of two

2011-05-27 Thread sukhmeet singh
(for query >> purposes) and O(n) time for preprocessing. >> >> >> On Fri, May 27, 2011 at 1:29 AM, sukhmeet singh >> wrote: >> >>> @Dave nd @Akash can u explain a bit more.. I didn't get what u say.. >>> Inserting in a map takes O(log n) time !! &

Re: [algogeeks] Re: sum of two

2011-05-27 Thread sukhmeet singh
@Dave nd @Akash can u explain a bit more.. I didn't get what u say.. Inserting in a map takes O(log n) time !! On Fri, May 20, 2011 at 8:35 PM, Aakash Johari wrote: > @Dave: This is what is still a doubt to me. I have searched but couldn't > get the info regarding this. > > > On Fri, May 20, 201

Re: [algogeeks] Re:

2011-04-10 Thread sukhmeet singh
do post the sln after attending the class On 4/10/11, himanshu kansal wrote: > Rofl:D:D > > On Sun, Apr 10, 2011 at 12:01 AM, ArPiT BhAtNaGaR < > arpitbhatnagarm...@gmail.com> wrote: > >> lol funniest moment of Algogeeks >> >> >> On Sun, Apr 3, 2011 at 9:51 PM, Umer Farooq wr

Re: [algogeeks] Re: Google puzzles

2011-03-29 Thread sukhmeet singh
arpit can u a bit more explain how u came up with this formula ??? On Thu, Mar 17, 2011 at 11:11 PM, arpit.gupta wrote: > ans is n=6, m=36; > m= n + (n*7/6 + (n-1)) + ((n*7/6 + (n-1))*7/6 + n-2) +.. > now n must be a multiple of 6. taking n=6, we get the answer m= 36 > > On Mar 16, 3:27 pm,

Re: [algogeeks] problem

2011-03-27 Thread sukhmeet singh
Well this was asked by codechef on it's intern contest...!! Make a recursive algorithm using divide and conquer paradigm On Thu, Mar 10, 2011 at 11:20 AM, Akash Mukherjee wrote: > hi, > > can anybody plzz look at this problem. i tried a recursive greedy approach > but it was too slow i guess > >

Re: [algogeeks] [brain teaser ] 3march

2011-03-27 Thread sukhmeet singh
@rajul can u xplain how the bounty is (x-100)/6... ?? On Thu, Mar 3, 2011 at 1:43 PM, rajul jain wrote: > 2500 gold > 5 pirates > > Set the initial 2 pirates gold equal as follows: > x = total gold > > 100 + [(x-100)/6] = 200 + [(x - 200 - 100 - ((x-100)/6)/6] > > Rearranging and solving: > x -

Re: [algogeeks] Re: Spoj Problem

2011-03-27 Thread sukhmeet singh
is there a better solution than O(n) ??? any datastructure possible On Wed, Mar 23, 2011 at 8:20 PM, .bashrc wrote: > I may be wrong but if no==1000 then it becomes a[100] which is > beyond your array limit > > On Mar 18, 12:31 am, KK wrote: > > i m getting TLE for this soln and m not g

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-26 Thread sukhmeet singh
Bharath can u tell me how u came with the combine function ??? I can't understand the logic behind it ... do reply On Wed, Mar 16, 2011 at 10:24 PM, Bharath 2009503507 CSE < bharathgo...@gmail.com> wrote: > i am new to segment trees..i tried this problem in spoj.. > http://www.spoj.pl/problems/BR

Re: [algogeeks] SPOJ problem

2011-03-25 Thread sukhmeet singh
try using precomputation in a better way ...this got me AC.. rest is just binary search function ...!!! On Thu, Mar 24, 2011 at 9:06 PM, .bashrc wrote: > Has anyone solved this problem-https://www.spoj.pl/problems/FACVSPOW/ > I am getting TLE using binary search. > Thanks in advance > > -- > You

Re: [algogeeks] SPOJ problem- TRICOUNT

2011-03-19 Thread sukhmeet singh
may be u can try to find a more general formula for the series..which just depends on 'n'... On Sat, Mar 19, 2011 at 11:48 PM, cegprakash wrote: > Here is my code for TRICOUNT problem > > //http://www.spoj.pl/problems/TRICOUNT/ > //cegprak...@gmail.com > > #include > #include > using namespace s

Re: [algogeeks] Re: Given an integer n , you have to print all the ways in which n can be represented as sum of positive integers

2011-03-13 Thread sukhmeet singh
I think it can be done like this that assume that the number is represented as 1.. like 4= , 3= 111 ans so on now if u have to fint the total number of ways then it is similar to placing a '+' sign in the mid places Like 3= 1 1 1 so possible are 1+11 (1+2) or 11+1 (2+1) or 1+1+1(1+1+1) hence 3

Re: [algogeeks] Spoj Problem : String based

2011-03-13 Thread sukhmeet singh
in order to deal with such situations u have to read the input till the end of file if your algo is correct then using EOF something like while(scanf("%d",&n)!=EOF) will give u AC..!! On Sun, Mar 13, 2011 at 2:01 PM, Logic King wrote: > I tried the problem https://www.spoj.pl/problems/NHAY/ > > I

Re: [algogeeks] Re: Amazon Question

2011-03-03 Thread sukhmeet singh
he already pointed out that there are no repetations..!! On Thu, Mar 3, 2011 at 9:40 PM, Vipin Agrawal wrote: > take an example > > 3 3 3 5 5 5 7 8 > > I think this would fail > > On Mar 3, 8:22 pm, Ankit Sinha wrote: > > It is funny but right input is as mentioned earlier to rahul. 0,2,3,8, >

Re: [algogeeks] Amazon Question

2011-03-03 Thread sukhmeet singh
what should be the answer for this: if A={0,1,2,4,5} 0 or 1 or 2 On Thu, Mar 3, 2011 at 6:26 PM, Ankit Sinha wrote: > Hi, > > Here is the code to do this using Bsearch in o(logn) time. > > int BsearchElemEqualIndex (int *a, int start, int end) > { >int mid = (((end - start) >> 1) + start)

Re: [algogeeks] Re: String of Max Length Which Repeats More Then Onep

2011-03-01 Thread sukhmeet singh
the pseudo code can be like this: func(string s) // returns an array a[] int i=1; int j=0; int a[0]=0; while(i0 a[i]=a[j-1]; else a[i]=0; i++; } this can calculate the maxm repeated string. Next I can easily traverse the array to check what is the maxm lenght and how many times it has repeated.

Re: [algogeeks]

2011-02-24 Thread sukhmeet singh
How do Levenshtein distance used.. For that u need to know the palindrome that is closest to it.. and if that is know than there is no point in calculating the distance .. we can easily see how many changes are to be made..!(correct me if I am wrong) Further my approach is this : taking the number