Re: [algogeeks] fastest sequential access

2012-11-21 Thread vishal chaudhary
singly linked list On Wed, Nov 21, 2012 at 8:21 PM, shady sinv...@gmail.com wrote: which data structure among the follow has fastest sequential access ? i) vector ii) Singly linked list iii) Doubly linked list it won't be doubly linked list as it involves more pointer manipulations

Re: [algogeeks] Array Problem

2012-11-15 Thread vishal chaudhary
is going to take O(nlogn) complexity. Kindly share an alternative algorithm if you find one with lower complexity. Vishal On Wed, Nov 7, 2012 at 7:43 PM, Arun Kindra reserve4placem...@gmail.comwrote: Given an unsorted array, how to divide them into two equal arrays whose difference of sum

Re: [algogeeks] Array Problem

2012-11-15 Thread vishal chaudhary
this in the same array itself i guess but you have to do some kind of shifting. by doing this for all the elements and dividing them into two groups. I hope this helps. Vishal On Fri, Nov 16, 2012 at 9:46 AM, bharat b bagana.bharatku...@gmail.comwrote: @ vishal : how can u divide an array into 2

Re: [algogeeks] increment operator...

2012-11-06 Thread vishal chaudhary
then it goes for or and increments the k variable and then k = 7 then it finds that condition k=8 to be true. now one of the condition in the or is true and it then prints the value of k as 7 hope this helps u. Vishal Chaudhary 2012/11/6 Anil Sharma anilsharmau...@gmail.com main() { int

Re: [algogeeks] Check if a binary tree is Binary Search Tree or not.

2012-11-05 Thread vishal chaudhary
and check whether the left child is less than the root and root is smaller than the right node. Warm Regards Vishal Chaudhary BE(Hons) Computer Science and Engineering BITS Pilani On Tue, Nov 6, 2012 at 12:34 AM, shady sinv...@gmail.com wrote: Hi, Can we check this by just doing an inorder

Re: [algogeeks] Virtual functions in constructor

2012-10-10 Thread Kumar Vishal
. Thanks Kumar Vishal On Wed, Oct 10, 2012 at 2:16 AM, rahul sharma rahul23111...@gmail.comwrote: Guys i have read that concept of virtual fxn is not applicable in case of constructors..I means using virtual function in constructors always call local function..i wan to read more on this..can

Re: [algogeeks] Finding top 10 most frequent repeated word

2012-09-08 Thread Kumar Vishal
://groups.google.com/group/algogeeks?hl=en. -- Regards Kumar Vishal _ *http://wethecommonpeople.wordpress.com/ * *h**ttp://kumartechnicalarticles.wordpress.com/http://kumartechnicalarticles.wordpress.com

Re: [algogeeks] Gate complaxity question

2012-08-25 Thread vishal yadav
Because you can always find a positive constant c for which following inequality hold true. A(n) = cW(n) i.e. the avg. case time complexity always upper bounded by worst case time complexity. Which is the definition of Big O. On Sat, Aug 25, 2012 at 7:11 PM, rahul sharma

Re: [algogeeks] Gate complaxity question

2012-08-25 Thread vishal yadav
You have to discard option d because , according to definition of small o notation if f(n) =o(g(n)) then for ALL constants c 0 you have f(n) cg(n). or Lim(n-infinite) f(n)/g(n) = 0. On Sat, Aug 25, 2012 at 10:24 PM, vishal yadav vishalyada...@gmail.comwrote: Because you can always find

Re: [algogeeks] Data Cache implementation problem

2012-08-11 Thread Kumar Vishal
. -- Regards Kumar Vishal _ *http://wethecommonpeople.wordpress.com/ * *h**ttp://kumartechnicalarticles.wordpress.com/http://kumartechnicalarticles.wordpress.com/ * _ -- You received this message because you are subscribed

Re: [algogeeks] Fwd: general tree into BST

2012-07-28 Thread Kumar Vishal
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. -- Regards Kumar Vishal

Re: [algogeeks] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-26 Thread Kumar Vishal
...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Kumar Vishal _ *http://wethecommonpeople.wordpress.com/ * *h**ttp://kumartechnicalarticles.wordpress.com/http

Re: [algogeeks] MS Question: Add two large numbers where the numbers are stored in an array format

2012-06-26 Thread Kumar Vishal
I mean 123 is store as 1,2,3 or 3,2,1 On Tue, Jun 26, 2012 at 6:01 PM, Kumar Vishal kumar...@gmail.com wrote: MSB is at end or at the last of the array .. ?? On Tue, Jun 26, 2012 at 5:43 PM, saurabh singh saurab...@gmail.comwrote: ^ Does it make any difference? Saurabh Singh

Re: [algogeeks] Find the Pair of X,Y [ 1/x + 1/y = 1/N! ]

2012-06-26 Thread Kumar Vishal
be able to solve the question On Tue, Jun 26, 2012 at 1:58 AM, prakash y yprakash@gmail.com wrote: @Vishal, If the output should be the total no.of pairs, then i think there are infinite no.of such pairs. but not sure. Can someone provide me the link to the actual problem and some analysis

Re: [algogeeks] Find the Pair of X,Y [ 1/x + 1/y = 1/N! ]

2012-06-26 Thread Kumar Vishal
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. -- Regards Kumar Vishal _ *http

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

2012-06-25 Thread Kumar Vishal
We have to find number of Pair(x,y) which will satisfy the eq: 1/x + 1/y = 1/(n factorial) for large 0 N 10 ^ 4 N is integer Its problem from Code Sprint I tried to solve it by taking LOG but the sol was very slow , can any one please help Thanks Kumar Vishal -- You received

Re: [algogeeks] Find the Pair of X,Y [ 1/x + 1/y = 1/N! ]

2012-06-25 Thread Kumar Vishal
...@gmail.com wrote: Few Months back I found the problem on Code Sprint 1/x + 1/y = 1/N! (N factorial). For large value of N we have to find the par of (X,Y) which satisfy the equation my sol was slow , can any pleas help me . Thanks Kumar Vishal -- You received this message because

Re: [algogeeks] Find the Pair of X,Y [ 1/x + 1/y = 1/N! ]

2012-06-25 Thread Kumar Vishal
! On Mon, Jun 25, 2012 at 5:04 PM, Roshan kumar...@gmail.com wrote: Few Months back I found the problem on Code Sprint 1/x + 1/y = 1/N! (N factorial). For large value of N we have to find the par of (X,Y) which satisfy the equation my sol was slow , can any pleas help me . Thanks Kumar Vishal

Re: [algogeeks] Question asked in Amazon Online test

2012-06-23 Thread Kumar Vishal
bcaz choosing any vertical will automatically fix the horizontals and vice verse (u+r) C r= (u+r) C u On Sat, Jun 23, 2012 at 1:08 PM, Kumar Vishal kumar...@gmail.com wrote: Let u and r be the distance to move in the up and right directions. u=y2-y1 and r=x2-x1. (u+r) C r

Re: [algogeeks] Question asked in Amazon Online test

2012-06-23 Thread Kumar Vishal
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. -- Regards Kumar Vishal _ *http://wethecommonpeople.wordpress.com/ * *h**ttp

Re: [algogeeks] Re: Largest Path in Tree [SPOJ BENFECT]

2012-06-23 Thread Kumar Vishal
What I can think is case is : 10 / \ 6 13 / \ 4 5 / \ \ 6 7 8 / \ \ 9 a b so from a-b is a-7-4-2-5-8-b 1- Left Tree then 2- Right Tree add them On Sat, Jun 23, 2012 at 3:49 PM, Kumar Vishal kumar...@gmail.com wrote: What I can think

Re: [algogeeks] Re: Largest Path in Tree [SPOJ BENFECT]

2012-06-23 Thread Kumar Vishal
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. -- Regards Kumar Vishal

Re: [algogeeks] Re: validate bit pattern : MS question

2012-05-17 Thread Vishal Thanki
On Sat, Apr 7, 2012 at 11:24 AM, Dave dave_and_da...@juno.com wrote: @Ashgoel: Try this: bool OnesZerosOnes(unsigned int n) {     if( !(n 1) || !(n = n+1) ) return 0;     n |= n-1;     return !(n (n+1)); } Here is how it works: !(n 1) is true if the number has trailing zeros. If

Re: [algogeeks] Re: Operating System

2011-10-07 Thread Vishal Beri
You can try Operating System Concepts and Principles by Gelvin On Fri, Oct 7, 2011 at 8:32 PM, Brijesh brijeshupadhyay...@gmail.comwrote: Yeah...anyone plz tell good book for OS concepts -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

Re: [algogeeks] Find the Max from each sub-array of size k

2011-09-02 Thread vishal jain
I made a small program with window size k = 2; int max(int n, int m) { if ( n m ) return n; else return m; } int main() { int arr[8]={3,5,1,9,0,4,-1,7}; int i,j; for (i=0;i!=j i=7;i++) for (j=0;j!=i j=7; j++) { int k =

Re: [algogeeks] Re: Static variable

2011-08-31 Thread vishal jain
I executed on linux machine.. I am gettign output 0-1-2-3-4-5-6-7-8 :( for code int main() { static int i=10; while(--i0) { main(); printf(%d,i); } return 0; } On Wed, Aug 31, 2011 at 7:48 PM, Abhishek Mallick abhishek.mallick2...@gmail.com wrote: The

Re: [algogeeks] Re: Static variable

2011-08-31 Thread vishal jain
, vishal jain vishal.l...@gmail.com wrote: I executed on linux machine.. I am gettign output 0-1-2-3-4-5-6-7-8 :( for code int main() { static int i=10; while(--i0) { main(); printf(%d,i); } return 0

Re: [algogeeks] Re: Static variable

2011-08-31 Thread vishal jain
, Aug 31, 2011 at 7:50 PM, vishal jain vishal.l...@gmail.com wrote: I executed on linux machine.. I am gettign output 0-1-2-3-4-5-6-7-8 :( for code int main() { static int i=10; while(--i0) { main(); printf(%d,i

Re: [algogeeks] Novell - Technical Interview

2011-07-29 Thread Vishal Thanki
For 2nd, Are you looking for this? /lib/modules/kernel_versionbuild/ ? Or the kernel image? It can be found under /boot/. But that depends upon the distribution, there is no symbolic link present for kernel image as far as i know. On Fri, Jul 29, 2011 at 9:45 AM, rajeev bharshetty

Re: [algogeeks] Facebook Intern F2F Interview

2011-07-28 Thread Vishal Thanki
+1 Nikhil On Thu, Jul 28, 2011 at 4:26 PM, Nikhil Jindal fundoon...@yahoo.co.in wrote: Generate a random number from 1 to 100. If it is less than or equal to x, return true, else return false. This will ensure that ur returning true with x/100 probability. Cheers Nikhil Jindal On Thu, Jul

Re: [algogeeks] sizeof() question.

2011-07-27 Thread Vishal Thanki
I am not sure about the first question, but if you use sizeof(main()), it gives the ans 4. vishal@ubuntu:~/progs/c\ 09:12:57 PM $ cat alg.c #includestdio.h int main() { printf(%d\n,sizeof(main())); return 0; } vishal@ubuntu:~/progs/c\ 09:13:00 PM $ gcc alg.c vishal@ubuntu:~/progs/c\ 09:13

Re: [algogeeks] Small Doubt

2011-07-27 Thread Vishal Thanki
@ rajeev, vishal@ubuntu:~/progs/c\ 09:25:38 AM $ cat alg.c #includestdio.h int main() { int *p = (int *)0xff; *p = 4; return 0; } vishal@ubuntu:~/progs/c\ 09:25:42 AM $ gcc alg.c vishal@ubuntu:~/progs/c\ 09:25:45 AM $ ./a.out Segmentation fault vishal@ubuntu:~/progs/c\ 09

Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-26 Thread Vishal Thanki
@ankur, i think 1,2 and 2,1 would be same as set theory.. CMMIW. following is the code.. #include stdio.h #include stdlib.h void print_comb(int *a, int len) { int tlen = len; int i, j, k; for (i=0;i5;i++) { for (j=i+1; j4;j++) {

Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-26 Thread Vishal Thanki
anyway, the code i posted is buggy.. doesn't work for k=3.. don't use it :) On Tue, Jul 26, 2011 at 1:02 PM, Vishal Thanki vishaltha...@gmail.com wrote: @ankur, i think 1,2 and 2,1 would be same as set theory.. CMMIW. following is the code.. #include stdio.h #include stdlib.h void

Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-26 Thread Vishal Thanki
Here is the working code.. #include stdio.h #include stdlib.h int a[] = {1,2,3,4,5}; #define ARRLEN(a) (sizeof(a)/sizeof(a[0])) void print_comb(int len) { int tlen = len; int i, j, k; int al = ARRLEN(a); for (i = 0; i al; i++) { for (j=i+len-1;

[algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Vishal Jain
Hi All, In my last interview(given few months back), I was asked the following puzzle.. http://goo.gl/jrnpc Could you please tell me the solution for the same? Thanks Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog @ jainvish.blogspot.com Success taste better when target achieved

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

2011-07-22 Thread Vishal Jain
I think Aditi's solution is correct. I was doing the same thing using XOR function... So basically I was saying to use XOR and interviewer was asking for something better... I could not find this solution... Thanks Aditi. Thanks Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog

Re: [algogeeks] Re: sbtration

2011-07-11 Thread Vishal Thanki
z = x + (-y) :) On Tue, Jul 12, 2011 at 10:58 AM, Sunny T sunny.1...@gmail.com wrote: i would say.. implementing subtraction using division and modulus is more costly and complicated. bit manipulation is the fastest among all these techniques.  x=a-b = (a/b)*b + a%b .here u are

Re: [algogeeks] Google Question

2011-07-08 Thread Vishal Thanki
google this question!! On Fri, Jul 8, 2011 at 11:47 AM, priyanshu priyanshuro...@gmail.com wrote: How to find the number users connected to the web?? -- 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] Reversing the order of words in String

2011-07-07 Thread Vishal Thanki
Off Topic: Sorry for the diversion, but I was just wondering how easy it has become to code in languages other than c. Here is the code i wrote for the above mentioned problem in Python. It takes command line arg as string. something like vishal@ubuntu:~/progs/python\ 02:45:07 PM $ cat rev.py

Re: [algogeeks] Reversing the order of words in String

2011-07-07 Thread Vishal Thanki
@Navneet, it works with multiple spaces between words.. And here is the two line solution :) import sys print .join((sys.argv[1].split())[::-1]) On Thu, Jul 7, 2011 at 3:12 PM, Navneet Gupta navneetn...@gmail.com wrote: @Vishal, can you see if your program works well for more than single

Re: [algogeeks] Reversing the order of words in String

2011-07-07 Thread Vishal Thanki
yea, expression .join((sys.argv[1].split())[::-1]) will return the string!! On Thu, Jul 7, 2011 at 3:36 PM, Navneet Gupta navneetn...@gmail.com wrote: @Vishal, Don't confuse printing in reverse with actually modifying the actual string to reverse word order in it :) On Thu, Jul 7, 2011

Re: [algogeeks] Reversing the order of words in String

2011-07-07 Thread Vishal Thanki
#!/usr/bin/python import sys string=sys.argv[1] string= .join((string.split())[::-1]) print string How does this sound? :P On Thu, Jul 7, 2011 at 3:43 PM, Vishal Thanki vishaltha...@gmail.com wrote: yea, expression   .join((sys.argv[1].split())[::-1]) will return the string!! On Thu, Jul 7

Re: [algogeeks] Explanation

2011-07-07 Thread Vishal Thanki
you are overwriting terminating null char!! On Fri, Jul 8, 2011 at 10:23 AM, rShetty rajeevr...@gmail.com wrote: #includestdio.h #includestring.h int main() {  char str[]=This is rajeev\n;  char str1[10];  memset(str,'0',4);  printf(%s,str);  memcpy(str1,str,10);  printf(\n this is

Re: [algogeeks] Explanation

2011-07-07 Thread Vishal Thanki
memcpy is usually used to copy data structures other than strings. Use strcpy for copying strings!! On Fri, Jul 8, 2011 at 11:25 AM, Navneet Gupta navneetn...@gmail.com wrote: @Vishal, still the array str1 is also 10 bytes only, I know that memcpy overwrites the null character but not sure

Re: [algogeeks] Reversing the order of words in String

2011-07-06 Thread Vishal Thanki
If we only need to print the words in reverse order, strtok+recursion can help. Following is the code (which also stores the string into another string, not memory efficient though): #include stdio.h #include string.h #include stdlib.h char str[] = This is a new world; char sstr[sizeof(str)];

Re: [algogeeks] Re: 2 D array(dynamic allocation)

2011-07-05 Thread Vishal Thanki
and in that process, I am overwriting the signature (which is used by free()), and hence free() call fails. Can you point out the problem? Thanks, Vishal On Sun, Jul 3, 2011 at 2:12 AM, Gene gene.ress...@gmail.com wrote: Unfortunately this invokes undefined behavior, so it may not work for all

Re: [algogeeks] Re: find output

2011-07-05 Thread Vishal Thanki
+1 @Sankalp On Tue, Jul 5, 2011 at 5:02 PM, sankalp srivastava richi.sankalp1...@gmail.com wrote: A better place to put these types of questions would be www.stackoverflow.com On Jul 4, 10:45 pm, amit kumar amitthecoo...@gmail.com wrote: thanx guys... On Mon, Jul 4, 2011 at 5:11 PM,

Re: [algogeeks] c doubt

2011-07-04 Thread Vishal Thanki
because \061 is considered as a single char in ur string.. On Mon, Jul 4, 2011 at 12:52 PM, Sangeeta sangeeta15...@gmail.com wrote: #Iincludestdio.h #includestring.h main() { char str[]=S\061AB; printf(\n%d,strlen(str)); } output:4 why? -- You received this message because you are

Re: [algogeeks] Fwd: anu_test Segmentation fault

2011-07-03 Thread Vishal Thanki
Don't allocate too much static memory in stack, it will cause troubles. You are doing int[2000][2000], i.e. 2000*2000*4 bytes of memory in stack. Use dynamic memory allocation for such large chunk. I modified your code as below and it doesn't give seg fault. #includestdio.h #include malloc.h

Re: [algogeeks] please explain

2011-06-30 Thread Vishal Thanki
Rujin is right, here is the code which compiles.. vishal@ubuntu:~/progs/c\ 11:04:37 AM $ cat alg.c #includestdio.h int maxdiff(int arr[]); int main() { int p,arr[]={2,4,1,6,23,4}; p=maxdiff(arr); printf(\n MAX Diff is \t %d,p); return 0; } int maxdiff(int arr

Re: [algogeeks] Re: Statement Riddle

2011-06-27 Thread Vishal Thanki
this may be a reverse race, who comes last will win.. On Mon, Jun 27, 2011 at 6:22 PM, Dave dave_and_da...@juno.com wrote: Force indain driver finishes second in race. Ferari was next to last. Dave On Jun 27, 2:18 am, Lavesh Rawat lavesh.ra...@gmail.com wrote: *Statement Riddle  - 27

Re: [algogeeks] Reverse

2011-06-27 Thread Vishal Thanki
this code will only print, it will not store the reverse string. On Mon, Jun 27, 2011 at 9:53 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: #include stdio.h #include stdlib.h void revers(char *s) {      if(*s)      {                     revers(++s);                     s--;        

Re: [algogeeks] Reverse

2011-06-27 Thread Vishal Thanki
and yes, s will be stored in stack everytime you call the function, so its a temp variable.. string reverse is a simple logic, just iterate i through 1 to n/2 and swap the i to n-i On Mon, Jun 27, 2011 at 10:06 PM, Vishal Thanki vishaltha...@gmail.com wrote: this code will only print

Re: [algogeeks] [Brain Teaser] Sherlock puzzle 24 June

2011-06-24 Thread Vishal Thanki
she got killed because of suffocation :P On Fri, Jun 24, 2011 at 12:35 PM, Lavesh Rawat lavesh.ra...@gmail.com wrote: sherlock puzzle Solution - 24 june A wife and her husband were driving in their car on the highway. All of a sudden, they ran out of gas. So the husband said to the wife,

[algogeeks] C Error

2011-06-23 Thread Vishal Thanki
Hey all, I think I am missing something very basic in C, and which is troubling me. Following code is not compiling for me, can anyone explain why? vishal@ubuntu:~/progs/c\ 09:07:01 AM $ cat ternary.c #include stdio.h #include stdlib.h int main(int argc, char *argv[]) { int x = atoi(argv

Re: [algogeeks] C Error

2011-06-23 Thread Vishal Thanki
*argv[]) {        int x = atoi(argv[1]);        int y = 10;        x = (x 10) ? y++: 10;        return x; } Wladimir Araujo Tavares Federal University of Ceará On Fri, Jun 24, 2011 at 12:40 AM, Vishal Thanki vishaltha...@gmail.com wrote: Hey all, I think I am missing something

Re: [algogeeks] C Error

2011-06-23 Thread Vishal Thanki
Okay, I found the problem i think, (x 10) ? y++: x = 10 is evaluated as ((x 10) ? y++: x) = 10 which is wrong.. (x 10) ? y++: (x = 10) will work. On Fri, Jun 24, 2011 at 9:22 AM, Vishal Thanki vishaltha...@gmail.com wrote: yes, i understand that.. but is there any limitation in ternary

Re: [algogeeks] [brain teaser ] A Riddle

2011-06-22 Thread Vishal Thanki
was he driving a bus or tram? On Wed, Jun 22, 2011 at 12:36 PM, Yameni Dhankar yamenid...@gmail.com wrote: was he driving an ambulance? On Wed, Jun 22, 2011 at 12:33 PM, Lavesh Rawat lavesh.ra...@gmail.com wrote: A Riddle A bus driver was heading down a street in Delhi. He went right past

Re: [algogeeks] Find the error..

2011-06-22 Thread Vishal Thanki
memory leak and memory allocation check, make sure malloc return non-null. On Wed, Jun 22, 2011 at 7:04 PM, Shachindra A C sachindr...@gmail.com wrote: @balaji, the memory allocated from the heap using malloc needs to be released before termination of the program. there should be two additional

Re: [algogeeks] Interview Question: Puzzle: Probability

2011-06-22 Thread Vishal Jain
of Choosing Jar 2)*(Probability of Choosing Red Ball From jar 2) (1/2)*(1) + (1/2)(49/99) Thanks Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog @ jainvish.blogspot.com Success taste better when target achieved is bigger. P *We have a responsibility to the environment.* *Before printing

Re: [algogeeks] Output please..

2011-06-18 Thread Vishal Thanki
btw, i didn't understand the reason/motive behind this question? was it some kind of test?? On Sat, Jun 18, 2011 at 11:45 AM, Harshal hc4...@gmail.com wrote: compiler error?? if the void is replaced by int, ans=155. On Sat, Jun 18, 2011 at 11:33 AM, Balaji S balaji.ceg...@gmail.com wrote:

[algogeeks] Interview Question: Puzzle: Probability

2011-06-14 Thread Vishal Jain
Folks, This question was asked during a screening process of a product based company. Please answer. http://exploreriddles.blogspot.com/2011/06/interview-questions-puzzle.html Thanks Regards Vishal Jain Success taste better when target achieved is bigger. P *We have a responsibility

Re: [algogeeks] output

2011-06-14 Thread Vishal Thanki
@ Harshal, you are absolutely right. Again, this kind of code is highly discouraged when used in real life projects. And there is no need to go into details of how to evaluate such expressions, which are not complying to standards. On Wed, Jun 15, 2011 at 10:49 AM, Harshal hc4...@gmail.com wrote:

Re: [algogeeks] C OUTPUT HELP

2011-06-11 Thread Vishal Thanki
In 1st program, 2nd printf requires one more argument. And basically %a is used for printing a double value in hex. see man 3 printf. On Sat, Jun 11, 2011 at 5:29 PM, nicks crazy.logic.k...@gmail.com wrote: Hello friends..plz help me in understanding the following C Output first one is --

[algogeeks] C Question

2011-06-07 Thread Vishal Thanki
Following declaration makes the x as a volatile pointer to an integer. int *volatile x; But what does following means? int **volatile x; ~Vishal -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks

Re: [algogeeks] C doubt

2011-06-05 Thread Vishal Thanki
Usually it is a bad practice to increment the pointer. Rather, one should use the indexing variable to dereference the pointer at some index. One more bug in your code was, you are allocating the space for only 3 ints for p and storing 4 ints. Here is the code with some modification. #include

Re: [algogeeks] gcc debugger

2011-06-04 Thread Vishal Thanki
http://www.yolinux.com/TUTORIALS/GDB-Commands.html this may help On Sat, Jun 4, 2011 at 11:57 PM, nitish goyal nitishgoy...@gmail.com wrote: @ saurabh singh thanks On Sat, Jun 4, 2011 at 11:44 PM, saurabh singh saurabh.n...@gmail.com wrote: Do man gdb On Sat, Jun 4, 2011 at 11:20 PM,

Re: [algogeeks] A simple C question

2011-06-03 Thread Vishal Thanki
can use fork() also.. On Fri, Jun 3, 2011 at 11:57 AM, anand karthik anandkarthik@gmail.com wrote: (!printf(Hello)) On Jun 3, 2011 11:52 AM, Arpit Mittal mrmittalro...@gmail.com wrote: Please help me in this question. What's the condition so that the following code prints both

Re: [algogeeks] A simple C question

2011-06-03 Thread Vishal Thanki
vishal@ubuntu:~/progs/c\ 12:11:53 PM $ cat fork.c #include stdio.h #include stdlib.h int main() { if (fork()) { printf(hello ); } else { printf(world\n); } return 0; } vishal@ubuntu:~/progs/c\ 12:11:56 PM $ gcc fork.c vishal@ubuntu

Re: [algogeeks] A simple C question

2011-06-03 Thread Vishal Thanki
@sachindra, @naveen, this was just a plain trick to execute if and else block. i agree with your concerns :) 2011/6/3 Vιиodh vinodh...@gmail.com: @vishal: can u explain the fork()  solution?? On Fri, Jun 3, 2011 at 12:16 PM, Shachindra A C sachindr...@gmail.com wrote: There can be some

Re: [algogeeks] A simple C question

2011-06-03 Thread Vishal Thanki
on console tty's driver takes whole line and output it at once. On Fri, Jun 3, 2011 at 12:40 PM, Vishal Thanki vishaltha...@gmail.com wrote: @sachindra, @naveen, this was just a plain trick to execute if and else block. i agree with your concerns :) 2011/6/3 Vιиodh vinodh

Re: [algogeeks] c output

2011-06-01 Thread Vishal Thanki
you may want to read: http://c-faq.com/expr/seqpoints.html On Wed, Jun 1, 2011 at 5:19 PM, himanshu kansal himanshukansal...@gmail.com wrote: a=++b*++b; if b=3 initially, then a is coming out to be 25.why -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] sum of two n bit binary intergers

2011-05-31 Thread Vishal Thanki
#include stdio.h int main() { int a[8] = {1,0,1,1,0,0,1,1}; int b[8] = {1,0,1,1,0,0,1,1}; int c[9] = {0}; int size = sizeof(a)/sizeof(a[0]); int i; int carry = 0; for (i = size-1; i = 0; i--) { if (a[i] b[i]) {

Re: [algogeeks] Google Interview Question

2011-05-29 Thread Vishal Jain
6785 ... Now merge the numbers based on their actual value. 987976785.. I have not testing this entirely, but after seeing solution(Multiplying by 10) at top, I though this might work better. Thanks Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog

Re: [algogeeks] Re: spoj--two squares problem

2011-05-29 Thread Vishal Jain
Hi Saurabh, Can you try it for 10? Could not really understand, what are you gonna communicate? 10 = 2*5 (2^2 + 1^2 )*(1*2 + 1^2)... If with this logic you are saying 10 is prime then all numbers divisible by 5 should be prime. Could you elaborate your answer more? Thanks Regards Vishal Jain

Re: [algogeeks] Re: Sudoku verification problem

2011-05-29 Thread Vishal Thanki
will evaluate to false. I may be wrong... plz help. On May 28, 9:15 pm, Vishal Thanki vishaltha...@gmail.com wrote: here is the code.. #define bi  (i) #define bj  (GRID_SIZE+j) #define bk  (int)((GRID_SIZE*2)+(glb_sqrt*(i/glb_sqrt)+(j/glb_sqrt))) /*glb_sqrt should be the square root of grid_size (i.e

Re: [algogeeks] Re: Sudoku verification problem

2011-05-29 Thread Vishal Thanki
will always evaluate to false. same thing will happen for every value in the matrix because the corresponding bit has been set earlier. so how is ur verification function working??? On May 29, 3:35 pm, Vishal Thanki vishaltha...@gmail.com wrote: yes, you are right. bitmap will be filled

Re: [algogeeks] Re: Sudoku verification problem

2011-05-29 Thread Vishal Thanki
during the loop when i==5 and j==4, the if condition will always evaluate to false. same thing will happen for every value in the matrix because the corresponding bit has been set earlier. so how is ur verification function working??? On May 29, 3:35 pm, Vishal Thanki vishaltha...@gmail.com

Re: [algogeeks] C Output

2011-05-29 Thread Vishal Thanki
a 0.08f will make it compare to float. by default 0.08 is considered as double. On Sun, May 29, 2011 at 9:51 PM, Ankit Agarwal ankitgeniu...@gmail.com wrote: #includestdio.h int main(void) {     float a=0.08;     if(a0.08)         printf(Hello\n);     else         printf(Hii\n);    

Re: [algogeeks] C Output

2011-05-29 Thread Vishal Thanki
you may want to check how the floats and doubles are stored into memory using ieee notation. i tried to print 0.08 and 0.08f in hex format and got the following result. vishal@ubuntu:~/progs/c\ 10:03:56 AM $ cat fl.c #include stdio.h int main() { float f=0.08; if (f 0.08f

Re: [algogeeks] Finding Blocks in a matrix

2011-05-29 Thread Vishal Thanki
what about using a hash function? On Mon, May 30, 2011 at 10:18 AM, ross jagadish1...@gmail.com wrote: Given a matrix, you need to find the number of blocks in it. A block has the same numbers. EG: 1 1 3 1 2 3 2 2 4 has 4 blocks namely, 1 1 1   2 2 2 3 3 4 1 2 3 4 5 6 7 8 9

Re: [algogeeks] Re: Finding Blocks in a matrix

2011-05-29 Thread Vishal Thanki
not sure what will be the most efficient data structure to implement this in c/c++. Vishal On Mon, May 30, 2011 at 10:31 AM, ross jagadish1...@gmail.com wrote: @vishal Hi, I do not get you. Can you please elaborate a little more how you ll use hash? On May 30, 8:50 am, Vishal Thanki

Re: [algogeeks] Re: Finding Blocks in a matrix

2011-05-29 Thread Vishal Thanki
@anshu, i got you. my bad!! On Mon, May 30, 2011 at 10:49 AM, anshu mishra anshumishra6...@gmail.com wrote: @vishal ur sol wil give wrong answer for this 1 1 2 1 3 1 2 3 4 answer should be 6 but ur sol wil give 4. -- You received this message because you are subscribed to the Google

Re: [algogeeks] Sudoku verification problem

2011-05-28 Thread Vishal Thanki
here is the code.. #define bi (i) #define bj (GRID_SIZE+j) #define bk (int)((GRID_SIZE*2)+(glb_sqrt*(i/glb_sqrt)+(j/glb_sqrt))) /*glb_sqrt should be the square root of grid_size (i.e. 3 if its a 9x9 sudoku). */ /* #define bk (int)((GRID_SIZE*2)+(5*(i/5)+(j/5))) */ /* * This function will

Re: [algogeeks] Sudoku verification problem

2011-05-28 Thread Vishal Thanki
]; } } } } Need not to mention that marix[][] is the 2-D array to represent sudoku grid. On Sat, May 28, 2011 at 9:45 PM, Vishal Thanki vishaltha...@gmail.com wrote: here is the code.. #define bi  (i) #define bj  (GRID_SIZE+j) #define bk  (int)((GRID_SIZE*2)+(glb_sqrt*(i/glb_sqrt)+(j/glb_sqrt

[algogeeks] [CodeFest] Participate in Manthan - Algorithm Intensive Programming Contest

2011-03-13 Thread vishal kumar rai
Hello, *CodeFest'11* http://codefest.org.in/, the annual online international coding festival of Computer Engineering Society IT-BHU, presents Manthanhttp://codefest.org.in/event.php?name=manthan- the *algorithm intensive* programming contest. The contest aims to provide a platform for

[algogeeks] Invitation to CodeFest - the international online coding festival of Computer Engineering Society, ITBHU

2011-02-12 Thread vishal kumar rai
Hello , We are delighted to inform you that *Codefest '11*http://www.itbhu.ac.in/codefest/, the *annual International online coding festival* of *Computer Engineering Society, IT-BHU*, has been unveiled. CodeFest is a unique fest wherein concepts of mathematics, logic, artificial intelligence,

[algogeeks] CodeFest - Online Coding Festival by Computer Engineering Society, IT-BHU

2011-01-27 Thread vishal kumar rai
Hello, We are delighted to inform you that *Codefest'11*http://www.itbhu.ac.in/codefest/, the *annual International online coding festival* of *Computer Engineering Society, IT-BHU*, has been unveiled. CodeFest is a unique fest wherein concepts of mathematics, logic, artificial

[algogeeks] CodeFest - Online Coding Festival by Computer Engineering Society, IT-BHU

2011-01-27 Thread vishal kumar rai
Hello, We are delighted to inform you that *Codefest'11*http://www.itbhu.ac.in/codefest/, the *annual International online coding festival* of *Computer Engineering Society, IT-BHU*, has been unveiled. CodeFest is a unique fest wherein concepts of mathematics, logic, artificial intelligence,

Re: [algogeeks] Re: Single linked list questions.

2011-01-06 Thread vishal raja
@sourabh, In addition to your solution, If there is any cycle(loop) exist in the link list your algo will fail. To solve this problem first detect this cycle if there is any and count the element in the cycle, and then you can do the mathematics. On Thu, Jan 6, 2011 at 6:51 PM, sourabh jakhar

Re: [algogeeks] Re: Single linked list questions.

2011-01-06 Thread vishal raja
@aditya, Who said it's a Y shaped structure, It can very well has a cycle. Assume the case when the last node is not pointing to NULL but to a node in the list. On Thu, Jan 6, 2011 at 7:45 PM, ADITYA KUMAR aditya...@gmail.com wrote: @vishal saurabh is right its merging at only one point its

Re: [algogeeks] Re: combinations problem

2010-12-29 Thread vishal raja
@juver, ofcourse , and that's not a big deal. On Wed, Dec 29, 2010 at 5:11 PM, juver++ avpostni...@gmail.com wrote: Yes, it's true. But we should process DP in the following order not to take one element more than once. -- You received this message because you are subscribed to the Google

Re: [algogeeks] Divide an array into two equal subsets

2010-12-29 Thread vishal raja
] = count[i-1][j] if P(i-1,j) ==1 count[i][j] = count[i-1][j-a[i]] if P(i-1,j-a[i]) ==1 else count[i][j] = 0 On Thu, Dec 30, 2010 at 11:42 AM, vishal raja vishal.ge...@gmail.comwrote: yeah, My bad. Missed that. On Wed, Dec 29, 2010 at 10:52 PM, Wladimir

Re: [algogeeks] Answer This

2010-12-17 Thread vishal raja
There were 20 green eyed people and they will commit suicide on 20th day altogether. See, There is atleast one green-eyed man. So let's take the case if there was only one gree-eyed man. than that man could've seen the colour of all other blued-eyed people and commit suicide on the very first day.

Re: [algogeeks] Arrays

2010-09-20 Thread vishal raja
add up all the elements in array A say sumA and array B say sumB ,substract the sumA from sumB... You'll get the element. On Tue, Sep 21, 2010 at 5:36 AM, Anand anandut2...@gmail.com wrote: Two unsorted arrays are given A[n] and B[n+1]. Array A contains n integers and B contains n+1 integers

Re: [algogeeks] Yahoo!!!! Puzzle

2010-09-14 Thread vishal raja
take out that one A pill that's there in the jar. take the half of all the four pills, that's how u'll make sure that u've had 1 of 'A' and 1 of 'B' pill. On Tue, Sep 14, 2010 at 2:52 PM, bittu shashank7andr...@gmail.com wrote: You are on a strict medical regimen that requires you to take two

Re: [algogeeks] Re: To sort an array of 0,1,2

2010-08-23 Thread Kumar Vishal
. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kumar Vishal StAy HunGrY , StAy fOOlisH

Re: [algogeeks] Next higher element

2010-06-23 Thread Kumar Vishal
, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kumar Vishal StAy HunGrY , StAy fOOlisH Contact No:- 09560193839 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group

[algogeeks] Re: Problem in code

2008-02-23 Thread Vishal
Can we just not post the code here for debugging? This group more related to algorithms than implementations. If your code is not working, use debugger. On Sat, Feb 23, 2008 at 6:22 AM, monty 1987 [EMAIL PROTECTED] wrote: Find out why this program is not working which converts list

  1   2   >