[algogeeks] find a point closest to other points

2012-04-24 Thread tech coder
Given N points(in 2D) with x and y coordinates. You have to find a point P (in N given points) such that the sum of distances from other(N-1) points to P is minimum. --  Regards "The Coder" -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. T

[algogeeks] determine if a string if of form pZq

2012-04-19 Thread tech coder
determine whether the given string is of form pZq. p and q can contain only X and Y. like if p=XXYX then z will be XYXX for ex XXYXXXYXX is valid the limitation is that "you can read only the next character at each point" . --  Regards "The Coder" -- You received this message because you a

Re: [algogeeks] Re: Nice question

2011-12-13 Thread tech coder
that input. You are missing > numbers which include the digit zero, such as 14610, 30278, and 52056. > > Don > > On Dec 13, 11:37 am, tech coder wrote: > > I tried the problem and written the code for it . it is in java. it is > > printing all the possible numbers >

Re: [algogeeks] Re: Nice question

2011-12-13 Thread tech coder
I tried the problem and written the code for it . it is in java. it is printing all the possible numbers I am treating the differences ans an array of integers. here is the code public class Main { public static void main(String[] args) { int digit[]={3,2,5,1};// array of absolu

Re: [algogeeks] MYSIS AND DRISHTI-SOFT

2011-12-13 Thread tech coder
which other group u people are talking about, i would like to join that group. On Tue, Dec 13, 2011 at 9:21 PM, sunny agrawal wrote: > @aayush > Lots of member are here but that doesn't mean that you should start > posting the things which are strictly banned on this group. I hope you will > take

Re: [algogeeks] A binary tree question

2011-12-11 Thread tech coder
we have to traverse in zig zaz or spirally. so we need two stack or two queus. On Mon, Dec 12, 2011 at 12:23 AM, atul anand wrote: > @Gene : if i am not wrong , level order traversal can be done using only 1 > queuewhy 2 queue??? > > > On Sun, Dec 11, 2011 at 9:53 PM, AMAN AGARWAL wrote: > >>

Re: [algogeeks] Re: Number Theory (Power of 3 )

2011-12-10 Thread tech coder
use of log.Moreover log (or any > floating point operations) take lot of hardware time as they are emulated > on the floating point environment on most machines.Thirdly precision > problem for higher values of n may cause your solution to give wron g > answers,,, > > > > &g

Re: [algogeeks] MYSIS AND DRISHTI-SOFT

2011-12-10 Thread tech coder
about drishtisoft test pattern 1: technical + aptitude 2 hours abt 60 questions c 20 apti 30 and others 10 2round coding 4 to 5 questions 3 round 1 technical interview , they wiil ask u write working code , list and tree problems. On Fri, Dec 9, 2011 at 12:44 PM, aayush jain wrote: >

Re: [algogeeks] Re: Re : Non Decreasing Numbers

2011-12-07 Thread tech coder
there was small mistake. correct code is int count=0; void fun(int a[],int index,int n,int i) { if(index==n) { count++; cout<<"\n"; for(int k=0;k wrote: > how to arrive at such a formulation ? > can any one derive this formula ? > > > On Mon, Sep 26, 2011 at 12:09 AM, asdqwe wrote: > >> t

Re: [algogeeks] Re: Number Theory (Power of 3 )

2011-12-07 Thread tech coder
what about this log(base 3 n) is of integral type then n is a power of 3 On Mon, Dec 5, 2011 at 11:36 PM, Dave wrote: > @Carl: You can generate the constants the first time the procedure is > called. There is no need to do them every time. So the first call > would be O(wordsize) but subsequ

Re: [algogeeks]

2011-11-27 Thread tech coder
loop through the elements of array. keep two vales firstlargest and 2ndlargest and update accordingly. loop i=1 to n { if(a[i]>1stlargest) { 2ndlargest=1stlargest; 1stlargest=a[i]; continue; } if(A[i]>2ndlargest) 2ndlargest=a[i]; }// loop c

Re: [algogeeks] Re: Any one

2011-11-26 Thread tech coder
: > @vikas : to do BFS ..first you have to create tree . so what basis will > you create a tree ? a dictionary can contains thousandss of word , just by > taking arbitrary word from the dictionary and creating tree i guess > will take lot of time. > > @tech coder : target will be

Re: [algogeeks] Any one

2011-11-26 Thread tech coder
i think edit distance algorithm can not be used here because in edit distance problem we have a target string and a source string. Here we dont have any target word. I think trie can be used with some preprocessing. On Thu, Nov 24, 2011 at 11:59 PM, atul anand wrote: > http://blog.notdot.net/2007

Re: [algogeeks] Re: Maximize Subsquare

2011-11-26 Thread tech coder
@ Chunyuan Ge *have u checked ur solution . ur solution is to find the submatrix all filled with 1 , but the question say that 1 can be at boundaries. * On Wed, Nov 23, 2011 at 3:00 PM, kumar raja wrote: > @Dark prince : what is meant by Allones(i,0.k) what subsquare he is > considering here?? >

[algogeeks] cracking the coding interview book

2011-11-25 Thread tech coder
please upload the books "cracking the coding interview 5th edition" and " data structures and algorithms made easy", if somebody have. thanks. -- * Regards* *"The Coder"* *"Life is a Game. The more u play, the more u win, the more u win , the more successfully u play"* -- You received this

Re: [algogeeks] Re: finding closest points

2011-11-22 Thread tech coder
use a max heap of size k, On Tue, Nov 22, 2011 at 11:38 PM, Aamir Khan wrote: > > On Tue, Nov 22, 2011 at 8:43 PM, Dave wrote: > >> @Ganesha: You could use a max-heap of size k in time O(n log k), which >> is less than O(n log n) if k < O(n). > > > We can always ensure that k <= n/2. > > If k >

Re: [algogeeks] An Array Problem

2011-11-22 Thread tech coder
here is an O(n) approach using a stack. problem can be stated as " find the 1st smaller element on the right. put the first element in stack. take next element suppose "num" if this number is less than elements stored in stack, pop those elements , for these pooped elements num will be the r

Re: [algogeeks] Time Complexity

2011-11-19 Thread tech coder
@ sravanreddy001 complexity is O(N^2) whether tree is balanced or not doesn't matter For each level it's visiting elements. all elements upto n-1 level . i dont know from where u got the concept of logn , the code is not making any decision to go in left or right , it is going in left and right

Re: [algogeeks] Time Complexity

2011-11-19 Thread tech coder
the complexity is N^2 for each level you are traversing all the nodes below that level. for nth level , you have to traverse all n-1 nodes. so O(N^2) better to use queue , we can traverse level order in O(n). On Sat, Nov 19, 2011 at 4:58 PM, shady wrote: > this doesn't seem like level order prin

Re: [algogeeks] median from continuous stream

2011-11-08 Thread tech coder
using a max heap and min heap we can find the median On Tue, Nov 8, 2011 at 10:59 AM, Arun Vishwanathan wrote: > Hi to find running median from a stream of random generated numbers I have > heard of the 2 heap ( min and max heap ) solution but I fail to understand > it...could someone please e

Re: [algogeeks] Re: Re : Non Decreasing Numbers

2011-11-05 Thread tech coder
this is the solution . it also prints all the possible as well as the total count int count=0; void fun(int a[],int index,int n,int i) { if(index==n) { count++; cout<<"\n"; for(int k=0;k wrote: > how ? > elaborate on the solution part ? how to arrive at that > formulation ? > > On Se

Re: [algogeeks] Re: matrix

2011-09-17 Thread tech coder
people just dont read the question properly and post the answer On 9/17/11, prasanth n wrote: > @sinjanspecial: > > i think your code is for an 1 D matrix..but i have to find for a 2D matrix.. > > On Sat, Sep 17, 2011 at 7:33 PM, sinjanspecial > wrote: > >> hii I think this code will work >> >> #

Re: [algogeeks] Re: no of elements of the array

2011-09-15 Thread tech coder
+1 to don On Thu, Sep 15, 2011 at 9:40 PM, Don wrote: > Not really. Usually you would need a second parameter indicating the > size of the input. In theory it might be possible to put a marker > value at the end of the array. > > Most implementations of malloc store the size of the memory block

Re: [algogeeks] Find the element in Array

2011-09-15 Thread tech coder
1: use bit array(hashing) then only it is possible in O(n) On Fri, Sep 16, 2011 at 12:04 PM, tech coder wrote: > @ akshat read the question properly before posting such solution > > > On Wed, Aug 31, 2011 at 12:27 PM, Akshat Sapra wrote: > >> Solution: >> >

Re: [algogeeks] Find the element in Array

2011-09-15 Thread tech coder
@ akshat read the question properly before posting such solution On Wed, Aug 31, 2011 at 12:27 PM, Akshat Sapra wrote: > Solution: > > arr[n],sum = 0; > > > for ( int i = 0 ; i < n; i++ ) { >sum ^= arr[i]; > } > > print sum; // required number > > -- > > > Akshat Sapra > Under Graduat

Re: [algogeeks] C output

2011-09-14 Thread tech coder
@ prateek absolutely wrong , dear u need to brushup ur basics d is a pointer , it's can be 2 or 4 depebding on compiler On Wed, Sep 14, 2011 at 6:26 AM, PRATEEK VERMA wrote: > 9 and 3 > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. >

[algogeeks] complexity of recursion

2011-09-14 Thread tech coder
an interseting problem for a fibonacci series the recurrence relation is t(n)=t(n-1)+t(n-2)+O(1) on solving it gives upper bound of O(n^2) but when draw tree for the recurcsion we see that it is growing exponentially giving a complexity of O(2^n). so what is the complexity for fibonaacci series

Re: [algogeeks] Re: Finding connection b/w 2 profiles

2011-09-14 Thread tech coder
we can also use dfs and find if there exist path between given two nodes(profiles here). if yea , there is a connection b/w two profiles. On Wed, Sep 14, 2011 at 1:58 PM, Azhar Hussain wrote: > Union Find Algorithm would do > > - > Azhar. > > > On Wed, Sep 14, 2011 at 1:42 PM, JITESH KUMAR wr

Re: [algogeeks] C output

2011-09-13 Thread tech coder
for 16 bit compiler ans is 2 3 for 32 bit compiler ans is 4 3 pls correct me if i m wrong On Wed, Sep 14, 2011 at 11:36 AM, tech coder wrote: > +1 > > On Wed, Aug 31, 2011 at 9:27 PM, SANDEEP CHUGH wrote: > >> its 4 3 i think >> >> >> On Wed, Aug 3

Re: [algogeeks] C output

2011-09-13 Thread tech coder
+1 On Wed, Aug 31, 2011 at 9:27 PM, SANDEEP CHUGH wrote: > its 4 3 i think > > > On Wed, Aug 31, 2011 at 9:25 PM, aditi garg wrote: > >> 8 3 >> >> >> On Wed, Aug 31, 2011 at 9:22 PM, rohit wrote: >> >>> output?? >>> >>> int main() >>> { >>> char *d = "abc\0def\0"; >>> printf("%d %d",sizeof

[algogeeks] Which one is better to work for ThoughtWorks or Samsung

2011-09-13 Thread tech coder
Which one is better to work for ThoughtWorks or Samsung. ThoughtWorks package 5.86 Samsung 6.25. Those who r working in samsung or thoughtworks please reply -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email

[algogeeks] need help

2011-09-11 Thread tech coder
if somebody has the preparation material and videos provided by Careercup.com. Then please send me. thanks. -- 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] Max sub matrix problem

2011-09-11 Thread tech coder
this is possible in o(n^2) with n^2 addidtional space . On Sun, Sep 11, 2011 at 11:33 AM, Neha Singh wrote: > @victor: Can u provide the algo ?? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to a

Re: [algogeeks] Request for crack coding book ebook

2011-09-05 Thread tech coder
please send the 5th edition if someone have thanks On Sun, Sep 4, 2011 at 11:18 PM, Sanjay Rajpal wrote: > Send it to me also. > > Thanx in advance .. :) > Sanju > :) > > > > On Sat, Sep 3, 2011 at 9:58 AM, UMESH KUMAR wrote: > >> hi >> anybody do you have CrackCoding ebook pls send . >> >> than

Re: [algogeeks] max sum in submatrix

2011-08-30 Thread tech coder
can u elaborate On Tue, Aug 30, 2011 at 11:13 AM, sukran dhawan wrote: > kadane 's algo ? > > On Tue, Aug 30, 2011 at 1:19 AM, tech coder wrote: > >> given a matrix with +ve and -ve numbers find the sub matrix with max sum >> >> -- >> You received t

Re: [algogeeks] affect of change

2011-08-30 Thread tech coder
oh yes d will give error. On Tue, Aug 30, 2011 at 9:36 AM, tech coder wrote: > c and d will be affected. > > > On Tue, Aug 30, 2011 at 8:51 AM, nidhi jain wrote: > >> >> >> yes, D vl give an error ,as increment operator cannot be used as lvalue >> for assi

Re: [algogeeks] affect of change

2011-08-30 Thread tech coder
c and d will be affected. On Tue, Aug 30, 2011 at 8:51 AM, nidhi jain wrote: > > > yes, D vl give an error ,as increment operator cannot be used as lvalue for > assignment. > > NIDHI JAIN > INFORMATION TECHNOLOGY(FINAL YEAR) > NIT,DURGAPUR > > -- > You received this message because you are subsc

Re: [algogeeks] Re: How

2011-08-30 Thread tech coder
++rahul see a constructor cant recieve an srgument of the same class type(by value), although it can recieve a reference of same class type, because the process become recursiv eand go infinite till stack overflow On Tue, Aug 30, 2011 at 9:28 AM, rahul sharma wrote: > a. default constructor > c

Re: [algogeeks] Find square root a number

2011-08-30 Thread tech coder
the sqrt of 32 bit number can't be more than 16 bits. have an array of 2^16 elemnts wtih elemts 1 2 3 4 5 32768 . now apply binary search i=a[mid]where mid=(lower+upper)/2 if(i*i==num) i is the sqrt increment lower and upper accordingly as we do in binary search so order is Olognw

[algogeeks] convert a string into another in minimum number of steps

2011-08-29 Thread tech coder
convert a string into another in minimum number of steps. insertion of a new character , deletion will be considerd as a step. for ex. to convert "map" into man requires 1 step. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to th

Re: [algogeeks] Re: There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum com

2011-08-29 Thread tech coder
an example array 35,36,37,36,37,38,39,40,39,40,41,42,43,42 etc array need not to be sorted. the complexity of Dave algo is O(N) in worst case , when element is not present in the array.m i right Dave On Tue, Aug 30, 2011 at 11:02 AM, Anup Ghatage wrote: > @tech > Could you give an example

[algogeeks] There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum complexity.

2011-08-29 Thread tech coder
There is an array and the distance between any two consequent elements is one(+1 or -1) and given a number. You have to check whether the number is in array or not with minimum complexity. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To po

Re: [algogeeks] URGENT- Software engineers - Java / J2ee...Need LOCALS !!

2011-08-29 Thread tech coder
are u carzy replying such spams and putting ur resume on public forum On Mon, Aug 29, 2011 at 12:52 PM, Ankur Garg wrote: > Hi > > PFA my resume for the below position > > Regards > Ankur > > On Tue, Aug 30, 2011 at 1:00 AM, katie williams < > katiewilliams...@gmail.com> wrote: > >> *URGENT- So

Re: [algogeeks] Re: subset with sum

2011-08-29 Thread tech coder
can u elaborate ur answer pls On Mon, Aug 29, 2011 at 12:47 PM, Brijesh wrote: > Sort the array and use dynamic programming.. it will take at most n^2 > complexity.! > BY dynamic programming , i mean make a 3D type array.. which will give all > the combination which sums to all the nos.. try it!

[algogeeks] max sum in submatrix

2011-08-29 Thread tech coder
given a matrix with +ve and -ve numbers find the sub matrix with max sum -- 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 algogee

[algogeeks] subset with sum

2011-08-29 Thread tech coder
is there exist an approach to find subset with a particular sum in less than O(2^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

Re: [algogeeks] Probability

2011-08-29 Thread tech coder
yes .964 easy hai yaar On Mon, Aug 29, 2011 at 5:47 AM, vishwa wrote: > if first is hit then the probability will be 0.7he missed 1st chance ,, > probability with which he missed is 0.3 ... same way he will try 2nd > chance.. hit chance is 0.6.. but he missed first already.. so total > p

Re: [algogeeks] Adding Two no without using any operator...??

2011-08-27 Thread tech coder
int add(int a,int b) { int sum=a^b; int carry=a&b; while(carry!=0) { carry<<=1; a=sum; b=carry; sum=a^b; carry=a&b; } return sum; } On Sat, Aug 27, 2011 at 12:28 PM, Mohit kumar lal wrote: > int add(int a, int b) > { >

[algogeeks] Given an array A[] and a integer num. Find four no.s in the array whose sum is equal to given num.

2011-08-27 Thread tech coder
Given an array A[] and a integer num. Find four no.s in the array whose sum is equal to given num. -- 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] Re: unsorted array problem

2011-08-26 Thread tech coder
@ Don exactly waht u write i wanted to say On Fri, Aug 26, 2011 at 11:52 AM, tech coder wrote: > @Tech: I'm not sure I understand your algorithm. Let's try it on > {1,1,2,2,3,4,5,5,6,6,7,7}. The two number occurring an odd number of > times are 3 and 4. We xor the numbers

Re: [algogeeks] Re: unsorted array problem

2011-08-26 Thread tech coder
@Tech: I'm not sure I understand your algorithm. Let's try it on {1,1,2,2,3,4,5,5,6,6,7,7}. The two number occurring an odd number of times are 3 and 4. We xor the numbers getting 7 = 111 in binary. Now how do we divide the numbers into two groups? see we come to know that both number differ at bi

Re: [algogeeks] unsorted array problem

2011-08-26 Thread tech coder
it can be done in O(N) by using XOR ing the elements 1: Xor all the elemnts since those elemnts that even freq will nullify each other we get number taht will tell in which the two required number differ. 2: divide the array in two sets on the basis of bit in which numbers differ 3:1 element will

Re: [algogeeks] chanege in immutable string

2011-08-26 Thread tech coder
thanks to all got it On Fri, Aug 26, 2011 at 4:54 AM, Neha Singh wrote: > @tech coder: > When u execute : s+="c c++"; > a new string object is created with the value of s appended with "c c++". > Now s is made to hold the reference of this new string object. T

[algogeeks] chanege in immutable string

2011-08-25 Thread tech coder
in java a tring object is immutable but in following code String s="java"; s+="c c++"; System.out.print(s); the output is " javac c++" why this is so -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group,

Re: [algogeeks] Re: matrix finding immediate neighour

2011-08-25 Thread tech coder
@ shashank and all can we an approach that take less time than O(N^2). I mean not in O(N ) or nlogn but wrote: > @Sharvan ..Yes We Can do That and yes i forgot that intead of > locals.add(a[i][j]) , we need tow write locals.add(i+j) Hope its fine now > :) > > > > > *Thanks > Shashank Mani > Co

[algogeeks] finding string in matrix grid

2011-08-25 Thread tech coder
check whether a string is present in matrix grid (either horizonatal(left to right), vertical(top to boottom) ,reverse horizonatal(right to left) reverse vertical(bottom to top). i think the question is clear. first try to give solution for horizontal and vertical only, just give the logic --

[algogeeks] tech coder wants to chat

2011-08-25 Thread tech coder
--- tech coder wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit: http://mail.google.com/mail/b-1d33702e37-993bf651e4-cs5cZharYeuSTf7aKwuqhWm2blM Y

[algogeeks] matrix finding immediate neighour

2011-08-25 Thread tech coder
write a code which will receive as input a matrix (int[][] matrix) and which should find all local maximum from the matrix. A local maximum is such a number in the matrix that is greater than all its immediate neighbors. The method should return the List of locations of all local maximum numbers fo