Re: [algogeeks] Re:

2013-06-21 Thread shubham saini
)) + bitCount(n) + n + 1; } On Thursday, June 20, 2013 11:03:35 PM UTC-4, shubham saini wrote: How to count no of set bits for all numbers from 1 to n for a given n... i knew brute force any better solution ?? -- You received this message because you are subscribed to the Google Groups

[algogeeks]

2013-06-20 Thread shubham saini
How to count no of set bits for all numbers from 1 to n for a given n... i knew brute force any better solution ?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email

[algogeeks] c++ this pointer

2013-06-05 Thread shubham saini
#includeiostream using namespace std; class Test { private: int x; int y; public: Test(int x = 0, int y = 0) { this-x = x; this-y = y; } void setX(int a) { x = a; } void setY(int b) { y = b; } void destroy() { delete this; coutx=this-x,y= this-y; } void print() { cout x =

Re: [algogeeks] What data structures will you use to implement a text editor. Size of editor can be changed and you also need to save the styling information for all the text like italic, bold etc.EO

2013-05-27 Thread Shubham Singh
Rope Data Structure is best suited for text editors. On Sat, May 25, 2013 at 10:24 PM, Nishant Pandey nishant.bits.me...@gmail.com wrote: In one of the interview it was asked, can some one suggest good DS for this. Thanks -- You received this message because you are subscribed to the

Re: [algogeeks] help with o/p why 0 comes???

2013-03-04 Thread Shubham Sandeep
to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Regards, SHUBHAM SANDEEP IT 3rd yr. NIT ALD. -- You

[algogeeks] separate coins into heaps of similar weights using balance in minimum comparisons

2013-03-01 Thread Shubham Sandeep
There are 8 coins in a bag . 3 coin weights x kg 3 coins weights y kg 2 coins weights z kg 2 coins weights w kg You have to separate them into separate heaps according to their weights in minimum comparisons using weighing balance. -- Regards, SHUBHAM SANDEEP IT 3rd yr. NIT ALD. -- You

Re: [algogeeks] Re: separate coins into heaps of similar weights using balance in minimum comparisons

2013-03-01 Thread Shubham Sandeep
2 coins weights z kg 2 coins weights w kg You have to separate them into separate heaps according to their weights in minimum comparisons using weighing balance. -- Regards, SHUBHAM SANDEEP IT 3rd yr. NIT ALD. -- You received this message because you are subscribed to the Google

[algogeeks] help with o/p why 0 comes???

2013-02-28 Thread Shubham Sandeep
code snippet: *int main() { printf (%d\n,(float)((int)(3.5/2))); return 0; }* -- Regards, SHUBHAM SANDEEP IT 3rd yr. NIT ALD. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from

Re: [algogeeks] help with o/p why 0 comes???

2013-02-28 Thread Shubham Sandeep
totally different format. If you have -Wall turned on, you should see a warning. Yanan Cao On Thu, Feb 28, 2013 at 1:41 PM, Shubham Sandeep s.shubhamsand...@gmail.com wrote: code snippet: *int main() { printf (%d\n,(float)((int)(3.5/2))); return 0; }* -- Regards, SHUBHAM SANDEEP

Re: [algogeeks] how does this code achieve SIGSEGV

2012-12-22 Thread Shubham Sandeep
...@gmail.comwrote: You are initialising random memory address with 0, which OS doesn't allow. On 12/17/12, Shubham Sandeep s.shubhamsand...@gmail.com wrote: how does this code achieve SIGSEGV code: *p;main(){*p=0;} -- Regards, SHUBHAM SANDEEP IT 3rd yr. NIT ALD

[algogeeks] how does this code achieve SIGSEGV

2012-12-17 Thread Shubham Sandeep
how does this code achieve SIGSEGV code: *p;main(){*p=0;} -- Regards, SHUBHAM SANDEEP IT 3rd yr. NIT ALD. --

Re: [algogeeks] Re: adobe apti question

2012-12-17 Thread Shubham Sandeep
but not both Ans. (e) E option should be or 113 am i ryt??? A- b or c. if A-Bthen B-fg and Delse if A-C ,then c-eh and c-d am i ryt -- -- Regards, SHUBHAM SANDEEP IT 3rd yr. NIT ALD. --

Re: [algogeeks] Re: adobe apti question

2012-12-16 Thread Shubham Sandeep
but not both Ans. (e) E option should be or 113 am i ryt??? A- b or c. if A-Bthen B-fg and Delse if A-C ,then c-eh and c-d am i ryt -- -- Regards, SHUBHAM SANDEEP IT 3rd yr. NIT ALD. --

Re: [algogeeks] Re: Amazon interview Question

2012-12-16 Thread Shubham Sandeep
://nicolas-lara.blogspot.in/2009/01/permutations.html On Friday, December 14, 2012 11:56:16 AM UTC+5:30, tapan rathi wrote: For a given number, find the next greatest number which is just greater than previous one and made up of same digits. -- -- Regards, SHUBHAM SANDEEP IT 3rd yr. NIT ALD. --

[algogeeks] BST to DLL code: whats wrong with this code........

2012-09-02 Thread shubham jain
34 40 45 50 60 70 Thank you Shubham -- 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/-/XXMvBSg0t08J. To post to this group, send email to algogeeks

[algogeeks] plz explain output y it is 1212

2012-08-17 Thread Shubham Sandeep
#includestdio.h main() { printf ( \%\d\ , 12 ) ; printf ( \%\ d\ , 12 ) ; } -- Regards, SHUBHAM SANDEEP IT 3rd yr. NIT ALD. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

[algogeeks] Oracle paper pattern

2012-08-08 Thread shubham jain
Has anyone appeared for oracle recentlyplz tell the pattern of the paper -- 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/-/IhEwqKaWLmAJ. To post to this

[algogeeks] Explain the output of this code:

2012-06-16 Thread Shubham Sandeep
#includestdio.h main() { int a[] = {0,1,2,3,4}; int *p[] = {a,a+1,a+2,a+3,a+4}; int **pp= p; printf(%d, %d, %d , *pp-a, pp-p, **pp); pp++; pp++;; ++pp; *++pp; printf(%d, %d, %d , pp-p, *pp-a, **pp); } output:0 ,0 ,0 ,4 ,4 ,4 -- You received this message

Re: [algogeeks] Microsoft Interview Question

2012-06-15 Thread Shubham Sandeep
@guneesh your code fails to keep order b/w 3 and 4 in the above example On Fri, Jun 15, 2012 at 2:40 PM, Guneesh Paul Singh gunees...@gmail.comwrote: void change(int a[],int n) { int i,j; i=0; j=1; while(injn) { if(ji) j=i+1; else

Re: [algogeeks] Directi Question

2012-06-15 Thread Shubham Sandeep
wat constraints does dis bring in the question... Also the books are arranged in a certain order and this order must never be changed. does this imply --- a student gets only consecutivly numbered book if not then sort the array B in decreasing order in Onlogn take another array S of k

Re: [algogeeks] Algo for Search in a 2D Matrix

2011-10-09 Thread shubham goyal
im assuming it be a square matrix then kth smallest element will be in a first k*k sub matrix. jst look for smallest element in the diagonal of this matrix. it will give the kth smallest element . On Mon, Oct 10, 2011 at 4:45 AM, Ankur Garg ankurga...@gmail.com wrote: Given a 2D matrix which

[algogeeks] help

2011-10-05 Thread SHUBHAM BANSAL
can anybody tell me about INFOEDGE working culture? -- Shubham bansal contact no. 7206338328 NIT Kurukshetra Computer Engineering (Final year) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks

[algogeeks] sol

2011-08-20 Thread SHUBHAM BANSAL
sum=((a^b) || ((ab)1)); -- 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/-/47RmEJcjv6kJ. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] sol

2011-08-20 Thread SHUBHAM BANSAL
((a^b) | ((ab)1)) sorry tht was bitwise or..by mistak i hd wrote logicl or SHUBHAM BANSAL COMP DEPT.. NIT KKr On Sun, Aug 21, 2011 at 9:30 AM, Sanjay Rajpal srn...@gmail.com wrote: Yes if a or b are non zero, the result is always 1. Sanju :) On Sat, Aug 20, 2011 at 8:57 PM, Naman Mahor

Re: [algogeeks] Re: adobe written round que

2011-08-01 Thread shubham
Hi, we can show that (x/3) = (x/2) - (x/4) + (x/8) - (x/16) + infinity Proof: let s1 = (x/2)+(x/8)+(x/32)+...infinity = (x/2)/(1-(1/4)) [Geometric Progression , common Ratio(r) = 1/4] s2 = (x/4)+(x/16)+(x/64)+...infinity = (x/4)/(1-(1/4)) [Geometric Progression , common Ratio(r) =

Re: [algogeeks] Re: Novell - Puzzle

2011-07-31 Thread Shubham Maheshwari
for the cows ques ... you all are forgetting to add the orginal starting cow ... thus the answer should be *233* On Sun, Jul 31, 2011 at 1:30 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: Oops. My bad. Rabbits produce every month too. I overlooked that. On Sun, Jul 31, 2011 at 1:24 PM,

Re: [algogeeks] 32 bit?

2011-07-31 Thread Shubham Maheshwari
if OS installed is of 32 bit ... then compiler will work as working on a 32 bit architecture ... and give the results accordingly ... @aditi :: i am not so sure abt your stateent regarding the size of pointer and an int being th same ... could you plzz quote the reference for the same ... On

Re: [algogeeks] Direct - i ques

2011-07-31 Thread Shubham Maheshwari
use a doubly linked list ... with a field node *min. weneva you insert an element ... check for the value of min at the head ... if the new inserted node has less value ... then set the min field to point to itself else copy the min field of te previous head. insertion and deletion is easy

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread Shubham Maheshwari
its a *doubly* linked list ... you can easily do the job ... On Sun, Jul 31, 2011 at 2:23 PM, siva viknesh sivavikne...@gmail.comwrote: using LL u cant delete in O(1) ... u have to traverse from head On Jul 31, 1:47 pm, Shubham Maheshwari shubham@gmail.com wrote: use a doubly linked

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread Shubham Maheshwari
you mean circular linked list ...!!! in case of stack ... we cn do it via SSL ... for a queue implementation ... we will ned circular, or doubly for deletion in O(1). On Sun, Jul 31, 2011 at 2:38 PM, naveen ms naveenms...@gmail.com wrote: @shubham...i have a doubt.can't the same be done

Re: [algogeeks] Morgan stanely interview ques

2011-07-31 Thread Shubham Maheshwari
color and intensity are2 different things ... do you mean to find pixels with same intensity ...!! and wat is meant by can be reached ...!! On Sun, Jul 31, 2011 at 2:40 PM, sivaviknesh s sivavikne...@gmail.comwrote: *Given an nxn screen, Each pixel is represented by intensity values. Given a

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread Shubham Maheshwari
, ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.com wrote: @shubham...i have a doubt.can't the same be done with singly linked list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] BST

2011-07-31 Thread Shubham Maheshwari
take countr to be a static variable ... that shud do the job ...!! btw ...if thats nt the case ... thn i m nt pretty sure wat u are asking to be done ... On Sun, Jul 31, 2011 at 2:12 AM, Rahul Mittal rahulmitta...@gmail.comwrote: help me with this we need to find out how many times a function

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread Shubham Maheshwari
the operation is nt extract min ... its *find* min ... On Sun, Jul 31, 2011 at 3:02 PM, Abhishek Gupta gupta.abh...@gmail.comwrote: @shubham maheshawari deletion can't be performed in O(1). after extracting the min element, we need to find the next minimum element, and worst case

Re: [algogeeks]

2011-07-31 Thread Shubham Maheshwari
http://ideone.com/IZKyN could you plzz explain this to me ...!! anyone ... On Sun, Jul 31, 2011 at 1:56 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: @sanchit:no,not at all :) On Sun, Jul 31, 2011 at 1:55 AM, Sanchit Manchanda sanchit...@gmail.comwrote: @kamakshi- sorry if you felt

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread Shubham Maheshwari
and finding the minimum element all have O(1) time. so after deleting the minimum element, where will you point min pointer? Sorry if i m wrong On Sun, Jul 31, 2011 at 3:11 PM, Shubham Maheshwari shubham@gmail.com wrote: the operation is nt extract min ... its *find* min ... On Sun

Re: [algogeeks] Tug of War

2011-07-30 Thread shubham
hey sylvester, just clarify the problem .. Is it such that in forming the group some people can be left out or the sum of the number of people in both partitions is equal to the total number of people -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

[algogeeks] Puzzle

2011-07-28 Thread shubham
A man leaves his office daily at 07:00 PM. His driver arrives with the car from home to his office at sharp 07:00 PM. So he doesn't need to wait for any transport medium as soon he is free from his work. But today he finished his work early and left the office at 05:30 PM. As his driver was not

Re: [algogeeks] Puzzle

2011-07-28 Thread shubham
That's what i was provided with in the interview. Somehow i know the answer, but don't know how? with the data provided above, you have to calculate the time it takes the man to reach the office from his home on car. -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Puzzle

2011-07-28 Thread shubham
answer is: 1 hr 20 mins. But i don't know how to arrive at the solution. help anyone.. -- 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/-/-QFXfKOMKfIJ. To

Re: [algogeeks] Re: Microsoft Question!

2011-07-22 Thread Shubham Maheshwari
x = 0; while( n ){ x = 1; x = x | ( n 1); n = 1; } return x; On Fri, Jul 22, 2011 at 1:31 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: sorry guys.. dont check the above siolution.. its wrong...!!! misread it.. On 7/22/11, Puneet Gautam puneet.nsi...@gmail.com wrote: check this out:

Re: [algogeeks] Re: Microsoft Question!

2011-07-22 Thread Shubham Maheshwari
thnx ... :D On Fri, Jul 22, 2011 at 9:19 PM, sagar pareek sagarpar...@gmail.com wrote: gr8 shubham On Fri, Jul 22, 2011 at 1:42 PM, Shubham Maheshwari shubham@gmail.com wrote: x = 0; while( n ){ x = 1; x = x | ( n 1); n = 1; } return x; On Fri, Jul 22, 2011 at 1:31 PM

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Shubham Maheshwari
could some1 plz post the xplainations ... On Fri, Jul 22, 2011 at 8:04 PM, Pankaj jatka.oppimi...@gmail.com wrote: Chetan, No. How could you relate this problem with that? Do you find something similar? ~ Pankaj On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor

Re: [algogeeks] Re: subwords in a given word!

2011-07-22 Thread Shubham Maheshwari
how are you gonna do it if the originl strng contains repeated letters ... On Fri, Jul 22, 2011 at 3:33 PM, shady sinv...@gmail.com wrote: what algorithm, print it subsequently is there any ? On Fri, Jul 22, 2011 at 3:24 PM, DeeJJ..! suryaprakash...@gmail.comwrote: @sunny...yaa..but

Re: [algogeeks] Re: Amazon ques

2011-07-20 Thread Shubham Maheshwari
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. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Shubham Maheshwari ShubZz O.o o.O

Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Shubham Maheshwari
to algogeeks@googlegroups.com. To unsubscribe 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. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- You received this message

Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Shubham Maheshwari
can we do anything else .. othr than hash tables ... On Tue, Jul 19, 2011 at 1:05 AM, Saket Choudhary sake...@gmail.com wrote: Have a hash Table. Read the elements and push it to the hash table. If it alraedy exists you are done. On 19 July 2011 01:02, Shubham Maheshwari shubham.veloc

Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Shubham Maheshwari
in a unless b.include?(m) bm else puts m break end end On 19 July 2011 01:05, Saket Choudhary sake...@gmail.com wrote: Have a hash Table. Read the elements and push it to the hash table. If it alraedy exists you are done. On 19 July 2011 01:02, Shubham Maheshwari

Re: [algogeeks] static vs dynamic array

2011-07-18 Thread Shubham Maheshwari
this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] What is the output of the following program? Why?

2011-07-17 Thread Shubham Maheshwari
i wasnt sure abt the first part of it. the one with multiple initializations ... :P On Sun, Jul 17, 2011 at 3:09 AM, sagar pareek sagarpar...@gmail.com wrote: Well shubham if you know about the unions very well then why u asked this question? On Sun, Jul 17, 2011 at 2:27 AM, Shubham

Re: [algogeeks] Re: Finding the Kth Prime

2011-07-17 Thread Shubham Maheshwari
://groups.google.com/group/algogeeks?hl=en. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- 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] Microsoft Qn: Algo to find the border of a binary tree

2011-07-16 Thread Shubham Maheshwari
. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe 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. -- Shubham Maheshwari ShubZz O.o o.O enJoY

[algogeeks] What is the output of the following program? Why?

2011-07-16 Thread Shubham Maheshwari
union Data Type What is the output of the following program? Why? #include main() { typedef union { int a; char b[10]; float c; } Union; Union x,y = {100}; x.a = 50; strcpy(x.b,hello); x.c = 21.50; printf(Union x : %d %s %f n,x.a,x.b,x.c); printf(Union y : %d %s %f n,y.a,y.b,y.c); } -- Shubham

Re: [algogeeks] What is the output of the following program? Why?

2011-07-16 Thread Shubham Maheshwari
you mean to say .. the ques is wrong ... or what ...!! On Sun, Jul 17, 2011 at 1:54 AM, sagar pareek sagarpar...@gmail.com wrote: I think you must first read about unions and the differences between union and structures :) On Sun, Jul 17, 2011 at 1:48 AM, Shubham Maheshwari shubham.veloc

Re: [algogeeks] What is the output of the following program? Why?

2011-07-16 Thread Shubham Maheshwari
of 100. On Sun, Jul 17, 2011 at 1:58 AM, Shubham Maheshwari shubham.veloc...@gmail.com wrote: you mean to say .. the ques is wrong ... or what ...!! On Sun, Jul 17, 2011 at 1:54 AM, sagar pareek sagarpar...@gmail.comwrote: I think you must first read about unions and the differences

Re: [algogeeks] Google Interview Question

2011-05-27 Thread shubham
whose next digit doesnot exist should be placed before the other number. step 3: concatenate these numbers. e.g. (0,1,10,100) sorting it gives: 1,10,100,0 = 1101000 (97,8,9) sorting gives: 9,97,8 = 9978 correct me if i'm wrong. Shubham -- You received this message because you

[algogeeks] Re: GOOGLE INTERVIEW QUESTION

2011-05-10 Thread shubham
check this one out: #includeiostream #includecstdio #includevector #includecstring using namespace std; int check_palin(string str,int *start) { int pos=-1,ret,size=str.size()-1; char last_char=str[size]; while(possize) { ret=0;int i; pos=str.find(last_char,pos+1);

[algogeeks] Reading Huge input from the terminal in least time.

2011-04-19 Thread shubham
Hello Geeks, Suppose we have a 2-d array arr[1000][1000] capable of storing 10^6 elements in it. Input is supplied one row at a time. Then what is the best possible way to read this much data in the least amount of time as scanf() or cin takes a lot of time? -- You received this message because

[algogeeks] Hard Problem

2011-03-21 Thread shubham
Hi there, Please help me reveal the suitable logic behind this problem. For a set of inputs, outputs are given. You are to guess the logic. problem can be seen at- http://www.spoj.pl/problems/HARDP/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

[algogeeks] Need help regarding the SPOJ problem...

2011-03-18 Thread shubham
You have N marbles and K slots. You have to follow the below mentioned rules : 1. You can put in a marble or take out a marble from slot numbered 1 at any time. 2. You can put in a marble or take out a marble from slot numbered i only if there exists a marble at the slot i - 1. 3. The

Re: [algogeeks] dp

2011-02-04 Thread shubham singh
if (u r calling dp of spoj as basic) { i would say u are a champ already ; } else { do practise more on spoj } -- 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] Re: Google

2011-01-18 Thread shubham singh
wch college u are in ? -- 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. For more options,

Re: [algogeeks] Re: Google

2011-01-18 Thread shubham singh
thats cool i am from uptu google didnt visit here so no idea :D :D -- 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: bits groups

2010-12-21 Thread shubham singh
u can see topcoder and codechef tutorials may help -- 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