[algogeeks] kth smallest element in 2 sorted arrays

2013-06-09 Thread rahul sharma
Please suggest logm+logn aproach... can be easily done in o(k) How to do in logm +logn plz suggest algo -- 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 to alg

Re: [algogeeks] Re: Median of two sorted arrays of different sizes

2013-06-09 Thread rahul sharma
t; > int min = 0; > int max = sizeA; > const int medianPos = (sizeA + sizeB) / 2; > while(max >= min) > { > i = (min + max) / 2; > j = medianPos-i; > if (B[j] > A[i]) min = i+1; > else if (B[j+1] < A[i]) max = i-1; > else break; > } > >

Re: [algogeeks] Minimum number of coins to SUM to S

2013-06-05 Thread rahul sharma
> wrote: > >> This seems to be Coin Change problem. Just google that. >> >> >> On Tue, May 28, 2013 at 12:42 AM, Adolfo Ccanto wrote: >> >>> Can you write the constraints for this problem? >>> thanks. >>> Adolfo >>> >>>

[algogeeks] Re: t9 dictionary

2013-06-05 Thread rahul sharma
Can i implement by trie which is having structure as 9 pointers for 9 digits..like if it comes 4663...i will make a path 4663 from root to leaf and in end i will have a linked list to store dataany more optimized solution anyone having???plz suggest On Thu, May 30, 2013 at 2:37 AM, rahul

[algogeeks] A Juggling Algorithm

2013-06-05 Thread rahul sharma
Can anybody explain me how juggling algo works for array rotation ???Whats the logic behind this? -- 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 to algogeeks+un

Re: [algogeeks] Re: searching all matching words in a Trie with a given filter.

2013-06-05 Thread rahul sharma
wat exaclty the question is. We have to make a tire with filter or we have a trie(whole dictionary) and we have to check filter out the elements. plz explain question On Wed, May 29, 2013 at 7:55 PM, Don wrote: > There has to be some way to know that a node is the end of a word, and > to k

[algogeeks] t9 dictionary

2013-06-05 Thread rahul sharma
how to implement with trie.???is trie the best way..plz provide me raw algo to start with, -- 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 to algogeeks+unsubscr.

Re: [algogeeks] searching all matching words in a Trie with a given filter.

2013-05-29 Thread rahul sharma
@don u r searching in a previously built trie with the given filter...then wat is this add fxn doing?correct me if m getting u wrng On Wednesday, May 29, 2013, avinesh saini wrote: > Thank you Don, I was also trying in similar way. But here I'm confused how you are storing the traversed words. Are

Re: [algogeeks] Re: count number of set bits in an (big) array (Asked in Google interview)

2013-05-27 Thread rahul sharma
@don..you are counting in an integer only...correct if wrng? On Wed, May 22, 2013 at 7:28 PM, Don wrote: > My program works with any numbers. > Don > > On May 22, 3:45 am, Pramida Tumma wrote: > > This above program works only if the array contains consecutive numbers > > starting from 1 to n.

[algogeeks] [Adobe]Generate all possible combinations (of r elements) inside an array of size N

2013-05-27 Thread rahul sharma
Generate all possible combinations (of r elements) inside an array of size N E.g. arr [] = {2,8,14} All possible combinations of r=2 will be {2,8}, {8,14}, {14,2} Asked in adobe -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe

Re: [algogeeks] Re: count number of set bits in an (big) array (Asked in Google interview)

2013-05-27 Thread rahul sharma
@don...i got it...its complexity is logn..how? On Thu, May 23, 2013 at 11:10 AM, rahul sharma wrote: > @don..you are counting in an integer only...correct if wrng? > > > On Wed, May 22, 2013 at 7:28 PM, Don wrote: > >> My program works with any numbers. >> D

Re: [algogeeks] least common ancestore bst

2013-05-27 Thread rahul sharma
gt; On Mon, May 13, 2013 at 1:42 AM, rahul sharma wrote: > >> [image: BST_LCA] >> what should be ancestor of 12 and 14.it should be 12 or >> 14...if 12 then for 20 and 22 also it is 20...if 12 ans 14 has >> ancestor as 8 then for 20 and 22 it is NULL

Re: [algogeeks] Re: count number of set bits in an (big) array (Asked in Google interview)

2013-05-27 Thread rahul sharma
guys ..i got solution here http://www.geeksforgeeks.org/program-to-count-number-of-set-bits-in-an-big-array/ plz tell how its complexity is logn. On Fri, May 17, 2013 at 6:55 PM, Don wrote: > Counting the set bits in one integer is not the problem which was > asked. > However, I think that som

[algogeeks] lexographic permutations complexity

2013-05-27 Thread rahul sharma
following is code from geeks for geeks. Please tell how the complexity of this in n*n! n*n! times loop will be executed and then wat about the statements in loop?? reference:- http://www.geeksforgeeks.org/lexicographic-permutations-of-string/(second method) void reverse(char str[], int l, int

Re: [algogeeks] Re: count number of set bits in an (big) array (Asked in Google interview)

2013-05-27 Thread rahul sharma
and how this is working void init() { bitCount[0] = 0; for(int i = 1; i < 65536; ++i) bitCount[i] = bitCount[i/2] + (i&1); } it is working fine..but plz tell the logic behind this On Thu, May 23, 2013 at 11:12 AM, rahul sharma wrote: > > @don...i got it...its complexity is logn..

Re: [algogeeks] Re: count number of set bits in an (big) array (Asked in Google interview)

2013-05-27 Thread rahul sharma
@pramidathat can be done in 0(n)..lets say int takes 4 bytes i will make and array of first 256 numbers ... while finding for inte i will take a char pointer pointing to first byte and then using array of 256 int i will count in that byte and increent array and count in it.and so on...acces

[algogeeks] Minimum number of coins to SUM to S

2013-05-27 Thread rahul sharma
Minimum of coins to sum s -- 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 to algogeeks+unsubscr...@googlegroups.com.

Re: [algogeeks] least common ancestore bst

2013-05-16 Thread rahul sharma
ect me if i am wrong? > Thanks, > Tushar Patil. > > > > On Sun, Apr 21, 2013 at 10:26 PM, rahul sharma wrote: > >> int leastCommanAncestor(struct node* root, int n1, int n2) >> { >> if(root==NULL) >> return -1; >> if(root->data>n1 &&a

[algogeeks] Next higher number with same number of set bits

2013-05-12 Thread rahul sharma
unsigned snoob(unsigned x) { unsigned smallest, ripple, ones; // x = xxx0 smallest = x & -x; // 0001 ripple = x + smallest; // xxx1 ones = x ^ ripple; // 0001 ones = (ones >> 2)/smallest; // 0111 return ripple | ones; // xxx1 0111 } please ex

[algogeeks] count number of set bits in an (big) array (Asked in Google interview)

2013-05-12 Thread rahul sharma
I was searching for google questions and got this question.Use look up to do it in bext way What is best time complexity for this.. plz post algo too -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop re

Re: [algogeeks] MS written Reasoning question

2013-05-03 Thread rahul sharma
be selected. > (3) Remaining 1 would be MCA. > > > So ans would be (d) > > option (b) is not correct as it says that only 2 mba and only 1 mca are > selected but the total no of selected candidates are 6. > > -- > Ashish > > > On Fri, Apr 26, 2013 at 11:32 PM,

[algogeeks] MS written Reasoning question

2013-04-28 Thread rahul sharma
10 candidates appear for an interview and 6 selected. 2-M.A 2-MCA 4-BTECH 2-MBA. If at least one MBA is selected then exactly 2 btech are selected and vice versa. Of six candidates,exactly one must be an MA cndidate question:- which of the following statementsis definitely true:,if 2 btech are sel

Re: [algogeeks] Re: Find the number of islands/connected components

2013-04-26 Thread rahul sharma
t; On Fri, Apr 26, 2013 at 3:11 AM, Don wrote: > >> The complexity is still O(ROWS*COLS) because each location in the >> matrix will be visited once by the loop and once by DFS. Once a >> location has been visited by DFS, it is marked as visited and can't be >> visited

[algogeeks] Re: Find the number of islands/connected components

2013-04-25 Thread rahul sharma
What will be complexity if all elements in matrix are 1.. when first dfs will call then all matrix will be scanned setting each element to visited... then again loop contiues to scan all the elements..plz explain On Thu, Apr 11, 2013 at 2:04 AM, rahul sharma wrote

[algogeeks] Re: Find the number of islands/connected components

2013-04-25 Thread rahul sharma
@don..can u plz tell me how the complexity of this http://www.geeksforgeeks.org/find-number-of-islands/ is ROW*COL? On Thu, Apr 11, 2013 at 4:35 PM, rahul sharma wrote: > > M not getting matrix..is it adjacencyif simple 1 means connected > components then first wehave 3 ones..then

[algogeeks] Median of two sorted arrays of different sizes

2013-04-24 Thread rahul sharma
IS this code correct? float findMedianUtil( int A[], int N, int B[], int M ) { // If the smaller array has only one element if( N == 1 ) { // Case 1: If the larger array also has one element, simply call MO2() if( M == 1 ) return MO2( A[0], B[0] );

Re: [algogeeks] Re: least common ancestore bst

2013-04-21 Thread rahul sharma
estor. > > It seems that common usage is that a node is its own ancestor; see, e.g., > http://en.wikipedia.org/wiki/Lowest_common_ancestor. > > Dave > > On Sunday, April 21, 2013 11:56:01 AM UTC-5, rahul sharma wrote: > >> int leastCommanAncestor(struct node* root, int n1,

[algogeeks] least common ancestore bst

2013-04-21 Thread rahul sharma
int leastCommanAncestor(struct node* root, int n1, int n2) { if(root==NULL) return -1; if(root->data>n1 && root->data>n2) return leastCommanAncestor(root->left,n1,n2); else if(root->datadataright,n1,n2); return root->data; } Does this code miss any case?N suppose if we have to find LCA of n

Re: [algogeeks] Interview Question

2013-04-19 Thread rahul sharma
search the previous posts before posting search for [algogeeks] Amazon Interview Question you will get this -- 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 to a

Re: [algogeeks] Re: algorithm to sort based on frequency.

2013-04-16 Thread rahul sharma
Can anyone give me example using hash+linked list method ..although i got dave method.but still... On Tue, Apr 16, 2013 at 8:58 PM, Dave wrote: > @Varun: Here is an algorithm using sorting only: > > 1. Append an index onto each number, so your example becomes {{4,0}, > {3,1}, {2,2}, etc.} > > 2

Re: [algogeeks] Re: algorithm to sort based on frequency.

2013-04-16 Thread rahul sharma
@don.can u plz explain with example. On Wed, Feb 1, 2012 at 9:29 PM, Don wrote: > Build a hashmap with the array value as a key mapping to a struct > which contains the key, frequency, and location of first occurance. > Then sort the hashed elements comparing first by frequency and > breaking t

[algogeeks] MS interview question

2013-04-14 Thread rahul sharma
Suppose you are given a string IAMABOY and a dictionary then divide it into I AM A BOY if it is possible to break form as many dictionary words from a string giveM able to solve it..but how if we are given a string like IXAFGMJAHBDSOXDY. how can we form I AM A BOY..will be done in Opower(2,n)

[algogeeks] inplace m*n transpose

2013-04-12 Thread rahul sharma
in this there are permutation cycles which are used to do transpose.can anybody tell me nl = (ol x R) mod (N-1) nl- new location ol- old location N-total elements if i is current element then it will be placed at new location next = (i*r)%size; r- no. of rows please explain how it works log

[algogeeks] Re: Find the number of islands/connected components

2013-04-11 Thread rahul sharma
: > islands are five as for each cell we assume all surrounding positions to be connected... so if coordinates are (x,y) then it is connected to (x+1, y), (x-1, y), (x+1, y+1), (x-1, y+1), (x+1, y-1), (x-1, y-1), (x, y-1), (x, y+1 > > > On Thu, Apr 11, 2013 at 9:35 AM, rahul sharma wrote: &

[algogeeks] Re: Find the number of islands/connected components

2013-04-10 Thread rahul sharma
lly, horizontally, or diagonally. > So the five islands are > > 11000 > 01002 > 10022 > 0 > 30405 > > Don > > On Apr 10, 4:34 pm, rahul sharma wrote: >> {*1*,* 1*, 0, 0, 0}, >> {0, *1*, 0,

[algogeeks] Re: Interview question

2013-04-10 Thread rahul sharma
> > On Apr 10, 4:19 pm, rahul sharma wrote: >> isnt the complexity should be o(m*n*n) instead of (n*n*n) as m can be >> greater than n..plz comment >> >> On Wed, Apr 10, 2013 at 10:11 PM, rahul sharma wrote: >> >> >> >> >> >> >

[algogeeks] Find the number of islands/connected components

2013-04-10 Thread rahul sharma
{*1*,* 1*, 0, 0, 0}, {0, *1*, 0, 0, *1*}, {*1*, 0, 0, *1*, *1*}, {0, 0, 0, 0, 0}, {*1*, 0, *1*, 0, *1*} Can anybody eplain how there are 5 islands in above matrix..thnx in advan

[algogeeks] Re: Interview question

2013-04-10 Thread rahul sharma
isnt the complexity should be o(m*n*n) instead of (n*n*n) as m can be greater than n..plz comment On Wed, Apr 10, 2013 at 10:11 PM, rahul sharma wrote: > > http://www.geeksforgeeks.org/dynamic-programming-set-27-max-sum-rectangle-in-a-2d-matrix/ > > wat is complexity of this..

[algogeeks] Interview question

2013-04-10 Thread rahul sharma
http://www.geeksforgeeks.org/dynamic-programming-set-27-max-sum-rectangle-in-a-2d-matrix/ wat is complexity of thisn3 or mn2 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails fr

[algogeeks] Re: Trie | (Insert and Search)

2013-04-10 Thread rahul sharma
M asking in case of DELETE from trie fxn On Wed, Apr 10, 2013 at 9:15 PM, rahul sharma wrote: > http://www.geeksforgeeks.org/trie-insert-and-search/ > > Can any body tell me what is need of checking pcrawl!=0 int the > return..cant we check only its value>0 to check whether

[algogeeks] Trie | (Insert and Search)

2013-04-10 Thread rahul sharma
http://www.geeksforgeeks.org/trie-insert-and-search/ Can any body tell me what is need of checking pcrawl!=0 int the return..cant we check only its value>0 to check whether its a leaf node return (0 != pCrawl && pCrawl->value); -- You received this message because you are subscribed to the Goog

Re: [algogeeks] Re: Amazon interview question

2013-04-09 Thread rahul sharma
If you have any other solution ..please post that...i thnik recursion is ok with base case...we need to scan again after first iteration...?? On Wed, Apr 10, 2013 at 12:12 AM, rahul sharma wrote: > i forgot to add base case..can add wen 2 elemnts are there then there sum > is stored

Re: [algogeeks] Re: Amazon interview question

2013-04-09 Thread rahul sharma
times. > > However, I would suggest not using recursion. There is no reason to > not do it iteratively. Your recursive solution has no base case so it > will recurse until your computer runs out of stack space, at which > point it will crash. > > Don > > On Apr 9, 2:29 pm, ra

[algogeeks] Amazon interview question

2013-04-09 Thread rahul sharma
A = {5, 3, 8, 9, 16} After one iteration A = {3-5,8-3,9-8,16-9}={-2,5,1,7} After second iteration A = {5-(-2),1-5,7-1} sum =7+(-4)+6=9 Given an array, return sum after n iterations my sol/ void abc(int arr[],n) { for(i=0;ihttps://groups.google.com/groups/opt_out.

Re: [algogeeks] Re: Dlete Linked List

2013-04-09 Thread rahul sharma
ote: > "head" is not even declared, so I doubt that it would compile. > I believe that you want to free head, not next. > > > On Apr 9, 11:31 am, rahul sharma wrote: > > Is the following code correct for linked list deletion or i need to copy > > head in some tem. p

[algogeeks] Re: Median in stream of running integers

2013-03-24 Thread rahul sharma
es nothing and leave the >> heap in an invalid state. >> >> Comapring l and r child to find maximum/minimum is only needed in prelocate >> down, not in prelocate up. >> >> >> 2013/3/24 rahul sharma >> >>> And also in heapify y we r not co

Re: [algogeeks] [Off topic] Call for Moderators for Algogeeks

2013-03-14 Thread rahul sharma
You mean one who can provide solutions to the pending questions or some type of management of group like the type of posts and off topic?? On Wed, Mar 13, 2013 at 11:25 PM, shady wrote: > Hi, > Does anyone wants to be moderator ? We want someone who is actively > participating in discussions

[algogeeks] Re: trie implementation

2013-03-14 Thread rahul sharma
On Thursday, March 14, 2013, rahul sharma wrote: > Can anybody provide any link me to understand t9 implementation? I dnt need code..I need how to implement t9 with trie with explanation..thnx in advance -- You received this message because you are subscribed to the Google Groups "A

[algogeeks] trie implementation

2013-03-14 Thread rahul sharma
Can anybody provide me to understand t9 implementation? I dnt need code..I need how to implement t9 with trie with explanation..thnx in advance -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving

[algogeeks] Compiler doubt

2013-01-22 Thread rahul sharma
S->aAbB\bAaB\e A->S B->s Find follow(A) and follow(B)???explanation required??thnx in advance --

[algogeeks] B-Tree

2013-01-01 Thread rahul sharma
IF btree is of order n,then what is min nuber of values at each node Is it floor(n/2) a I read if oreder is 5 then min values in each node is 2...SO is it floor(n/2) --

[algogeeks] DBMS gate 2012 query

2012-12-27 Thread rahul sharma
HI please explain the following question no: 2 on below link as i am not able to copy it. http://www.geeksforgeeks.org/database-management-system-set-3/ --

Re: [algogeeks] Re: adobe apti question

2012-12-16 Thread rahul sharma
st occur" is asked my answer is option C > > > On Sun, Dec 16, 2012 at 11:39 PM, marti wrote: > >> Yes I feel (e) is the right option. >> >> >> On Sunday, December 16, 2012 11:18:57 PM UTC+5:30, rahul sharma wrote: >>> >>> A causes B or C, but

Re: [algogeeks] C o/p adobe

2012-11-16 Thread rahul sharma
s of *the* book The C Programming Language by Dennis Ritchie: >> There must be only one definition of an external variable among all the >> files *that make up the* >> *source program*; other files may contain extern declarations to access >> it. (There may also be >> extern declarat

Re: [algogeeks] C o/p adobe

2012-11-16 Thread rahul sharma
; } >> // end of file2.c >> >> compile both file together >> as >> rahul@rahul:~gcc file1.c file2.c >> rahul@rahul:~./a.out >> you will get the required output >> >> >> >> >> >> On Fri, Nov 16, 2012 at 8:27 AM, Neera

Re: [algogeeks] C o/p adobe

2012-11-15 Thread rahul sharma
ndian Institute of Technology Roorkee > Contact No. : +91 9897073730 > > > > On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma wrote: > >> but how can i use extern..if i simply declare a variable in file1 as int >> j and try to use in file2 with extern then it shows that j nit de

Re: [algogeeks] C o/p adobe

2012-11-15 Thread rahul sharma
t() > { > ++i; > printf("%d\n",i); > //printf("%d",j); // since no defintion provided so getting error > other(); > } > > file2.c > > > extern int i; > void other() > { > ++i; > printf("%d\n",i); > } > > if you

Re: [algogeeks] Add and subtract with out using mathematical operator.......

2012-11-07 Thread rahul sharma
following using exor http://www.geeksforgeeks.org/archives/18324 following is tricky http://www.geeksforgeeks.org/archives/22080 On Wed, Nov 7, 2012 at 11:36 AM, Rahul Kumar Patle < patlerahulku...@gmail.com> wrote: > you can use bit wise addition.. using xor , and , or and shift op > erations..

Re: [algogeeks] Time Complexity Analysis

2012-11-05 Thread rahul sharma
dude n for build tree and n in this for finding maximun??so n*(n/2)=o(n^2) On Mon, Nov 5, 2012 at 8:54 PM, shady wrote: > Here the time complexity of the solution should be O(n * log(n)) > http://www.geeksforgeeks.org/archives/21781 > > -- > You received this message because you are subscrib

Re: [algogeeks] Ternary operators

2012-11-01 Thread rahul sharma
ut as *cout << test* will take precedence, there is > no point of putting a ternary operator there, unless you use braces, of > course. > > > In teh second case however, reason given is valid: > i.e. return type of ternary operator is determined by "A String" and

[algogeeks] You are given two 32-bit numbers, N and M, and two bit positions, i and j.

2012-10-31 Thread rahul sharma
You are given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j). EXAMPLE: Input: N = 100, M = 10101, i = 2, j = 6 Output: N = 10001010100 Following is

[algogeeks] Extern in c

2012-10-31 Thread rahul sharma
How actually to use extern suppose in file 1 i write code..(test_new.c) #include #include int interest_rate =5; int main() { int test = 0; int t=5; // cout< #include"test_new.c" extern int interest_rate; void fun() { interest_rate=6; } it works.. now if i make interest_rate as stati

Re: [algogeeks] BIG O

2012-10-31 Thread rahul sharma
le loop in the above code? >>>> >>>> I understand that the for loop implies O(n),does the log n in the O(n >>>> log n) comes from the while loop? >>>> What if there where two while loops in the for loop separately? >>>> >>&g

Re: [algogeeks] Ternary operators

2012-10-31 Thread rahul sharma
plz read carefully On Wed, Oct 31, 2012 at 10:18 AM, Tamanna Afroze wrote: > sorry for my last post, i didn't look carefully at the code. I think > without bracket the ternary expression is incomplete, that's why; first > code doesn't compile correctly. > > > > On Wed, Oct 31, 2012 at 9:51 AM, Ta

Re: [algogeeks] Re: Repeated values

2012-10-30 Thread rahul sharma
i thnik this is the solution... http://www.geeksforgeeks.org/archives/9755 On Wed, Oct 31, 2012 at 2:20 AM, Don wrote: > We can modify the array. The algorithm should work even if we use > unsigned integers and N is the largest unsigned integer. > > Don > > On Oct 30, 4:4

Re: [algogeeks] Re: Repeated values

2012-10-30 Thread rahul sharma
Can we modify the array???we can make index we visit as negative and then if any one already containing -ve..then its repeating On Wed, Oct 31, 2012 at 1:40 AM, Don wrote: > Does your algorithm work if N=4 and the array is {1,1,2,2}. > > Don > > On Oct 30, 2:32 pm, arumuga abinesh wrote: > > if

Re: [algogeeks] C Macro

2012-10-30 Thread rahul sharma
..before and after the swap then >> you should see that after swap p will be holding address of x and >> q will be holding address of a..that it >> >> On 10/29/12, rahul sharma wrote: >> > I have taken form book...i am writing exact code >> >

Re: [algogeeks] Re: #in macros

2012-10-30 Thread rahul sharma
gt; http://gcc.gnu.org/onlinedocs/cpp/Argument-Prescan.html#Argument-Prescan > > > > > On Sun, Oct 28, 2012 at 3:28 PM, rahul sharma wrote: > >> And when char *opername=str(oper); >> >> then o/p is operwhy behaviour is diff. in 2 cases >> >> O

Re: [algogeeks] Pre/Post L and r value

2012-10-30 Thread rahul sharma
s > you would be assigning nowhere. > > On 27 October 2012 20:09, rahul sharma wrote: > >> But y post returns temp. object >> >> >> On Fri, Oct 26, 2012 at 8:18 PM, Saurabh Kumar wrote: >> >>> i++: Post increment can't be a lvalue because

[algogeeks] Complicated declaration C

2012-10-30 Thread rahul sharma
void(*f)(void(*)(int*,void **),int(*)(void**,int*)); f is a fxn pointer to fxn which takes 2 args and teturn nothing 2 arguments are 1. pointer to function which returns nothing and takes 2 args one pointer to int and pointer to pointer to void 2. pointer to fxn returning int and takes 2 args a

[algogeeks] C Function Pointer(Typedef)

2012-10-29 Thread rahul sharma
#include #include int func(int); int main(int count,char *argv[]) { typedef int (*pFunc) (int); pFunc=func; getchar(); } Y itz not compiling? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to al

Re: [algogeeks] C Macro

2012-10-29 Thread rahul sharma
to save the address of x and y in temp > pointers i.e > >int *p.*q; > p=&x; > q=&y; > int t; > t=*p; > *p=*q; > *q=t; > now you can convert it into macro. > > On 10/29/12, rahul sharma wrote: >

Re: [algogeeks] C Macro

2012-10-29 Thread rahul sharma
ut not swapping two pointerssplz comment > On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma wrote: > >> its now doing swapping of pointers...plz explain >> >> >> On Sun, Oct 28, 2012 at 8:08 PM, atul anand wrote: >> >>> it should swap >>&

[algogeeks] Re: LCA in BST

2012-10-28 Thread rahul sharma
Sun, Oct 28, 2012 at 9:40 PM, rahul sharma wrote: > According to wiki http://en.wikipedia.org/wiki/Least_common_ancestor > > n1 is parent of n2 then n1 is lcabut according to above algo return > -1..i have taken it from(http://www.geeksforgeeks.org/archives/1029) > > plz tell

[algogeeks] Re: #in macros

2012-10-28 Thread rahul sharma
And when char *opername=str(oper); then o/p is operwhy behaviour is diff. in 2 cases On Sun, Oct 28, 2012 at 2:53 PM, rahul sharma wrote: > #include > #include str(x) #x > #define Xstr(x) str(x) > #define oper multiply > > > int main() > { > char *opername=Xstr(op

[algogeeks] #in macros

2012-10-28 Thread rahul sharma
#include #include str(x) #x #define Xstr(x) str(x) #define oper multiply int main() { char *opername=Xstr(oper); printf("%s",opername); } so firstly Xstr is expanded to str(oper) then str(oper) is expanded to #oper now i have read that If, however, a parameter name is preceded by a # in the

[algogeeks] C Macro

2012-10-28 Thread rahul sharma
Why the following code is not able to swap two macros???although it is easily swapping 2 variables #include #define swap(a,b,c) c t;t=a,a=b,b=t int main int x=10,y=20; int *p,*q; swap(x,y,int); -- You received this message because you are subscribed to the Google Groups "Algorithm Geek

Re: [algogeeks] Fork in c

2012-10-27 Thread rahul sharma
think the output should be : >> >> text1text2 >> text2 >> >> >> >> >> >> On Sat, Oct 27, 2012 at 2:22 PM, rahul sharma wrote: >> >>> int main() { >>> printf("text1"); >>> fork(); >>>

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-27 Thread rahul sharma
@payalplz explain how to slect 3 spaces for a.b.c out of 6. we need to put them in orderso look my aboyve post and plz comment On Sat, Oct 27, 2012 at 8:14 PM, rahul sharma wrote: > plz help mei am thinking this the following way.. > > we need to find no. of permutaions

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-27 Thread rahul sharma
sion and abc in >> other) >> >> You can view this problem as writing all permutations of strings of 3R's >> and 3U's (for RIGHT movement and UP movement) RRRUUU which will take you to >> the top right most corner. >> All possible arrangements = (3+3)! / (

Re: [algogeeks] Sequence Point C with postincremented

2012-10-27 Thread rahul sharma
mp; 1; > >> *a++ *a is Post incremented (a is now 1 but return value is 0) > >> *0 && 1* = 0 (which gets assigned to j) > Hence, j = 0, a = 1 > > On 26 October 2012 18:54, rahul sharma wrote: > >> Guys plz tell that postincremented variable is incremented

Re: [algogeeks] Pre/Post L and r value

2012-10-27 Thread rahul sharma
used only as a rvalue. > ++i: whereas, in Pre-increment value gets incremented and the same > location is returned back to you, hence can be used as lvalue in an > expression.(C++ allows this) > Both can be used as rvalues though. > > On 26 October 2012 18:54, rahul sharma wrote:

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-27 Thread rahul sharma
27;s > and 3U's (for RIGHT movement and UP movement) RRRUUU which will take you to > the top right most corner. > All possible arrangements = (3+3)! / (3! * 3!) > In general: (m+n)! / (m! * n!) for a mxn grid. > > > On 27 October 2012 11:05, rahul sharma wrote: > >>

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-26 Thread rahul sharma
should i take it how many ways are there to reach from start to the top right destination...x,y,z,a,b,c, are i/p statexyzabc one stringabc xyz is another...if m ryt then is dere any formulla to calute or we have to do it manuall On Sat, Oct 27, 2012 at 11:02 AM, rahul sharma wrote

Re: [algogeeks] Finite state automata accpt string of length 6

2012-10-26 Thread rahul sharma
can u please elaborate...i am not able to understand the figure..plz explainit would be of great help On Sat, Oct 27, 2012 at 5:57 AM, payal gupta wrote: > should be 6C3 or 20 perhaps. > > On Sat, Oct 27, 2012 at 3:29 AM, rahul sharma wrote: > >> Finite state automata accp

[algogeeks] BIG O

2012-10-26 Thread rahul sharma
for k=1 to n { j=k; while(j>0) j=j/2; } the complexity is big o is o(nlogn) am i ryt -- 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 ema

[algogeeks] Advice needed

2012-10-26 Thread rahul sharma
There is question asked like O/p of following in C(32 bit OS) #include #include using namespace std; bool IsEqual(char * a) { printf("abc"); return true; } int main() { char str[30]; printf("%d",sizeof(sizeof(IsEqual(str; getchar(); return 0; } I run with .cppi

[algogeeks] Pre/Post L and r value

2012-10-26 Thread rahul sharma
why pre inc. is l value and post is r value..please explain -- 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...@

[algogeeks] Sequence Point C with postincremented

2012-10-26 Thread rahul sharma
Guys plz tell that postincremented variable is incremented after sequence or after ; as we have && || comma and ; as sequence point so say we have int i=10; int j=(i++,i++); firstly i++ goes and as comma comes so ++ post inc. takes place and take to 11 ..now when next time the postincremented is

[algogeeks] .Given the binary form of a number in a string. WAP to find 2's complement in that string itself.[ADOBE]

2012-10-25 Thread rahul sharma
Plz give a program for this...thnx -- 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 mor

Re: [algogeeks] Re: c code help!!!!

2012-10-25 Thread rahul sharma
Please dont reply to thi post..wrng questionsry for that On Fri, Oct 26, 2012 at 2:31 AM, rahul sharma wrote: > address of each byte is printed...each byte is 32 bit long...so 32/4=8 hex > for each row...but how these are separated with %.2x tin group of > 2's%.2x means min

Re: [algogeeks] Re: c code help!!!!

2012-10-25 Thread rahul sharma
ed...print start[i]still how these are able to grouped?? On Fri, Oct 26, 2012 at 1:53 AM, rahul sharma wrote: > As per o/p below: > 00 00 80 3f > 01 00 00 00 > 44 ff 28 00 > 01 00 00 00 > > first byte address is first row. > second byte address is second row. > third b

Re: [algogeeks] Re: c code help!!!!

2012-10-25 Thread rahul sharma
milarly, for pointer: >> char pointer reads 1 Byte at a time. It read 4Bytes in total i.e. 32 >> bits. Hence, you are working on a 32 bit machine. (as pointer has value: >> *44 ff 28 00, *address of i)*.* >> * >> * >> * >> * >> PS: This is an algorithm gr

Re: [algogeeks] Adobe written test question

2012-10-25 Thread rahul sharma
tion when ,when > compiler tried to link with the memory of int arr[10] it could nt find it , > as u have declraed it to be integer type pointer , and in file 1 it could > find integer pointer . > > On Wed, Oct 24, 2012 at 11:06 PM, rahul sharma wrote: > >> int arr[10] // in fyl

[algogeeks] Re: Does recusrion creates array or its by address??

2012-10-24 Thread rahul sharma
I think it is overwritng old values when child end..parent overwrite old value with new..m i ryt? On Thu, Oct 25, 2012 at 3:00 AM, rahul sharma wrote: > I wana ask that when we pass array by recursion then as we know formal > parameters are passed by value and array by base address/point

[algogeeks] Adobe written test question

2012-10-24 Thread rahul sharma
int arr[10] // in fyl 1 now in fyl 2 extern int *arr void foo() { arr[0]=10; } what kind of problem can be there?in what condition and y? plz comment -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algo

Re: [algogeeks] C o/p adobe

2012-10-24 Thread rahul sharma
can nyone provide me dummy code of how exactly to use extern in c.. in dev environment when i declare int i in one fyl and try use use with extern int i in another then it doesnt compile..plz coment On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma wrote: > Then why its not running? > >

Re: [algogeeks] C o/p adobe

2012-10-24 Thread rahul sharma
gt; declaration/definition of C functions, it is present there. For example, > when we write. > > int foo(int arg1, char arg2); > > There’s an extern present in the beginning which is hidden and the > compiler treats it as below. > > extern int foo(int arg1, char arg2); >

[algogeeks] second smallest in array

2012-10-24 Thread rahul sharma
for this shall we process all items and parallely calculate first and second max. or tournament methos i best for thsi.. if tournament method is best can anybody provide me with code with tournament method to find second smallest.. -- You received this message because you are subscribed to th

[algogeeks] C o/p adobe

2012-10-24 Thread rahul sharma
Pleaase reply with sol as asp Fille 1: #include extern int i; extern int j; void next(void); int main() { ++i; printf("%d",i); next(); getchar(); } int i=3; void next() { ++i; printf("%d",i); printf("%d",j); other(); } File 2: extern int i; void other() { ++i; printf

  1   2   3   4   >