Re: [algogeeks] Fork in c

2012-10-28 Thread Brijesh Kumar
output -text1text2 text2 explaination-system call fork creates a child process copying the whole code of parent but the execution of child process will start after the line where fork is called.thus the two process parent and child will print text2 twice -- You received this message

Re: [algogeeks] Fork in c

2012-10-28 Thread Brijesh Kumar
output - text1text2 -- 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, visit

Re: [algogeeks] Re: kth smallest element

2011-11-11 Thread Brijesh Upadhyay
I guess this approach will work.. -- 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/-/zeydVF1OqioJ. To post to this group, send email to

[algogeeks] Re: Operating System

2011-10-07 Thread Brijesh
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 view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/aVShOmMEE_cJ. To post to this group, send email to

[algogeeks] Re: deep vas shallow

2011-10-01 Thread Brijesh
http://www.learncpp.com/cpp-tutorial/912-shallow-vs-deep-copying Go through this link.. -- 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/-/NIWaOsWRCT0J. To

[algogeeks] Re: Amazon - array problem

2011-09-30 Thread Brijesh
int main() { int a[]={4,3,5,2,6}; // 1 4 12 60 120 const int n=5; int temp=1,i; int b[5]={0}; for(i=0;in;i++) { b[i]=temp; temp*=a[i]; } temp=1; for(i=n-1;i=0;i--) { b[i]*=temp; temp*=a[i];

[algogeeks] Explain Output

2011-09-29 Thread Brijesh
void main() { void *ptr; char *a='A'; char *b=TAN; int i=50; ptr=a; ptr=(*char)malloc(sizeof(a)); printf(%c,*ptr); ptr=i; ptr=(*int)malloc(sizeof(i)); printf(%d,++(*ptr)); ptr=b; ptr=(*char)malloc(sizeof(b)); printf(%c,++(*ptr)); } Ans: A51AN Please explain the output.. Doesnt this line

[algogeeks] Explain output

2011-09-29 Thread Brijesh
void main() { void *ptr; char *a='A'; char *b=TAN; int i=50; ptr=a; ptr=(*char)malloc(sizeof(a)); printf(%c,*ptr); ptr=i; ptr=(*int)malloc(sizeof(i)); printf(%d,++(*ptr)); ptr=b; ptr=(*char)malloc(sizeof(b)); printf(%c,++(*ptr)); } ptr=(*char)malloc(sizeof(a)); Ans: A51AN Please explain the

Re: [algogeeks] Find the output

2011-09-16 Thread Brijesh
On Friday, 16 September 2011 13:25:38 UTC+5:30, Anup wrote: #includestdio.h int main() { int a[5]={1,2,3,4,5}; int *ptr=(a + 1); int *ptr=(int *)(a + 1); printf(%d %d\n,*(a+1),*(ptr-1)); return 0; } Find the output! Now it will print 2 5 -- You received this message

[algogeeks] Re: Thoughtworks and Tejas network

2011-09-13 Thread Brijesh
yes..please anyone post questions asked in thoughtworks interview -- 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/-/Rpd5yw77HbMJ. To post to this group, send

[algogeeks] Re: Amazon ques

2011-09-11 Thread Brijesh
This is the fastest way I can think of to do this, and it is linear to the number of intervals there are. Let L be your original list of numbers and A be a hash of empty arrays where initially A[0] = [0] sum = 0 for i in 0..n if L[i] == 0: sum-- A[sum].push(i) elif L[i] == 1:

[algogeeks] Re: Object Oriented Programming

2011-09-11 Thread Brijesh
Yaarr do u have pdf file of this book?? -- 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/-/J3_X1gBC3-sJ. To post to this group, send email to

[algogeeks] Re: Object Oriented Programming

2011-09-11 Thread Brijesh
If u have pdf file of this book please attach it :) -- 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/-/UAtjWdjmTIEJ. To post to this group, send email to

[algogeeks] Re: worst case complexity

2011-09-10 Thread Brijesh
i==n j==i*i= n*n k==j=i*i=n*n so total i*j*k=n^5 -- 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/-/jv1X4YzDp_sJ. To post to this group, send email to

[algogeeks] Re: informatica pattern and question of interview

2011-09-10 Thread Brijesh
Yeah..agree with this... Just find minimum no and increment that..! Any counter-example?? On Saturday, 10 September 2011 01:19:41 UTC+5:30, hashd wrote: For question 2 I guess finding the minimum element's index should suffice (considering all elements are positive integer). No need to even

Re: [algogeeks] What would be the ans.

2011-09-10 Thread Brijesh
for RT angled triangle , 0 cudnt be the answer , for obvious reason.. however it'll very small and close to zero... and for any two points on the circumference , there will be a point by which u can make rt angle triangle.. On Saturday, 10 September 2011 18:19:25 UTC+5:30, Neha Singh wrote:

[algogeeks] Re: What would be the ans.

2011-09-10 Thread Brijesh
let say there are n points on the circumference, then for rt angle triangle , answer would be nC2..select any two points , u'll always get a point which will make rt angle triangle.. but again we can not define no of points on circle..so :| On Saturday, 10 September 2011 14:47:53 UTC+5:30,

Re: [algogeeks] What would be the ans.

2011-09-10 Thread Brijesh
But probability ZERO means , impossible scenario , while this is possible so better say very less, near to zero..not zero exactly :P -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Object Oriented Programming

2011-09-10 Thread Brijesh
Guys please suggest me any good book for object oriented programming..which have lots of example of good design pattern. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Kth largest element

2011-09-08 Thread Brijesh
make a max heap of size K , and keep inserting all the elements in it.. and at last the root will be the k-th largest element ! O(nlogk) On Thursday, 8 September 2011 22:32:52 UTC+5:30, Sandeep Chugh wrote: wat abt creating a max heap? and then deleting root element k-1 times.. after then

[algogeeks] Re: Amazon Interview question

2011-09-08 Thread Brijesh
Please reply with your alog...! -- 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/-/OGVCUV_hutUJ. To post to this group, send email to

[algogeeks] Re: convert a word into a palindrome with minimum addition of letters to it

2011-09-06 Thread Brijesh
This can be solve by considering following case: i) If all the letters in the word are distinct : Just concatenate, reverse of the string(excluding last letter) to the original word..e.g. ZXKH==ZXKH KXZ ii)If two letters are same in the word : First ignore all the letters between those same

[algogeeks] Re: Let's see if U can find the bug...

2011-08-30 Thread Brijesh
It is problem of loss of data..as pow(x,y) returns double value and adding it to int truncate some data... if u write this sum+=(float)pow(r,3); it'll work fine! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the

[algogeeks] Re: Winshuttle Interview Questions

2011-08-29 Thread Brijesh
Yaar second question thoda elaborate kar.. didn't get it ! -- 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/-/3ClTQN8-GBEJ. To post to this group, send email to

[algogeeks] Re: subset with sum

2011-08-29 Thread Brijesh
Sort the array and use dynamic programming.. it will take at most n^2 complexity.! BY dynamic programming , i mean make a 3D type array.. which will give all the combination which sums to all the nos.. try it! -- You received this message because you are subscribed to the Google Groups

[algogeeks] Winshuttle Pattern and Question *Urgent*

2011-08-27 Thread Brijesh
Can anyone please post the pattern and questions asked by winshuttle , as it is coming to my college tomorrow..?? -- 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

[algogeeks] Re: Winshuttle Pattern and Question *Urgent*

2011-08-27 Thread Brijesh
lol.. Tu bhi yahin pe? yaar samsung me intern he mili hai.. final offer nahi :| and btw winshuttle us se achhi hai shayad! On Aug 27, 4:08 pm, SANDEEP CHUGH sandeep.aa...@gmail.com wrote: @birju : Samsung nhi leni kya?? On Sat, Aug 27, 2011 at 12:45 PM, Brijesh brijeshupadhyay

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

2011-08-27 Thread Brijesh
How to add two nos without using any operator...? -- 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/-/MpNKzlE3UuwJ. To post to this group, send email to

[algogeeks] Make My Trip *URGENT*

2011-08-17 Thread Brijesh Upadhyay
has anyone given MMT written test.?? please reply , what is the pattern of the paper? -- 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

Re: [algogeeks] Amazon Interview Q

2011-08-17 Thread Brijesh Upadhyay
But it is not circular doubly linked list.,..so u could not traverse in backward dirction from HEAD node.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Amazon Interview Q

2011-08-17 Thread Brijesh Upadhyay
At the node from where the loop just started.. anyway we could not use that logic , coz it isnt circular linked list! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] Re: shortest swapping rows

2011-08-17 Thread Brijesh Upadhyay
Make an array of size n, and fill it with index of last 1 of corresponding row in the matrix.. as if row 0 has 1101100 , than arr[0]=4 . so we end up with an array containing last position of 1 in the respective row.. lets arr[4] is like 3,2,2,1... we have to make it 1,2,2,3.. so now apply

[algogeeks] Re: shortest swapping rows

2011-08-17 Thread Brijesh Upadhyay
IT is the question.. You are given an N x N matrix with 0 and 1 values. You can swap any two adjacent rows of the matrix. Your goal is to have all the 1 values in the matrix below or on the main diagonal. That is, for each X where 1 ≤ X ≤ N, there must be no 1 values in row X that are to

[algogeeks] Re: Number theory

2011-08-16 Thread Brijesh Upadhyay
Actually it was one of the assignments given to me in lab.. here is the code #include iostream.h #include conio.h using namespace std; int a[20][20][20]; // Global declration to make every cell's default value to zero // 3D matrix to implement the algorithm void combinations(int number) //

[algogeeks] find numbers whose difference is min

2011-08-15 Thread Brijesh Upadhyay
Algorithm to find the two numbers whose difference is minimum among the set of numbers. For example the sequence is 5, 13, 7, 0, 10, 20, 1, 15, 4, 19 The algorithm should return min diff = 20-19 = 1. Constraint - Time Complexity O(N) -- You received this message because you are subscribed to

[algogeeks] C Output

2011-08-14 Thread Brijesh Upadhyay
int main () { printf(%d,1+2+5); getch(); return 0; } what should it return and how..?? -- 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/-/2H3Gg6hLEQ0J.

[algogeeks] Re: C Output

2011-08-14 Thread Brijesh Upadhyay
I think i got it... STRING always return address of S , which then get summed with 1 and 2. -- 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/-/kFrZUxzFTxsJ.

[algogeeks] Re: String questions

2011-08-13 Thread Brijesh Upadhyay
Dynamic programming would surely help but i dont know the algo :| :P -- 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/-/MD3432cto60J. To post to this group,

Re: [algogeeks] pls help

2011-08-10 Thread Brijesh Upadhyay
It could have a maximum of 81 leaves with the same '40' no of internal nodes so for any value between 28 to 81, it would have only 40 internal nodes -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Re: Microsoft written!!!

2011-08-10 Thread Brijesh Upadhyay
thank u , i couldnot have answered this :P -- 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/-/Gppo1P-Gr9oJ. To post to this group, send email to

[algogeeks] Re: Microsoft Written Test Questions

2011-08-10 Thread Brijesh Upadhyay
Yeah...please share questions..it will be of a lot help! -- 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/-/cs4XYfgJrooJ. To post to this group, send email to

[algogeeks] Probability question.. help

2011-08-09 Thread Brijesh Upadhyay
100 men women dance with each other. What is the Probability that a man cannot dance with more than two women? -- Regards, Brijesh Upadhyay CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] Probability question.. help

2011-08-09 Thread Brijesh Upadhyay
No thers is not.. someone has asked me this., dont know anything else about the question :| -- 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/-/mqMvDgb6TqUJ.

[algogeeks] Re: Microsoft written!!!

2011-08-09 Thread Brijesh Upadhyay
simple algo.. : let we have to find leftmost right cousin of x! try to get an ancestor of the node x such that x lies in left subtree of that ancestor , and count no of levels , say L, u moved to get that ancestor..now start from that ancestor to get left most node , by going down L

[algogeeks] Re: Microsoft written!!!

2011-08-09 Thread Brijesh Upadhyay
simple algo.. : let we have to find leftmost right cousin of x! try to get an ancestor of the node x such that x lies in left subtree of that ancestor , and count no of levels , say L, u moved to get that ancestor..now start from that ancestor to get left most node IN THE RIGHT SUBTREE , by

[algogeeks] Re: Microsoft written!!!

2011-08-09 Thread Brijesh Upadhyay
10 4 5 2 7 6 11 1 39 8 12 13 14 15 let u have to fine leftmost right cousin of 8 . , move up , u get 10 as the ancestor , such that its left subtree contains 8 , unlike 7 ,4 (whose right

Re: [algogeeks] pls help

2011-08-09 Thread Brijesh Upadhyay
I dont think 27 is the right answer,... it should be log 28 /log 3... i mean log 28 base 3 shuold be the no. of internal nodes ! and for any no of leaves , 2781, the answer would be same... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] pls help

2011-08-09 Thread Brijesh Upadhyay
80??? how can 80 internal nodes just produce only maximum of 81 leaves and that too in 3ary tree the answer is 1+3+9+27 = 40 internal nodes... think like this -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on

Re: [algogeeks] pls help

2011-08-09 Thread Brijesh Upadhyay
1 produces 3 nodes , which then 9 nodes,-- 27 nodes , and thses 27 nodes finally produces =81 leaves so sum of 27+9+3+1= 40 is the right answer... i guess -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web

Re: [algogeeks] pls help

2011-08-09 Thread Brijesh Upadhyay
General approach would be , get the no of levels first by log 28 /log 3 , = 4(use ceiling)...and now 3^0+3^1+3^2+3^3 = 40 will be no of internal nodes.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] C easy doubt

2011-08-08 Thread Brijesh Upadhyay
int main() { int a[3][4]={1,2,3,4,5,6,7,8,9,10,11,12}; printf(%u %u %u,a, a+1,a+1); getch(); } how a+1 is valid..?? please explain -- Regards, Brijesh Upadhyay CSE , final year. Thapar University -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] C easy doubt

2011-08-08 Thread Brijesh Upadhyay
Thank you , every 1 . got it... -- 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/-/3cPVG1k4kJ4J. To post to this group, send email to

Re: [algogeeks] Amazon Question

2011-08-08 Thread Brijesh Upadhyay
Yeah.. 3rd answer is 1:1 , for reference http://discuss.fogcreek.com/techInterview/default.asp?cmd=showixPost=150 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] sizeof operator C..

2011-08-08 Thread Brijesh Upadhyay
#includeiostream.h #includeconio.h int main() { int a[2]={1,2}; coutsizeof(a) sizeof(a)endl; couta aendl; couta+1 a+1endl; getch(); } It gives size of 'a' as 8 and 'a' as 4...which i hadnt expected.. and then a+1 is increasing just 4 while a+1 is increasing 8 in

Re: [algogeeks] Re: Directi interview question

2011-08-08 Thread Brijesh Upadhyay
Yeah..right..! u have to select continuous 10 petrol pumps , so just traverse through every set of 10 pumps with complexity of o(n). e.g. (1,10) (2,11) (3,12)(91 ,100) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this

[algogeeks] Re: amazon

2011-08-07 Thread Brijesh Upadhyay , Computer Science , 4th year , Thapar Universoty
Could u please explain how shell sort... why not quick sort?? On Aug 7, 10:42 pm, sourabh jakhar sourabhjak...@gmail.com wrote: shell sort is the correct answer On Sun, Aug 7, 2011 at 11:09 PM, ankit sambyal ankitsamb...@gmail.comwrote: bubble sort -- You received this message because

[algogeeks] Re: amazon

2011-08-07 Thread Brijesh Upadhyay , Computer Science , 4th year , Thapar Universoty
How?? could u please explain..? why not quick sort? On Aug 7, 10:27 pm, rajeev bharshetty rajeevr...@gmail.com wrote: b:Shell sort On Sun, Aug 7, 2011 at 10:56 PM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: 1.what is the best sorting method for almost sorted array?

Re: [algogeeks] Re: Probability Puzzle

2011-08-07 Thread Brijesh Upadhyay
I think 17/80 is right answer.. otherwise no use of mentioning *first five times* specifically in the question. ! though m not sure -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] C question.. sizeof operator

2011-08-03 Thread brijesh
main() { int i,j; i=10; j=sizeof(++i); printf(%d,i); } please give the output with explanation! -- 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,

[algogeeks] C question.. increment decrement operator..

2011-08-03 Thread brijesh
Please give the output and explain.. main() { int i=7; printf(%d\n,i++*i++); printf(%d\n,i++*++i); printf(%d\n,++i*i++); printf(%d\n,++i*++i); } What is the order of execution!? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] Re: Amazon Written test Q-1

2011-08-02 Thread brijesh
We can do it by just having an extra pointer variable which will store either rightmost 2's *next node* or left most 2's *previous node*(as it is doubly linked list)..now start traversing through rear end , if u get 1 , send it to front..if u get 3 send it to rear , and if u get 2 the insert it

[algogeeks] Re: adobe written round que

2011-07-29 Thread brijesh
@ankur I didnt get this... could u or anyone please elaborate! On Jul 30, 12:43 am, Ankur Khurana ankur.kkhur...@gmail.com wrote: when you use itoa , what you get is a string. get the sum of all the digits , using c-'0' and then use repeated subtraction . . . On Sat, Jul 30, 2011 at 1:01 AM,