Re: [algogeeks] this pointer help c++

2012-10-09 Thread SAMM
This used for the following situation when a=b=c=d (Consider then as the objects of a particular class say X ). -- 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

Re: [algogeeks] 1/x + 1/y = 1/(n factorial)

2012-06-26 Thread SAMM
1 /x + 1/y = 1/(n!) * Consider N = n! , * *The Equation becoz :-* 1/x + 1/y = 1/N or (x+y)/xy = 1/N or N( x + y ) = xy *Changing sides we get :-* xy - N(x+y) = 0 *Adding N^2 on both sides we get :-* xy - N( x + y) + N^2 = N^2 or xy - Nx - Ny + N^2 = N^2 or x(y - N) - N (y -

Re: [algogeeks] How many games you will conduct to decide a winner for N players. Visualize in terms of a Data Structure.

2012-04-08 Thread SAMM
This can be done using Tournament Tree ... PLzz refer wiki or http://www.geeksforgeeks.org/archives/11556 ... This will surely help .. -- 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] Need help regarding threads

2012-03-26 Thread SAMM
I think is error is in the 4th argument u r passing in this line * pthread_create(thread1,NULL,(void*)sender,(void*)0);* The 4th argument is expecting the address of the arguments , but the address he is getting is 0 , which is not granted by OS . Tht address is used by OS I guess . Instead*

Re: [algogeeks] Need help regarding threads

2012-03-26 Thread SAMM
Yaa Senthil is right , I overlooked it . In 3rd argument also it is expecting an address while u r passing the pointer . -- 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: Run Length Decoding... inplace

2012-03-24 Thread SAMM
In this question is it mandatory to use array here .Because the output and the space were the string is stored is required .. I was thinking of using LL approach .. Need four pointers to keep track of the positions . begin - store the beginning of the LL initially containing the pointer to he

Re: [algogeeks] Suggest some Data Structure appropriate to the problem

2012-03-05 Thread SAMM
Use two stack :- One stack is used for inserting and deleting the elements in the stack , supposing the the addition and deletion is done at the end of the stack . So it will be of in constant time . The Second Stack is used keeping track of the smallest number . For finding the element we

Re: [algogeeks] Suggest some Data Structure appropriate to the problem

2012-03-05 Thread SAMM
As I mentioned we have to use hashing using Separate Chaning to find the element in constant time . This is different than than opening addresing which added the element to the next free slot in case of a collision , so we cann't keep track of the element in a constant . In sepate Chaning the

Re: [algogeeks] Re: extracting vector (digitization) from an ECG image

2012-01-08 Thread SAMM
1 month back I wrote C++ code using Magick++ to zoom a image without distorting the Pixels . In that Code we can extact the Pixel attributes which are the Combination of Red , Blue and Green and Alpha attributes(Contributes to Picture Transparancy So , not present in Every Image ). But RBG

Re: [algogeeks] Re: check Similar array

2012-01-08 Thread SAMM
@All Sry for late reply .. I was offline for sometime . Just wanted to brief why I had come up of having a cummulative sum of each elements of the array . As I mentioned the Frequency distribution of the numbers .. I meant that to the frequency the elements of the array starting from 1 to

Re: [algogeeks] Re: check Similar array

2012-01-08 Thread SAMM
or not . That mean that we need to find whether the points are at the same distance from the center or suppose the Mean . This Dispersion can be measured using Standard Deviation. May be Standard Deviation is the Correct way of proceding .. Just a thought . On 1/9/12, SAMM somnath.nit...@gmail.com wrote: @All

Re: [algogeeks] check Similar array

2012-01-03 Thread SAMM
I think this may works . needs verification. For the given array (3 5 2 5 2) For +ve number (N) take the sum from 1 to N . For -ve number (N) take the sum from -1 to N . And take take the cumulative sum ... For this array it comes 42 . Similarly check the sum for the second array . If it is same

Re: [algogeeks] check Similar array

2012-01-03 Thread SAMM
@Atul For array (3 2 5 2 5) Sum+= (sum of number from 1 to n) , n is each array element. Sum=(1+2+3)+(1+2)+(1+2+3+4+5)+(1+2)+(1+2+3+4+5) =42 On 1/4/12, SAMM somnath.nit...@gmail.com wrote: This may not work for the array having both +ve -ve numbers becoz this logic is based on frequency

Re: [algogeeks] [Off-topic] Amdocs Interview Questions

2011-12-28 Thread SAMM
Thanks for the reply I am asking about the Telephonic round .. wht types of question are asked .. In the written round :- C++ was full of Class , Exceptions , namespaces , Polymorphism , Errors and Output Sql was full with Table joins , triggers . Unix was Easy . Aptitude was easy I want to

Re: [algogeeks] Facebook Question

2011-12-22 Thread SAMM
@UTKARSH SRIVASTAV Give the implemetation logic instead of the name of the DS . -- 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] Re: doubt in TSUM

2011-12-18 Thread SAMM
This comment was for anubhav code which he wrote :--- U will not get correct solution with this algo becoz ur algo will not able to generate all the 3 triplets sum. You hav to loop through all the triplets ... take for example the numbers :- 1 2 3 5 6.. Ur algo will generate the following

Re: [algogeeks] Re: doubt in TSUM

2011-12-18 Thread SAMM
@ All, The multiplication of the polynomial need to be done using FFT becoz it will take O(nlog n) where n is the number of elements in the set. For finding the triplet we need to have a equation of the form : f(x) ^3 + af(x)^2 + b f(x) . U need to to find the cofficient of a and b where f(x)

Re: [algogeeks] array searching

2011-11-17 Thread SAMM
Yes we can do so in O(n) . First find the XOR of all unique elements using hash table or some other DS. Secondly XOR all the elements of the array .which will hav the xor of elements other thn the element repeated twice. Now XOR the above two value which will give the answer.. On 11/17/11,

Re: [algogeeks] Re: array searching

2011-11-17 Thread SAMM
On 11/18/11, SAMM somnath.nit...@gmail.com wrote: For example the array has .. 1 4 2 6 7 4 8 3.. xor the elements in the array will give (1^2^6^7^8^3). now xor the unique elements using hash table ,It gives (1^4^2^6^7^8^3). Now xor these two value which gives 4. On 11/18/11, Dave

Re: [algogeeks] Re: Questions

2011-11-01 Thread SAMM
For example :- 2d array :: 1 2 3 456 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 we hav 1d array as :-- 13 2 21 10 23 12 So the 1d array is a subset of 2d array ... On 11/1/11, vikas vikas.rastogi2...@gmail.com wrote: what do you mean by subset of 1D present in the 2D

Re: [algogeeks] Problem

2011-10-31 Thread SAMM
This is like the TOPOLOGY SORT . Repeat the steps until all the elements of orginal set is visited:- Do First need to add all those elements in a set whose inorder is Zero . Then create another set whose inorder is 1 , after making set 1 , then decrease the inorder by 1 for those elements who

Re: [algogeeks] Maximize Subsquare

2011-10-31 Thread SAMM
Any body got any idea of just how to approach It need a DP algo. On 10/30/11, SAMMM somnath.nit...@gmail.com wrote: Suppose u have a square matrix, where every cell is filled with 0 or 1 . U need to find the maximum subsquare such that all four borders are filled with all 1s. Ex:- 1 0

Re: [algogeeks] Re: Minimize bins

2011-10-30 Thread SAMM
I think DP approach with bounded knapsack algorithm can be used to ensure tht the first Bin of filled optimally then the second bin to be filled until no elements remains. On 10/29/11, ravindra patel ravindra.it...@gmail.com wrote: I dont think the greedy approach gives the optimal solution

Re: [algogeeks] Re: Unique partition

2011-10-30 Thread SAMM
No there is no such condition ...just hav to make sure all the partitions are unique . The partitions can hav some elements ( K) in common but not the entire elements in a partition (Should be UNIQUE) . On 10/30/11, sunny agrawal sunny816.i...@gmail.com wrote: Is there any condition like all

Re: [algogeeks] Re: Unique partition

2011-10-30 Thread SAMM
count++; } } you can improve internal for loop by using map : if freq[a[i]] becomes 0 delete the node from array. On Sun, Oct 30, 2011 at 10:35 PM, SAMM somnath.nit...@gmail.com wrote: No there is no such condition ...just hav to make sure all the partitions are unique

Re: [algogeeks] Dp solution for this problem?

2011-10-30 Thread SAMM
This can be done using the Dijkstra's algorithm , Start frm the source frm the Destination (In this example from (2 2)) . You need to consider the index of the array as the the vertices and the weigjht as the the value for the movement from the present vertex to it's connecting neighbour .. On

Re: [algogeeks] Virtual table

2011-10-26 Thread SAMM
The Virtual tables are contructed during compile time . The compiler create a pointer vptr to point to the vtable during but it doesn't contain the address of the function which is declared as virtual because it is still not loaded in memory . Becoz is suppose to link the modules and header files

Re: [algogeeks] Questions on Hashing ...Share ur ideas...

2011-10-25 Thread SAMM
First of Happy Diwali 2 all. For question number 4, this can be done by using a chained hashing technique along with a valid/invalid bit which wil say it has been processed or not.. After insertion has been done in the hash table. For finding the unique pairs .. Iterate over the elements

Re: [algogeeks] Questions on Hashing ...Share ur ideas...

2011-10-25 Thread SAMM
On 10/26/11, SAMM somnath.nit...@gmail.com wrote: First of Happy Diwali 2 all. For question number 4, this can be done by using a chained hashing technique along with a valid/invalid bit which wil say it has been processed or not.. After insertion has been done in the hash table

Re: [algogeeks] Imp-Amazon Question

2011-10-02 Thread SAMM
linked list + hash table. check for similar question poster on last friday .. On 10/3/11, Ankur Garg ankurga...@gmail.com wrote: Can u provide a proper HashMap Not Implementation..A proper Idea wud do :) On Mon, Oct 3, 2011 at 1:03 AM, Preetam Purbia preetam.pur...@gmail.comwrote: you can

Re: [algogeeks] Re: amazon ques

2011-10-01 Thread SAMM
Yaa it will work , but in case of deletion don't u think array will not as efficient as linked list becoz array is Static we need to define the memory b4 hand.. On 10/1/11, WgpShashank shashank7andr...@gmail.com wrote: @All Why don't try with combination of* hash-table Array* , It Will Work ,

Re: [algogeeks] pointerssss

2011-10-01 Thread SAMM
Think pointer as an array , then u can understand the problm. Here *ptr=TAN ; so ptr points to the First adress of the string . when u do increment it just point to the next address and Thus is gives AN . On 10/1/11, rahul sharma rahul23111...@gmail.com wrote: void main() { void *ptr; char

Re: [algogeeks] amazon ques

2011-09-30 Thread SAMM
Linked List + Hash table will serve the purpose in O(1). On 9/30/11, Adi Srikanth adisriika...@gmail.com wrote: if space complexity is not a constraint..u can use any kind of hashing and its function.depends on the kind of data we store..if its numbers go for square or simple linear

Re: [algogeeks] Solve the following problems

2011-09-13 Thread SAMM
For question 2:- U can use my following code ... #includeiostream #includecstdio using namespace std; int main() { int a[]={4,2,5,2,3,5,1,34,14,64,82,94}; int size=sizeof(a)/sizeof(int); // printf(%d,size); for(int i=0;i(int)sqrt(size);i++)printf(%d ,a[i]); return 0; }

Re: [algogeeks]

2011-09-11 Thread SAMM
It can be done by using colored dfs .. Done initially making all the node with some color say white . During dfs when a node is encountered then change it color say black and when all it's neighbours r visited mark it as black .when a white node is ever encountered then there is a Cycle. On

Re: [algogeeks] Tejas networks

2011-09-05 Thread SAMM
Question no 1: Find the fibonacci number as usual and check whether the current fibonacci numbed is prime using Miller primality test .Tht will do... On 9/5/11, sagar pareek sagarpar...@gmail.com wrote: thanks bharat On Mon, Sep 5, 2011 at 1:47 PM, bharatkumar bagana

Re: [algogeeks] Compute a+bx2+cx3+dx4+... efficiently (a,b,c...given)

2011-08-22 Thread SAMM
horner's rule On 8/23/11, saurabh agrawal saurabh...@gmail.com wrote: Compute a+bx2+cx3+dx4+... efficiently (a,b,c...given) -- 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.

Re: [algogeeks] Re: find numbers whose difference is min

2011-08-16 Thread SAMM
I think.i hv seen this code somewhere ..geeksforgeek may be On 8/16/11, Ankuj Gupta ankuj2...@gmail.com wrote: we take the difference with the maximum element found so far. So we need to keep track of 2 things: 1) Minimum difference found so far (min_diff). 2) Maximum number visited so far

Re: [algogeeks] Re: adobe written round que

2011-07-30 Thread SAMM
Single bit shift... int divide(int n) { n-=1; n=1; return n; } On 7/30/11, tech rascal techrascal...@gmail.com wrote: hw will u get the ans on repeated subtraction from the sum of the digits?? I mean if I hv 2 divide 27 by 3 thn first I'll find sum of the digits i.e, 2+7=9 then I'll

Re: [algogeeks] SPOJ Problem Evaluating Expression

2011-07-23 Thread SAMM
It forms a pattern for each combination i solved it tht way in spoj. On 7/24/11, shady sinv...@gmail.com wrote: Does anyone know how to simplify the expression for this problem ? https://www.spoj.pl/problems/EXFOR/ To get AC for this problem we can always solve the expression, which is

Re: [algogeeks] Re: Shooters in a circle

2011-07-23 Thread SAMM
Chetan@ now wht will u say wasn't I correct.. Think twice b4 saying wrong to other. -- 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] Axis­ Aligned Rectangles

2011-07-20 Thread SAMM
use line sweep method On 7/20/11, Dumanshu duman...@gmail.com wrote: Describe
 an
 algorithm 
that
 takes an 
unsorted 
array 
of 
axis‐ aligned 
rectangles 
and returns 
any 
pair 
of 
rectangles 
that overlaps, 
if 
there 
is such 
a 
pair. 

Axis‐aligned means 
that all 
the
 rectangle 


Re: [algogeeks] Shooters in a circle

2011-07-20 Thread SAMM
I think it is related to Joshepus problm... ckeck wikipedia for more info. On 7/20/11, Vivek Srivastava srivastava.vivek1...@gmail.com wrote: If n people are standing in a circle ,they start shooting the person standing next to their neighbour.If they start firing in this way , determine

Re: [algogeeks] Amazon

2011-07-19 Thread SAMM
FOR question1 it returns no of set bits of N. On 7/19/11, oppilas . jatka.oppimi...@gmail.com wrote: For 3rd, if we only want winner, Then 1110 players must lose. So total 1110 games. On Tue, Jul 19, 2011 at 10:37 AM, sagar pareek sagarpar...@gmail.comwrote: 1. Let's say S=D=N repeat

Re: [algogeeks] Amazon

2011-07-19 Thread SAMM
FOR question1 it returns no of set bits of N. On 7/19/11, SAMM somnath.nit...@gmail.com wrote: FOR question1 it returns no of set bits of N. On 7/19/11, oppilas . jatka.oppimi...@gmail.com wrote: For 3rd, if we only want winner, Then 1110 players must lose. So total 1110 games. On Tue

Re: [algogeeks] MS ques

2011-07-19 Thread SAMM
The above method is good , I was going to suggest another algo it takes the same complexity but lengthy so I am not posting my algo... On 7/19/11, Piyush Sinha ecstasy.piy...@gmail.com wrote: Divisibility of 3 of numbers in base 2 can be seen same as divisibility of numbers by 11 in base 10...

Re: [algogeeks] Re: how to optimally compute a matrix (nXn) to the power of k?

2011-07-19 Thread SAMM
hey dude u r missing the guy who gave the xplanation.:p On 7/20/11, SkRiPt KiDdIe anuragmsi...@gmail.com wrote: Lishabh nice xplanation bro :) -- 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] Find the missing number - Again given 4 billion integers

2011-07-18 Thread SAMM
Then it can be done by taking the xor product of all number present in the list the number from 0 to 2^32,which would give the missing number.. Example:- for list (5 3 1 4) contain number from 1 to 5 ,2 is missing .Taking the xor of all elements and all number expected to present i:e index from

Re: [algogeeks] Find the Row ..

2011-07-18 Thread SAMM
This is wht I hav been asked in Interview think it is some sort of puzzle. On 7/18/11, SkRiPt KiDdIe anuragmsi...@gmail.com wrote: Reading the input will cost n^2 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] Find the Row ..

2011-07-18 Thread SAMM
Tht's wht i said to the interviewer but he kept me telling it's complexity is O(n^2) think different wht to say . solution iz in the question he told me. On 7/18/11, sunny agrawal sunny816.i...@gmail.com wrote: we don't need to find min and max values and hence there is a better

Re: [algogeeks] Find the Row ..

2011-07-18 Thread SAMM
Tht's wht i said to the interviewer but he kept me telling it's complexity is O(n^2) think different wht to say . solution iz in the question he told me. On 7/18/11, SAMM somnath.nit...@gmail.com wrote: Tht's wht i said to the interviewer but he kept me telling it's complexity is O(n^2

Re: [algogeeks] MS written test

2011-07-18 Thread SAMM
no I don't think they ask for a specific language .they will emphasis on algo,DS,puzzle,sql some networking On 7/18/11, sourabh chaki sourabh.chak...@gmail.com wrote: Can any one please suggest the type of Microsoft written test. How many sections are there? What are the area they mainly

Re: [algogeeks] ms ques

2011-07-18 Thread SAMM
Offcourse destructor is needed or smart pointer will do for dynamic memory allocation.local variable r stored in stack it is been handled in run time . On 7/18/11, sivaviknesh s sivavikne...@gmail.com wrote: Implement a C++ garbage collector efficiently..any ideas ??? ..shud we need

Re: [algogeeks] Find the Row ..

2011-07-18 Thread SAMM
while(cinn) until the file reaches EOF On 7/18/11, ankit sambyal ankitsamb...@gmail.com wrote: @Swathi : Suppose u read 3 rows. Find the minimum and maximum element from the elements read from 3 rows. 2 cases arise: 1. Min and Max element belong to 1 row 2. Min and Max belong to 2 rows In