Re: [algogeeks] Re: HOW TO CALCULATE THA size of union

2012-12-08 Thread shiv narayan
union C{* > > * int k;* > > * union D{* > > *char ch;* > > *int x[5];* > > * }s;* > > *}a;* > > * }b;* > > *}*p;* > > -- > > > -- Shiv Narayan Sharma Jt. Secretary CSI-DTU +919971228389 www.jugadengg.com --

[algogeeks] Re: Snapdeal placement proceedure

2012-09-05 Thread shiv narayan
hey how was your snapdeal exam you also please give some details ... On Tuesday, 28 August 2012 22:26:48 UTC+5:30, [we]fork wrote: > > > > -- Forwarded message -- > From: sachin singh > > Date: Tue, Aug 28, 2012 at 10:23 PM > Subject: Snapdeal placement proceedure > To: algo...@goo

Re: [algogeeks] Re: AMAZON: given col id, print col name in excel

2012-08-11 Thread shiv narayan
yes actually we have to print a,b,c..z instead of nos , so for that i have stored nos in character array so only characters will be printed not nos On Sat, Aug 11, 2012 at 2:18 AM, yq Zhang wrote: > @shiv, your code is correct go compute the base 26 number. However, this > question is no

[algogeeks] Re: AMAZON: given col id, print col name in excel

2012-08-08 Thread shiv narayan
this is similar to conversion of no in base 26.( where digits are a,b,c,d...z) just think it like decimal to binary conversion here base is instead 26. char Carr[26]={a,b,c...z} i=0; int arr[]; do { arrr[i++]=n%26; n/=2; } while(n) ; for(int i=n-1;i>=0;i--) cout< > Imagine a sequence like this:

[algogeeks] Re: [Amazon] : constructing fully binary tree

2012-08-07 Thread shiv narayan
Preorder and postorder do not uniquely define a binary tree. so question is vague . On Sunday, 15 July 2012 01:41:15 UTC+5:30, Navin Kumar wrote: > > Given Preorder and postorder traversals of a tree. Device an algorithm to > constuct a fully binary tree from these traversals. -- You received t

[algogeeks] Re: [Amazon] : constructing fully binary tree

2012-08-07 Thread shiv narayan
Preorder and postorder do not uniquely define a binary tree. so question is vague . On Sunday, 15 July 2012 01:41:15 UTC+5:30, Navin Kumar wrote: > > Given Preorder and postorder traversals of a tree. Device an algorithm to > constuct a fully binary tree from these traversals. -- You received t

[algogeeks] Re: Most compatible people

2012-07-06 Thread shiv narayan
check this out http://www.careercup.com/question?id=14182739 . On Friday, 6 July 2012 10:27:32 UTC+5:30, enchantress wrote: > > Given a list of people and music bands they like, two people are > compatible if they have at least 2 bands in common. The compatibility of > two people is directly pro

[algogeeks] Re: C output

2012-07-03 Thread shiv narayan
6/5=1, in integer division, how come you can think it as 2? On Tuesday, 3 July 2012 13:22:07 UTC+5:30, rahul sharma wrote: > > #include > #include > int main() > { > int i; > i=5; > i=++i/i++; > printf("%d",i); > getch(); > } > > Why o/p is 1 and not 2?? what happened for p

[algogeeks] Re: No of tri-angles

2012-06-15 Thread shiv narayan
Engineering > > MNNIT Allahabad > >  <http://gplus.to/amolsharma99> > > <http://twitter.com/amolsharma99><http://in.linkedin.com/pub/amol-sharma/21/79b/507><http://www.simplyamol.blogspot.com/> > > > On Fri, Jun 15, 2012 at 7:01 PM, shiv narayan

[algogeeks] Re: Directi Question

2012-06-15 Thread shiv narayan
On Jun 16, 2:1@shubham couldnt understand following logic in you algo please explain "when first k elemnts traversed then traverse again k elemnts of B and S[2*k-i]+=B[i])...again S[i-2*k]+=B[i][.so on till B is traversed completely." 6 am, Shubham Sandeep wrote: > wat constraints does dis bri

[algogeeks] Re: No of tri-angles

2012-06-15 Thread shiv narayan
this is the running code to find no of triangles using brute force technique logic: in a triangle having sides a,b,c; then a+b>c(if c is greatest side) correct me if i am wrong. #include #include using namespace std; int max(int a,int b,int c) { return ((a>b?a:b)>c?(a>b?a:b):c); } int main() {

[algogeeks] Re: Can anyone plz explain how we get this output

2012-06-15 Thread shiv narayan
although we know this is compiler dependent , but still such questions are very frequent in some local competitions and can be found in some old books too. is it possible to have such questions in any company placement paper or interview ? On Thursday, 14 June 2012 11:41:04 UTC+5:30, Ajesh js

[algogeeks] Re: Basics of Cloud Computing

2012-06-15 Thread shiv narayan
could you please provide free E-copy ? On Saturday, 9 June 2012 22:00:52 UTC+5:30, Ravi wrote: > > Hi All, > > Hope you are all doing great. > I am a cloud engineer and specialize in cloud computing development > and architecting as well big data analysis. Check out my blog for my > views @ ht

[algogeeks] Re: spoj problem

2012-06-13 Thread shiv narayan
will be better if you post on spoj forums.!! On Wednesday, 13 June 2012 01:40:36 UTC+5:30, gaurav yadav wrote: > > plz nyone explain how to approach this problem.. > http://www.spoj.pl/problems/XORROUND/ > -- You received this message because you are subscribed to the Google Groups "Algorith

[algogeeks] Re: Microsoft Interview Question

2012-06-13 Thread shiv narayan
@ayush goel couldnt really understand your algo , can you please explain little bit more . On Wednesday, 13 June 2012 21:49:49 UTC+5:30, Krishna Kishore wrote: > > Given a array of integers both positive and negative and you need to shift > positive numbers to one side > and negative numbers to

[algogeeks] Re: Sorting in O(n)

2012-05-05 Thread shiv narayan
@jeevitesh yeah that may be right but it requires extra space as lot of space will be wasted... On May 5, 1:44 pm, Jeevitesh wrote: > Hi all, > > I am new to this group. > > My last post was deleted i do not know the reason behind it. > > I will explain my logic here:- > > as the range is 1 to n^

[algogeeks] Re: power func

2012-05-03 Thread shiv narayan
it looks you are talking about unlock 1 or 2 on spoj, use your own recursive power function and since result may be very large so at every stage take mod. pow(a,b) { if(b==1) return a; else { if(b%2==0) return (pow(a,b/2)%mod *pow(a,b/2)%mod) %mod else return pow(a,b/2)%mod *pow(a,b/2)%mod) %

[algogeeks] Re: check Similar array

2012-01-04 Thread shiv narayan
can't be use squares of no's as said by rahul patil as said in previous comment?? On Jan 4, 10:57 am, atul anand wrote: > @sharad : after checking the link provided by u...it seem like complexity > will be O(n^2) { not sure } + saurabh point is also valid. -- You received this message because y

[algogeeks] puzzle

2011-09-23 Thread shiv narayan
Assume that you have just heard of a scandal and you are the first one to know. You pass it on to four person in a matter of 30 minutes. Each of these four in turn passes it to four other persons in the next 30 minutes and so on. How long it will take for everybody in the World to get to know the

[algogeeks] Re: Amazon online test

2011-09-23 Thread shiv narayan
what is answer to "In how many ways 3 identical coins can be placed in 5x5 grid so that no two coin come in same row and same column "?? according to me it should be 25*16*9 . On Sep 24, 2:19 am, Deoki Nandan wrote: > 1)write code to find first non repeating character in given string > 2)write

Re: [algogeeks] knight's tour - variant

2011-08-17 Thread Shiv Kumar Malik
what is the starting position of knight. -- 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+unsubscr...@googlegroups.com. F

Re: [algogeeks] Max possible numbers in incremental order

2011-08-17 Thread Shiv Kumar Malik
i think this can be solved by dynamic programming. this is very similar to the knapsack problem. 1. We have to maximize profit by increasing the length of array. 2. principle of optimality also holds here. considering the points solution ca be visualized easily. -- You received this message be

[algogeeks] Re: Goldman sachs

2011-08-06 Thread shiv narayan
hi, can anyone tell their experience of intern questions. and how to prepare for essay. On Aug 3, 5:02 pm, Ankit Minglani wrote: > heyy thanks alot to you people .. it was of so much help :) > > > > > > > > > > On Wed, Aug 3, 2011 at 2:49 AM, Kunal Patil wrote: > > I agree with Ved that Apti of

[algogeeks] Re: difference between the two

2011-08-05 Thread shiv narayan
according to me 2nd structure must also have 16 bit size for 64 bit architecture as padding must also take place there also. On Aug 6, 4:10 am, Shashank Jain wrote: > i dont understand the diff btw dem, could u plz elaborate? > > Shashank Jain > IIIrd year > Computer Engineering > Delhi College

[algogeeks] help on string manipulation & bit manipulation

2011-08-05 Thread shiv narayan
i have seen plenty of questions on string manipulation and bits operations asked in various comcanies exams. any one give me some good links where i can find some really good tutorials on string manipulation. -- You received this message because you are subscribed to the Google Groups "Algorith

[algogeeks] Re: probablity

2011-08-05 Thread shiv narayan
according to me it is 1/3 read the line carefully "What is the probability that the next pen from the same packet will also be a blue one? " since it is said the first pen was blue and second pen must also be blue. for it to happen 1st packet contaning all blue pen should be selected whose probab

[algogeeks] Re: array

2011-08-03 Thread shiv narayan
yes we can. On Aug 3, 10:08 pm, Arshad Alam wrote: > can we insert 16 elements of one dimension array in 4*4 of double dimension > array? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googleg

[algogeeks] plz explain

2011-07-31 Thread shiv narayan
Mike has $20 more than Todd. How much does each have given that combined they have $21 between them. You can't use fractions in the answer. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googleg

[algogeeks] Re: Novell - Puzzle

2011-07-29 Thread shiv narayan
i think for rat pair answer should be same as cow..correct me if i am wrong On Jul 29, 1:10 pm, sunny agrawal wrote: > No ans will be sum of all > final fib. number is the no of she-calves of age 0 > second last is number is she-calves of age 1 > ...and so on > > so answer is sum of all > > On Fr

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

2011-07-29 Thread shiv narayan
would it work temp=root; for(int i=0;ileft; } On Jul 29, 10:48 am, sunny agrawal wrote: > Node* x = TREE_MINIMUM(root); > for(int i = 0; i < k-1; i++){ > x = TREE-SUCCESSOR(x);} > > return x; > > > > > > > > > > On Fri, Jul 29, 2011 at 11:08 AM, noobcoder wrote: > > Iterative inorder of tree til

[algogeeks] Re: wht is d logic behind this

2011-07-29 Thread shiv narayan
this is very popular interview question i also want solution. On Jul 29, 11:19 am, jagrati verma wrote: >  an array containing +ve and -ve integers.find sub array with the largest > sum -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To

[algogeeks] Re: Novell - Puzzle

2011-07-28 Thread shiv narayan
solutions for cow questions: if we consider first cow would she calf at age 2 then first new cow would come at age two. at end of 2nd year: 1st would give new cow: at end of 3rd year:1st cow would another new cow at end of 4th year :1st cow will give new cow and the cow born at end of 2nd year woul

[algogeeks] Re: GATE C-Question

2011-07-27 Thread shiv narayan
value of k in any if case would be k=m+n-1, now analyse both of the options i)j wrote: > C ) > > On Tue, Jul 26, 2011 at 9:02 PM, Vijay Khandar wrote: > > > > > > > > > > > Consider the following C-function in which a[n] and b[m] are two > > sorted integer arrays and c[n+m] be an other integer arra

[algogeeks] clock synchronisation puzzle..

2011-07-20 Thread shiv narayan
There is a clock at the bottom of the hill and a clock at the top of the hill. The clock at the bottom of the hill works fine but the clock at the top doesn't. How will you synchronize the two clocks. Obviously, you can,t carry either of the clocks up or down the hill! And you have a horse to help

[algogeeks] puzzle

2011-07-19 Thread shiv narayan
There is a temple, whose premises have a garden and a pond. It has 4 idols, each of Ram, Shiv, Vishnu and Durga. The priest plucks x flowers from the garden and places them in the pond. The number of flowers doubles up, and he picks y flowers out of them and goes to offer it to Lord Ram. By the

[algogeeks] Re: Printf ...

2011-07-16 Thread shiv narayan
according to me it processing is done from righ to left .first right most a would be incremented and then from righ to left for first question answer should be 8+7+6=21 and for 2nd it should be (8)+(7)*10+(6)*100=678 On Jul 15, 1:15 pm, Antony Kotre wrote: > can any tell and explain the output o

[algogeeks] what would be the output of following code??

2011-07-16 Thread shiv narayan
Printf(“%d”,printf(“%d %d”,2,2) & printf(“%d %d ”, 2, 2)); -- 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+unsubscr...@g

[algogeeks] Re: plz explain if the solution is possible with less than 2n-3 comparisons??

2011-07-14 Thread shiv narayan
@sunny iam asking minimum no of comaparisons. On Jul 14, 10:22 am, sunny agrawal wrote: > n+lgn-2 no of comparisions will do > > On Thu, Jul 14, 2011 at 10:19 AM, shiv narayan > wrote: > > > Describe an optimal algorithm to find the second minimum number in an > > ar

[algogeeks] plz explain if the solution is possible with less than 2n-3 comparisons??

2011-07-13 Thread shiv narayan
Describe an optimal algorithm to find the second minimum number in an array of numbers. What is the exact number of comparisons required in the worst case? Note that they didn't ask the order in Big-Oh notation. They wanted the exact number of comparisons. -- You received this message because you

[algogeeks] puzzle-plz explain stepwise

2011-07-13 Thread shiv narayan
A car is traveling at a uniform speed.The driver sees a milestone showing a 2-digit number. After traveling for an hour the driver sees another milestone with the same digits in reverse order.After another hour the driver sees another milestone containing the same two digits. What is the average sp

[algogeeks] Re: output

2011-07-12 Thread shiv narayan
cant i invoke both simultaneously?? if i try to make two objects like x const a; x a; then it gives error..can u explain plz. On Jul 12, 9:55 pm, Sandeep Jain wrote: > *const* in C++ is not exactly same as *final* in java. SO unlike java adding > the keyword const to a function does not affect ov

[algogeeks] Re: NVIDIA Q

2011-07-06 Thread shiv narayan
it would be size of int. On Jul 7, 10:34 am, "oppilas ." wrote: > Ok. So for differentiating objects, we have size 1. What will be size of > following class:- > class A{ >      int z;}; > > How does different objects gets differentiated in above case? > > > > > > > > On Wed, Jul 6, 2011 at 2:24 P

[algogeeks] Re: NVIDIA Q

2011-07-06 Thread shiv narayan
hey i am getting size of empty struct 1. check my code #include #include using namespace std; struct empty{}; int main() { empty e; int x=sizeof(e); cout< wrote: > @piyush: > No,one can declare the variable of empty struct and access its address via > pointer. So, when you are accessing a

[algogeeks] Re: Puzzle

2011-07-06 Thread shiv narayan
speed of river=(distance traveled by object in it) / total time it took to travel here hat has traveled a distance of 1 KM and it has taken =5mn+5 min=10 min=10min/60=1/6 hrs; so speed = 1/(1/6)=6km/hr On Jul 6, 9:28 pm, Tushar Bindal wrote: > Let speed of boat be x miles/hr > Let speed of river

[algogeeks] Re: puzzle

2011-07-06 Thread shiv narayan
e: > > > > > > > > > @tiru and @aseem: explanation pls...! > > > On Wed, Jul 6, 2011 at 11:11 PM, TIRU REDDY wrote: > > >> 14 > > >> On 6 Jul 2011 22:35, "shiv narayan" wrote: > > >> * You are given 2 eggs. > &g

[algogeeks] puzzle

2011-07-06 Thread shiv narayan
* You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey bui

[algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread shiv narayan
@ashish thanx buddy nice solution On Jul 6, 7:20 am, Ashish Goel wrote: > Q3 : 42101000 > > started with 7000 > then changes this to > 6010 > 51000100 to > 42101000 to > > Best Regards > Ashish Goel > "Think positive and find fuel in failure" > +919985813081 > +919966006652 > > > > > > >

[algogeeks] Re: help to code

2011-07-05 Thread shiv narayan
@ tushar just one modification to you code would make the things correct.makin  if (a % 2*prime[b] == 0) inspite of  if (a % prime[b] == 0) would take care of even things hope i am correct.. thanx! for the reply On Jul 5, 10:47 pm, Tushar Bindal wrote: > If my interpretation is right, following

[algogeeks] Re: help to code

2011-07-05 Thread shiv narayan
@ tushar as per your interpretation this looks coreect...but i am not saying to exclude all no's which are divisible by first 5 prime no ..question says to exclude those no which are evenly divisible by first 5 prime no.. On Jul 5, 10:47 pm, Tushar Bindal wrote: > If my interpretation is right, f

[algogeeks] help to code

2011-07-04 Thread shiv narayan
Write a program that accepts an input integer n, and calculates the number and sum of all the numbers between 1 and n (inclusive) that are NOT evenly divisible by ANY of the first 5 prime numbers (2,3,5,7,11). The program should print out a clearly labeled count and sum my code is : it is not givin

[algogeeks] Re: puzzle

2011-06-26 Thread shiv narayan
can u please explain how is it 3? On Jun 26, 11:18 pm, "D.N.Vishwakarma@IITR " wrote: > 3 mice . > > On Sun, Jun 26, 2011 at 6:13 PM, ArPiT BhAtNaGaR < > > > > > > > > > > arpitbhatnagarm...@gmail.com> wrote: > > 3 > > > On Mon, Jun 27, 2011 at 2:10 AM, amit the cool > > wrote: > > >> There are

[algogeeks] Re: Stroustrup C++ BOOK

2011-04-26 Thread shiv narayan
can you please give the link of the book or mail me at narayan.s...@gmail.com On Apr 24, 7:31 pm, "D.N.Vishwakarma@IITR " wrote: > I have shared this book with algo geek group please check in group > > On Sun, Apr 24, 2011 at 6:52 PM, hary rathor wrote: > > send link to me also > > > harry.rat..

Re: [algogeeks] Re: Good Maths Question

2011-01-25 Thread Shiv ...
If the below link does not work- http://codepad.org/MDoQ8Kry ~Shiv. ** Hi, > > Here is a solution I have coded- http://codepad.org/bPOoakm3 > > Please let me know if you see any errors. > > *Logic for decreasing numbers-* > Number of 'n' digit valid numbers (say 2

Re: [algogeeks] Re: Good Maths Question

2011-01-25 Thread Shiv ...
starting with 'k-1' and number of 'n-1' digit number starting with 'k' [not k-1 as 55 is a valid decreasing number.]. I have used the same thought process for increasing numbers. ~Shiv. P.S. To avoid using too much memory, I have used only two int[10] arrays. I keep o

RE: [algogeeks] Re: program for evaluation of remainders

2010-12-11 Thread Shiv Shankar
Hi, I agree with ankit sablok. And if we get the factorial of n in 1!, 2!, 3! Etc. Then we can find the number easily. In its complexity will be O(N) -Original Message- From: algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com] On Behalf Of Dave Sent: Friday, December 10, 2

Re: [algogeeks] Mathematics Puzzle

2010-11-21 Thread Shiv Shankar Prajapati
> You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com > . > For mor

Re: [algogeeks] Brain Teaser

2010-11-11 Thread Shiv Shankar Prajapati
from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> Sunny Aggrawal >> B-Tech IV yea

Re: [algogeeks] Re: Yahoo Interview Question for Software Engineer/Developer about Algorithms

2010-09-18 Thread Shiv ...
i will choose BFS. As we just don't want to show a connection.. we want to show the shortest one. On Sat, Sep 18, 2010 at 4:12 PM, soundar wrote: > Even if u are connected to that person via some another friend it'll > show the shortest chain by which you are connected to that > person..So D

Re: [algogeeks] number of inversion pairs

2010-09-13 Thread Shiv ...
A pseudo code- int n; //= number of inputs. cin>>*a; // the inputs. int ** invArr; *inVArr[n-1] = NULL; //initialise all the elemnts with Null to be safe. for(int i = n-1; i > =0; i--) { for (int j = i; j < n; j++ ) { if(a[i] == a[j]) { *invArr[i] = *invArr[

Re: [algogeeks] Re: Simple reVerse

2010-09-04 Thread Shiv ...
I think Dave is trying to reverse the bit-order (in binary) reverse( 1110011 = 115) is 1100111 (= 103). On Sat, Sep 4, 2010 at 12:31 AM, albert theboss wrote: > if input is 12345 > then the output should be 54321 > > -- > You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Permutation of Array.

2010-08-19 Thread Shiv ...
An interesting idea would be treat the inputs as strings and sort them. On Thu, Aug 19, 2010 at 4:01 AM, amit wrote: > Given an array of numbers. Calculate a permutation when the > concatenate number is smallest. For instance, [55,31,312,33] is > 312313355 > > -- > You received this message b

Re: [algogeeks] Maximum size binary search tree

2010-08-15 Thread Shiv ...
Gopinath's solution can be extended by adding one more logic. Do in-order traversal, store it in an array or something. Keep resetting this data-structure if you hit a right leaf or a non-increasing number. Well we will need two such arrays, one for storing the current increasing sequence and other

Re: [algogeeks] Find the duplicate

2010-08-05 Thread Shiv ...
In constant space??? How? will you please elaborate? On Thu, Aug 5, 2010 at 9:29 PM, dinesh bansal wrote: > If I understand the question correctly... there is an array of size n which > has n/2 distinct elements and one element is repeated n/2 times. > > For e.g.: >n = 4: 1 2 3 3 >n =

Re: [algogeeks] 1's counting

2010-08-04 Thread Shiv ...
wait a sec. Manually!!! you don't want an algo/code ? And all the number has a power of two as multiple. Is it a co-incidence or intended? 2010/8/4 Seçkin Can Şahin > either count it with a for loop or if you are using C, use > __builtin_popcount(int x) > > or > > x is given > int count = 0; >

Re: [algogeeks]

2010-07-31 Thread Shiv ...
No it won't it will just reduce the height of tree to n/2 (from n). My algo- 1. Parse in triplets. For every 3 nodes make the second one parent of other two. Also, queue up such parents. 2. repeat step 1 till you have only 1 node left (root). But this may give a tree 'imbalanced at root. we may n

Re: [algogeeks] Re: What is the time complexity of multiplying two n-digit numbers base b

2010-07-31 Thread Shiv ...
An edgy case... On Sun, Aug 1, 2010 at 9:52 AM, Shiv ... wrote: > What about this- > = > long multiply(long num, int n) { > long bigSum=0; > while(n>=1) { > int sum =num; int j*=1*; //to avoid garbage @n=1. >

Re: [algogeeks] Re: What is the time complexity of multiplying two n-digit numbers base b

2010-07-31 Thread Shiv ...
What about this- = long multiply(long num, int n) { long bigSum=0; while(n>=1) { int sum =num; int j; for(int i =2; i<=n; i= i*2) { sum+=sum; j=i; } //for

Re: [algogeeks] What is the time complexity of multiplying two n-digit numbers base b

2010-07-31 Thread Shiv ...
O(log n). If u add in pairs. e.g. (5+5)=10. now add 10+10. On Sat, Jul 31, 2010 at 6:28 PM, sourav wrote: > When you first learned to multiply numbers, you were told that x * y > means adding x a total of y times, so 5 * 4 = 5+5+5+5 = 20. What is > the time complexity of multiplying two n-digi

Re: [algogeeks] Generate a number

2010-07-29 Thread Shiv ...
If space is not a restriction- Build a B-tree. 1. Have a dummy root. 2. At level one- Numbers divisible by 1. ie. (1-9). 3. At level 2- numbers made after adding a digit to numbers at level 1. e.g. number 7 at level will have children- (70,72,74,76,78). and so on.. 4. Do the same at each level. Le

Re: [algogeeks] Re: a google question

2010-07-29 Thread Shiv ...
I have formulated a solution, not strictly of O(n), but I guess it's close. === 1. for(int k=0;k wrote: > I guess your solution would also be proved incorrect with the following, > > Numbers in bold are the two arrays. > > 125122 120 110 104 103 102 101 > 100

Re: [algogeeks] Re: ALGORITHM

2010-07-29 Thread Shiv ...
I think we can assume a perfect hashing to exist. [Please correct me if I am wrong] Implementing one, is a different issue. :)) Other than hashing, we can use BST or Heap. ~ O(klog(n)) On Thu, Jul 29, 2010 at 1:07 PM, sourav wrote: > @Shiv > > Collision is itself a wel known issue i

Re: [algogeeks] ALGORITHM

2010-07-28 Thread Shiv ...
What if the number are not consecutive? My approach- Put the numbers in a hash till a collision occurs. On Wed, Jul 28, 2010 at 9:21 PM, Apoorve Mohan wrote: > Solution : > > 1. Find Xor of numbers from 1 to n-1. > > 2. Find Xor of the numbers present in the array. > > 3. Xor the results from st

Re: [algogeeks] Re: Adobe Strings matching Puzzle.

2010-07-28 Thread Shiv ...
else return NULL; } //while(1) }//match() On Wed, Jul 28, 2010 at 1:32 PM, Shiv ... wrote: > Excuse the indentations, how about the following solution? O(strlen(B)). > > match(char * A, char *B) { > char * tempA = *A; > while(1) { >

Re: [algogeeks] Re: Adobe Strings matching Puzzle.

2010-07-28 Thread Shiv ...
ULL; } //while(1) }//match() -Shiv On Wed, Jul 28, 2010 at 3:41 AM, Anand wrote: > It is just an Implementation of KMP string match Algorithm. > > In the first section, I am find the prefix function π for a pattern which > encapsulates knowledge about how the pattern matches > aga