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

2012-06-26 Thread rspr
- in general we use polynomial addition for the same. If the numbers are carrying some additional information as ( particular base or pattern) another mechanise can be designed On Tuesday, 26 June 2012 15:40:39 UTC+5:30, ashgoel wrote: > > Best Regards > Ashish Goel > "Think positive and find

Re: [algogeeks] Re: MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-18 Thread Prem Nagarajan
I think there is a problem in this solution. U r accessing stack elements from 1 to n in the outer loop. It is not possible. 1st element cannot be accessed without popping first n-1 elements out. On Mon, Jun 18, 2012 at 11:33 AM, Rituraj wrote: > My iterative approach > > /*code in c*/ > #includ

Re: [algogeeks] Re: MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-18 Thread aditya gupta
this is not a stack at all, u have just named it as a stack. for it to be a stack u should access only the top most element at any point of time!!! On Mon, Jun 18, 2012 at 11:33 AM, Rituraj wrote: > My iterative approach > > /*code in c*/ > #include > int main() > { > int stack[]={1,2,3,4,5,6,

Re: [algogeeks] Re: MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-18 Thread Abhishek Sharma
In a stack, you can't access any element directly, except the top one. On Mon, Jun 18, 2012 at 11:33 AM, Rituraj wrote: > My iterative approach > > /*code in c*/ > #include > int main() > { > int stack[]={1,2,3,4,5,6,7,8},top=7;// > int i,j,temp; > > for(i=1;i<=top;i++) > { > temp=stack[i

[algogeeks] Re: MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-17 Thread Rituraj
My iterative approach /*code in c*/ #include int main() { int stack[]={1,2,3,4,5,6,7,8},top=7;// int i,j,temp; for(i=1;i<=top;i++) { temp=stack[i]; for(j=i;j>0;j--) stack[j]=stack[j-1]; stack[0]=temp; } for(i=0;i<=top;i++) printf("%d ",stack[i] ); return 0; } /* Ritu

Re: [algogeeks] Re: MS Question : find word in 2D array

2012-06-12 Thread hary rathor
1 search should in using KMP algo so that It can be seacrh in O(n) . let function is int KMP(src,trget, searchDirection ) this kmpSearch funtion should be implemented is such a fashion that is search in both direction. 3. assume that give 2d array name is array const int row =1; const int col =1

[algogeeks] Re: MS Question : find word in 2D array

2012-06-11 Thread rammar
A DFS can be used to search the word. Start the search from each element having the starting character of the string. The search will check all the 8- possible directions. However once a path is chosen at the starting character (1 from the 8), the function continues in that single direction dir

Re: [algogeeks] Re: MS Question : find word in 2D array

2012-06-11 Thread Guneesh Paul Singh
@utsav in cases where u have repeating character in ur search string how would u assign the numbers eg in abaac -- 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 fr

[algogeeks] Re: MS Question : find word in 2D array

2012-06-09 Thread Arman Kamal
This can be done with a dfs to mark the path and a backtrack to construct the path or the word itself. -- 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 g

Re: [algogeeks] Re: MS question : string compression

2012-06-08 Thread Ashish Goel
Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Fri, Jun 8, 2012 at 12:54 PM, Ashish Goel wrote: > #include "stdafx.h" > #include > using namespace std; > > const int len = 20; > const int maxCount = 127; > > int rle(char* pStr, int length, cha

Re: [algogeeks] Re: MS question : string compression

2012-06-08 Thread Ashish Goel
#include "stdafx.h" #include using namespace std; const int len = 20; const int maxCount = 127; int rle(char* pStr, int length, char* pNew) { if (!pStr) return -1; if (length <3) return -1; int i = 0; int k = 0; char p1 = pStr[i++]; char p2 = pStr[i++]; char p3 = pStr[i++]; int pos=0; int cC

Re: [algogeeks] Re: MS question : string compression

2012-06-07 Thread Ashish Goel
The idea here is that there will be parts of the stream which actually should not be compressed. For example abcdef as well as aa do not need any compression. We need to compress only if 3 characters match because for compressing two chars we will take up 2 chars so no compression benefit (: So we

Re: [algogeeks] Re: MS question : string compression

2012-06-07 Thread Navin Gupta
If abcdef is changed to a1b1c1d1e1f1, then we need to allocate memory dynamically. Because length is increased,I think this has no practical implementation.As "abcdef " serves the same purpose. On Sunday, 3 June 2012 09:36:25 UTC+5:30, utsav sharma wrote: > > @ashish:-algo given in link wiil fa

Re: [algogeeks] Re: MS question : string compression

2012-06-02 Thread Navin Kumar
Try this code...i think my code can be improved further. #include main() { int flag=0; int i; int c,prev; int chars[26]; for(i=0;i<26;i++) chars[i]=0; while((c=getchar())!=EOF) { if(flag==0) { prev=c; flag=1; } if(c==prev) { if(c>='a' && c<='z') ++chars

Re: [algogeeks] Re: MS question : string compression

2012-06-02 Thread utsav sharma
@ashish:-algo given in link wiil fail for "abcdef" @navin:- output of "abcdef" should be "1a1b1c1d1e1f" On Sun, May 27, 2012 at 3:24 PM, Ashish Goel wrote: > Will fail for the sing having say 257characters all same > > Best Regards > Ashish Goel > "Think positive and find fuel in failure" > +91

Re: [algogeeks] Re: MS question : string compression

2012-05-27 Thread Ashish Goel
Will fail for the sing having say 257characters all same Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sat, May 26, 2012 at 12:26 PM, Navin Gupta wrote: > This is called Run-Length-Encoding (RLE) of a string. > Its purpose is to save space.So

[algogeeks] Re: MS question : string compression

2012-05-26 Thread Navin Gupta
This is called Run-Length-Encoding (RLE) of a string. Its purpose is to save space.So in case of abcdef,I think the output needed is abcdef (1 is implicit). The added benefit is it makes the solution in-place. Approach:- (In-place and Linear Time) Start from the left of string and PREVIOUS_CH

Re: [algogeeks] Re: MS question : string compression

2012-05-26 Thread Ashish Goel
http://michael.dipperstein.com/rle/index.html and basic one is http://www.fileformat.info/mirror/egff/ch09_03.htm Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sat, May 26, 2012 at 1:10 PM, Hassan Monfared wrote: > 1- try "a

Re: [algogeeks] Re: MS question : string compression

2012-05-26 Thread Hassan Monfared
1- try "abb" On Sat, May 26, 2012 at 12:07 PM, Anchal Gupta wrote: > yeah i forgot inplace so to do that we simply add count and ch in str > input array instead of op. > btw whats wrong with count it give me right answer. > > On May 26, 12:08 pm, Hassan Monfared w

[algogeeks] Re: MS question : string compression

2012-05-26 Thread Anchal Gupta
yeah i forgot inplace so to do that we simply add count and ch in str input array instead of op. btw whats wrong with count it give me right answer. On May 26, 12:08 pm, Hassan Monfared wrote: > u forgot to do "inplace" and you have wrong conversion of count > > On Sat, May 26, 2012 at 11:31 AM,

Re: [algogeeks] Re: MS question : string compression

2012-05-26 Thread Hassan Monfared
u forgot to do "inplace" and you have wrong conversion of count On Sat, May 26, 2012 at 11:31 AM, Anchal Gupta wrote: > hey, here is the function that do the compression and store the output > in an array op. > > > void str_comp(char *str) > { > int count=0,j=0,i; > char ch,op[100]; > > for(i=

[algogeeks] Re: MS question : string compression

2012-05-26 Thread Anchal Gupta
hey, here is the function that do the compression and store the output in an array op. void str_comp(char *str) { int count=0,j=0,i; char ch,op[100]; for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.

Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread praveen raj
Steps: 1)Reverse the list ... 2)Now do the swap two nodes... consecutively... PRAVEEN RAJ DELHI COLLEGE OF ENGINEERING -- 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 unsubs

Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread Ashish Goel
oh, a possible mistake from my side, ignore my mail please... Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Tue, Jan 24, 2012 at 3:08 PM, atul anand wrote: > @Ashish : seems exactly similar to Lucifer code or you modified something > in his

Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread DIPANKAR DUTTA
node* prev(node *h) { node *p,*q,*r; p=h; q=p->next->next; p->next->next=NULL; while(q!=NULL) { r=q->next->next; q->next->next=p; p=q; q=r; } return p; } On Tue, Jan 24, 2012 at 3:08 PM, atul anand wrote: > @Ashish : seems exact

Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread atul anand
@Ashish : seems exactly similar to Lucifer code or you modified something in his code ?? ... On Tue, Jan 24, 2012 at 2:02 PM, Ashish Goel wrote: > > > > > struct node > { > int data; > struct node *link; > }; > > node* CreateNode(int val) > { > node* root = (node*)malloc(sizeo

Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread Ashish Goel
struct node { int data; struct node *link; }; node* CreateNode(int val) { node* root = (node*)malloc(sizeof(struct node)); root->data = val; root->link = NULL; return root; } node* createList(int *arr, int n) { node * root = CreateNode(arr[0

[algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-23 Thread Lucifer
@above attaching the file.. -- 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/-/YW_phbT3me4J. To post to this group, send email to algogeeks@googlegroups.com.

[algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-23 Thread Lucifer
I just wrote a code which would work for any given size K. I tested it with K = 1 till 7. [ in the question asked above K=2] Also, tested for corner cases.. If you guys are interested, then have a look at the code.. I have added few helper functions so that you can directly run the code and use i

Re: [algogeeks] Re: MS question

2011-10-03 Thread rahul sharma
got it..thnx yr On Tue, Oct 4, 2011 at 8:34 AM, rahul sharma wrote: > so we shoul d aslo add loop at the top to find only for firrst row and > column the initial values > > > On Tue, Oct 4, 2011 at 8:30 AM, Ashish Goel wrote: > >> 0 in 0th row as well as 0 in 0th col and hence true >> >> >> Best

Re: [algogeeks] Re: MS question

2011-10-03 Thread rahul sharma
so we shoul d aslo add loop at the top to find only for firrst row and column the initial values On Tue, Oct 4, 2011 at 8:30 AM, Ashish Goel wrote: > 0 in 0th row as well as 0 in 0th col and hence true > > > Best Regards > Ashish Goel > "Think positive and find fuel in failure" > +919985813081 >

Re: [algogeeks] Re: MS question

2011-10-03 Thread Ashish Goel
0 in 0th row as well as 0 in 0th col and hence true Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Tue, Oct 4, 2011 at 8:28 AM, rahul sharma wrote: > row0 and col0 initilayy true coz we have 0 in 0 row???or these r default > values? > > > On T

Re: [algogeeks] Re: MS question

2011-10-03 Thread rahul sharma
row0 and col0 initilayy true coz we have 0 in 0 row???or these r default values? On Tue, Oct 4, 2011 at 8:07 AM, Ashish Goel wrote: > 1 1 0 1 > 0 1 1 1 > 1 1 1 1 > 1 1 1 0 > > row0 is true > col0 is true > > for (int i=1; i for (int j=1;j if (a[i][j] == 0) {a[i][0]=0; a[0][j]=0;} > > now after t

Re: [algogeeks] Re: MS question

2011-10-03 Thread Ashish Goel
1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 0 row0 is true col0 is true for (int i=1; iwrote: > @ashish can u give an xample.plz...i have read a lot archives ...but > cant find in 0(1) spaceu using 2 var only...plz give xample...nended > urgent.thnx > > > On Tue, Oct 4, 2011 at 7:26 AM, Ashish Goel w

Re: [algogeeks] Re: MS question

2011-10-03 Thread rahul sharma
@ashish can u give an xample.plz...i have read a lot archives ...but cant find in 0(1) spaceu using 2 var only...plz give xample...nended urgent.thnx On Tue, Oct 4, 2011 at 7:26 AM, Ashish Goel wrote: > keep two var row0 and col0 for checking if there is any 0 in row0flag > /col0flag > >

Re: [algogeeks] Re: MS question

2011-10-03 Thread Ashish Goel
keep two var row0 and col0 for checking if there is any 0 in row0flag /col0flag now walk over elements from 1,1 to n,m and set corresponding entry in 0th row /column if you hit a zero. now walk over zeroth column and rwo and set the complete row/col if a 0 is there in 0th row/col. after this bas

Re: [algogeeks] Re: MS question

2011-10-02 Thread rahul sharma
yeah it is wrong..i have a solution but uses 0(n+m) space.i need it in 0(n*m) tymand o(1) space On Mon, Oct 3, 2011 at 11:55 AM, shady wrote: > search archives :-/ > > > On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal < > pranav.is.cool.agra...@gmail.com> wrote: > >> @rahul sharma, i ran

Re: [algogeeks] Re: MS question

2011-10-02 Thread shady
search archives :-/ On Mon, Oct 3, 2011 at 11:47 AM, pranav agrawal < pranav.is.cool.agra...@gmail.com> wrote: > @rahul sharma, i ran this code, it is producing wrong answer :| > > check it, http://codepad.org/THv1hJq1 > > anyone with correct solution? > > -- > You received this message because

[algogeeks] Re: MS question

2011-10-02 Thread pranav agrawal
@rahul sharma, i ran this code, it is producing wrong answer :| check it, http://codepad.org/THv1hJq1 anyone with correct solution? -- 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.go

Re: [algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-28 Thread anshu mishra
*@all to median of BST time O(n) space O(1) (modified code of nitin to get median) medianBST*(node, n) int x = 0; *while* hasleftchild(node) *do* node = node.left *do* x++; if (x == n/2) return node->val; *if* (hasrightchild(node)) *then* node = node.right *whil

[algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-27 Thread geeks
morris Inorder traversal can do the task i think -- 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/-/TujHItNRKowJ. To post to this group, send email to algogeek

Re: [algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-27 Thread Sanjay Rajpal
Since we are given pointer to root node, we can easily find the minimum element in the tree. This will be the first node in the inorder traversal, now use method to find the inorder successor of a each node. Do it iteratively. Complexity will be O(n log n) and O(n) if tree is skewed. Correct me

Re: [algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-27 Thread Nitin Garg
Do inorder traversal, to find out the total no. of nodes. Next time, do the inorder traversal but keeping the count of nodes visited and stop when you visit n/2 nodes. Non recursive In-order Traversal - *inorder*(node) *while* hasleftchild(node) *do* node = node.left *do* visit(node)

Re: [algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-27 Thread Sanjay Rajpal
Recursion also requires space, so the problem is how to traverse without extra space. Once this is done, nothing is left in the problem. Sanju :) On Tue, Sep 27, 2011 at 8:35 AM, Dheeraj Sharma wrote: > @anshu > can middle element can be found if the no. of nodes are not given... > > > On Tue

Re: [algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-27 Thread Dheeraj Sharma
@anshu can middle element can be found if the no. of nodes are not given... On Tue, Sep 27, 2011 at 8:34 PM, vikas wrote: > a simple one is rabit-tortoise method, and using stackless traversal, > facing a lot of corner cases in coding this, can someone check this as > well? > > On Sep 27, 6:41 p

[algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-27 Thread vikas
a simple one is rabit-tortoise method, and using stackless traversal, facing a lot of corner cases in coding this, can someone check this as well? On Sep 27, 6:41 pm, anshu mishra wrote: > its not o(n) it is O(max height of tree) :P > i have not seen the constraint. -- You received this message

Re: [algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-27 Thread anshu mishra
its not o(n) it is O(max height of tree) :P i have not seen the constraint. -- 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 algoge

[algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-27 Thread Gene
This requires O(n) extra space. On Sep 27, 7:43 am, anshu mishra wrote: > int bstMedian(node *root, int n, int &x) > { >     if (node->left) return bstMedian(root->left, n, x); >     x++; >     if (x == n/2) return node->val; >     if (node->right) return bstMedian(root->right, n, x);} > > call b

[algogeeks] Re: MS Question -> Median of a BST without using extra space and in O(n)

2011-09-27 Thread Gene
And you have to use the pointer-reversing trick to traverse the tree because you don't have space for a stack. On Sep 27, 4:52 am, anshu mishra wrote: > do the inorder traversal as soon as reached at n/2th element that will be > median. -- You received this message because you are subscribed to

Re: [algogeeks] Re: MS question

2011-09-26 Thread Yogesh Yadav
Suppose matrix is 1 0 0 1 1 0 1 0 0 0 0 0 then we traverse the matrix for each 1 we found at a[i][j] , we will check for i=i to i wrote: > If you're given that it's a sparse matrix, then you must assume > storage is in a sparse matrix data structure to get time less than > O(mn). > > In fact, if

[algogeeks] Re: MS question

2011-09-26 Thread Gene
If you're given that it's a sparse matrix, then you must assume storage is in a sparse matrix data structure to get time less than O(mn). In fact, if you assume the right data structure, then the operation can take O(1) time. For example if you say the structure is an array of sets of indices of

Re: [algogeeks] Re: MS question

2011-09-26 Thread Ankur Garg
Guys an Update , This has been asked in MS by me.. I suggested O(m*n) but they were looking for a solution in nlogn ( n*n Sparse Matrix ) ..Any idea ... This post was discussed earlier but every1 came with O(m*n) solution so instead of cluttering it ..opened a new One ... On Tue, Sep 27, 2011

[algogeeks] Re: MS question

2011-09-26 Thread Gene
I assume we don't want to use extra storage. So one way is this: Go over the matrix and mark the first row with a 1 and the first column with a 1 for each 1 you find. Because row and column 1 are used for temporary storage in this manner, you must first remember whether they contained a 1, then g

Re: [algogeeks] Re: MS Question

2011-08-25 Thread Shrey Choudhary
i made a boo boo -- 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 t

Re: [algogeeks] Re: MS Question

2011-08-25 Thread SANDEEP CHUGH
@shrey but its not given in question that we have to return the position or the occurence in the document.. we hav to only the tell whether the word is in document.. read .design a code which efficiently search the word and find occurrence of it in given document . its nt given that return the

Re: [algogeeks] Re: MS Question

2011-08-25 Thread SANDEEP CHUGH
ohh sry my mistake .. got it On Thu, Aug 25, 2011 at 7:36 PM, Shrey Choudhary wrote: > "design a code which efficiently search > the word and find occurrence of it in given document" > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group

[algogeeks] Re: MS Question

2011-08-25 Thread Shrey Choudhary
"design a code which efficiently search the word and find occurrence of it in given document" -- 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] Re: MS Question

2011-08-25 Thread SANDEEP CHUGH
no .. question says that there is a function that gives the next word in the document.. this means after hashing one word , we hav to go to another word ... for this going to next word in the document , we hav already provided wid a function.. nothing to do wid the occurence On Thu, Aug 25, 201

[algogeeks] Re: MS Question

2011-08-25 Thread Shrey Choudhary
But it says finding the "next word" and also it's position of occurence. If we use frequency..won't position of occurence overlap? Am not sure whether I got the question right or not! -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post t

Re: [algogeeks] Re: MS Question

2011-08-25 Thread SANDEEP CHUGH
for every word in the document , apply hash funtion.. store the string n its frequency too.. if we get the same word , then increment the frequency. after storing. whenver we want to search the word , searching in O(1) time , jst applying hash function again on the word to be searched .. corre

[algogeeks] Re: MS Question

2011-08-25 Thread Shrey Choudhary
how will we exactly implement hashtables in this? What will be appropriate keys? ?? -- 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: MS Question

2011-08-25 Thread nishaanth
ya why not hashing ? On Thu, Aug 25, 2011 at 3:31 PM, SANDEEP CHUGH wrote: > wat abt doing wid hashing? > > > On Thu, Aug 25, 2011 at 3:55 PM, vikas wrote: > >> yep, trie needs to be built >> >> On Aug 24, 10:49 pm, Ankur Garg wrote: >> > It means when u call that func u get the next word in the

Re: [algogeeks] Re: MS Question

2011-08-25 Thread SANDEEP CHUGH
wat abt doing wid hashing? On Thu, Aug 25, 2011 at 3:55 PM, vikas wrote: > yep, trie needs to be built > > On Aug 24, 10:49 pm, Ankur Garg wrote: > > It means when u call that func u get the next word in the document > > > > Regards > > Ankur > > > > > > > > > > > > > > > > On Wed, Aug 24, 2011

[algogeeks] Re: MS Question

2011-08-25 Thread vikas
yep, trie needs to be built On Aug 24, 10:49 pm, Ankur Garg wrote: > It means when u call that func u get the next word in the document > > Regards > Ankur > > > > > > > > On Wed, Aug 24, 2011 at 6:59 PM, vikas wrote: > > what do you mean by "a function for finding the next word is given" ? > >

Re: [algogeeks] Re: MS Question

2011-08-24 Thread Ankur Garg
It means when u call that func u get the next word in the document Regards Ankur On Wed, Aug 24, 2011 at 6:59 PM, vikas wrote: > what do you mean by "a function for finding the next word is given" ? > > On Aug 22, 1:56 am, Ankur Garg wrote: > > Question--> Given a document containing some

[algogeeks] Re: MS Question

2011-08-24 Thread vikas
what do you mean by "a function for finding the next word is given" ? On Aug 22, 1:56 am, Ankur Garg wrote: > Question-->      Given a document containing some words ...and a function > for finding the next word is given .design a code which efficiently   > search > the word  and find occurre

Re: [algogeeks] Re: MS question

2011-08-09 Thread abhijeet srivastva
Below is a solution - #include int main(int argc, char* argv[]){ int i = 0; char *array = argv[1]; char prev = array[0]; while(array[i]){ int count = 0; while(prev == array[i]){ i +=1;

[algogeeks] Re: MS question

2011-08-09 Thread monish001
Given : ddbbccae O/P : 2d4a2b2c1a1e What is happening? What algo? Thanks and regards Monish On Aug 9, 5:59 pm, ankit sambyal wrote: > Given an array of characters, change the array to something as shown in the > following example. > Given : ddbbccae > O/P : 2d4a2b2c1a1e > > Do it in the

Re: [algogeeks] Re: MS question

2011-08-09 Thread Priyanshu
@gopi.. didnt got you... @adi.. ya thats what i am talking about... Regards, Priyanshu Gupta On Tue, Aug 9, 2011 at 11:18 AM, Aditya Virmani wrote: > i guess ur qn was how will u decide which frame shud b ur thumbnail...as > after tht, the frame cud be set as a thumbnail which is pretty much

Re: [algogeeks] Re: MS question

2011-08-09 Thread Aditya Virmani
i guess ur qn was how will u decide which frame shud b ur thumbnail...as after tht, the frame cud be set as a thumbnail which is pretty much an eay task in windows programming.i think most, dun hav much info abt it though, thumbnails shud contain more of data; i mean shudnt be unicolour(blank scree

Re: [algogeeks] Re: MS question

2011-08-09 Thread *$*
I guess , it can be done using indexing , with time stamp as key , and frame pointer as data .. Please correct me if I am wrong. On Tue, Aug 9, 2011 at 11:03 PM, Priyanshu wrote: > Anyone?? > > Regards, > Priyanshu Gupta > > > On Fri, Aug 5, 2011 at 6:09 PM, priyanshu wrote: > >> Give an efficie

[algogeeks] Re: MS question

2011-08-09 Thread Priyanshu
Anyone?? Regards, Priyanshu Gupta On Fri, Aug 5, 2011 at 6:09 PM, priyanshu wrote: > Give an efficient algorithm to determine which part of the video > should be displayed as a thumbnail?? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.

Re: [algogeeks] Re: MS question

2011-07-29 Thread rajeev bharshetty
Test cases for MSN Search Engine 1 : Check for auto completion feature (The auto completion based on the prefix should provide suggestions for the most searched keyword with that prefix) . 2 : The spelling correction feature which shows as to what the user actually meant. This should be highly

Re: [algogeeks] Re: MS question

2011-07-29 Thread vaibhav agarwal
what has palindrome to do with this? On Mon, Jul 18, 2011 at 1:11 AM, swetha rahul wrote: > Thanks everyone!! > > > On Sun, Jul 17, 2011 at 10:56 PM, ankit sambyal wrote: > >> Check for case senstivity also: >> eg: "Madam" and "madam" both are palindromes. >> >> >> Also for clarify with the int

Re: [algogeeks] Re: MS question

2011-07-17 Thread swetha rahul
Thanks everyone!! On Sun, Jul 17, 2011 at 10:56 PM, ankit sambyal wrote: > Check for case senstivity also: > eg: "Madam" and "madam" both are palindromes. > > > Also for clarify with the interviewer whether whitespace and > punctuation can be ignored. > eg: is the following string a palindrome

Re: [algogeeks] Re: MS question

2011-07-17 Thread ankit sambyal
Check for case senstivity also: eg: "Madam" and "madam" both are palindromes. Also for clarify with the interviewer whether whitespace and punctuation can be ignored. eg: is the following string a palindrome or not: "A man, a plan, a canal, Panama" And check for this condition accordingly --

Re: [algogeeks] Re: MS question

2011-07-17 Thread vaibhav agarwal
check for query injection,string like (spaces,nothing) entered. On Sun, Jul 17, 2011 at 9:04 PM, Dumanshu wrote: > Well, for the third case, you can elaborate on the implementation. We > need to compare the first half with the later half. So, in case of > even no. of characters it splits perfect

[algogeeks] Re: MS question

2011-07-17 Thread Dumanshu
Well, for the third case, you can elaborate on the implementation. We need to compare the first half with the later half. So, in case of even no. of characters it splits perfectly and in case of odd number of characters, just ignore the middle character. On Jul 17, 8:28 pm, swetha rahul wrote: >

Re: [algogeeks] Re: MS question

2011-07-17 Thread swetha rahul
is this ans sufficient..? any other possible test cases for palindrome ? On Sun, Jul 17, 2011 at 8:53 PM, Nishant wrote: > 1.If string is NULL then it should return 1 i.e. string is palindrome > 2.If there is only one character in string then it is palindrome > 3.If reverse of given string is sa

[algogeeks] Re: MS question

2011-07-17 Thread Nishant
1.If string is NULL then it should return 1 i.e. string is palindrome 2.If there is only one character in string then it is palindrome 3.If reverse of given string is same as string On Jul 17, 8:18 pm, swetha rahul wrote: > ya got it..thanks... > > how abt test cases for program to check whether

Re: [algogeeks] Re: MS question

2011-06-29 Thread rizwan hudda
Sorry dave, your solution works. Thanks for the answer, What I was assuming to be a Counting sort was a variant of it for integers. On Thu, Jun 30, 2011 at 7:56 AM, Dave wrote: > @Rizwan: I don't see the problem. Initialize an array of counters, one > for each possible last character, to zero. I

[algogeeks] Re: MS question

2011-06-29 Thread Dave
@Rizwan: I don't see the problem. Initialize an array of counters, one for each possible last character, to zero. If there are no restrictions on the last character, use an array of 256 counters. Then, for each string, increment the counter corresponding to the last character of the string by the l

Re: [algogeeks] Re: MS question

2011-06-29 Thread rizwan hudda
@Dave: Think of it again counting sort won't work, If you are just considering the last character as the even though key is just last character, the value is the whole string.. On Tue, Jun 28, 2011 at 1:53 PM, juver++ wrote: > List[letter] - linked list of all words with the last character as l

Re: [algogeeks] Re: MS question

2011-06-28 Thread juver++
List[letter] - linked list of all words with the last character as letter. Then iterate over all letters and concatenate lists. -- 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.co

Re: [algogeeks] Re: MS question

2011-06-28 Thread Kamakshii Aggarwal
@Dave:can u please explain the second method. On Mon, Jun 27, 2011 at 11:24 PM, Dave wrote: > @Nishant: Here are a couple of O(n) alternatives, given that there are > a limited number of "last characters" and no requirement to break ties > in any particular way: > > 1. A counting sort. > > 2. Fo

[algogeeks] Re: MS question

2011-06-27 Thread Dave
@Nishant: Here are a couple of O(n) alternatives, given that there are a limited number of "last characters" and no requirement to break ties in any particular way: 1. A counting sort. 2. Form a linked list of entries corresponding to each last character, and then merge these lists in collating s

[algogeeks] Re: MS question

2011-06-27 Thread Sanket
Do we really need to reverse? Can't we apply any normal sorting algo like merge sort or quick sort and for the comparison part of it, use the last characters of each string only? On Jun 27, 4:21 am, varun pahwa wrote: > reverse all strings and then sort. > > On Mon, Jun 27, 2011 at 2:28 PM, Nisha

[algogeeks] Re: MS Question

2011-06-25 Thread Dan
I don't think you need a temp string (though, this may be a language dependent issue). Just use the string "as given" and keep track of the character positions within the string. The length of the original string is irrelevant as long as your system can handle it. Dan :-) On Jun 23, 2:44 pm,

Re: [algogeeks] Re: MS Question

2011-06-14 Thread sunny agrawal
Nice Confusion... :) Consider the following case A[M] = {1,1,3,12}; B[N] = {1,2,12} here again i think answer should be {1,1,12} , why are u binding one occurrence of 1 in array A with one in B. Question is which elements of first array is present in second array. so for this case A[0], A[1], A[

Re: [algogeeks] Re: MS Question

2011-06-14 Thread Arpit Sood
i meant if N = { 1, 1, 1, 2, 12} and M = { 1, 1, 3, 12} then answer should be = {1, 1, 12} On Mon, Jun 13, 2011 at 8:06 PM, sunny agrawal wrote: > no we can take care of duplicates without any extra memory > modify 2nd step of my previous solution as follows > > if T[a[i]] is set then this eleme

[algogeeks] Re: MS Question

2011-06-14 Thread Dumanshu
@Sunny: what if the number is repeated multiple times? u seem to consider only the duplicates(2 times). On Jun 13, 7:36 pm, sunny agrawal wrote: > no we can take care of duplicates without any extra memory > modify 2nd step of my previous solution as follows > > if T[a[i]] is set then this elemen

Re: [algogeeks] Re: MS Question

2011-06-14 Thread Divye Kapoor
Good one! That halved the memory requirement. :) -- 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/-/N6mbMaJHO64J. To post to this group, send email to algogeek

Re: [algogeeks] Re: MS Question

2011-06-13 Thread sunny agrawal
no we can take care of duplicates without any extra memory modify 2nd step of my previous solution as follows if T[a[i]] is set then this element is there in second array so report this element and Reset T[a[i]]. now no duplicates will be reported. and only 1025 bits will be required. any failure

Re: [algogeeks] Re: MS Question

2011-06-13 Thread Arpit Sood
we can take care of the duplicate entries, but then that would cost more space(int), as of now we are working with bool On Mon, Jun 13, 2011 at 5:51 PM, sunny agrawal wrote: > that will report duplicate entries multiple times :( > > > On Mon, Jun 13, 2011 at 5:38 PM, sunny agrawal wrote: > >> why

Re: [algogeeks] Re: MS Question

2011-06-13 Thread sunny agrawal
that will report duplicate entries multiple times :( On Mon, Jun 13, 2011 at 5:38 PM, sunny agrawal wrote: > why do we need 2 bits at all ?? > i think single bit per table entry will do. > say table is T[1025], and array is A[M] > > > 1. Go through the N sized array and set bit 0 of the hash tabl

Re: [algogeeks] Re: MS Question

2011-06-13 Thread sunny agrawal
why do we need 2 bits at all ?? i think single bit per table entry will do. say table is T[1025], and array is A[M] 1. Go through the N sized array and set bit 0 of the hash table entry to 1 if it is present in the first array. 2. Go through the M sized array and if T[a[i]] is set then this elemen

[algogeeks] Re: MS Question

2011-06-13 Thread Divye Kapoor
Use a hash table of size 1025 with bits per table entry = 2. 1. Go through the N sized array and set bit 0 of the hash table entry to 1 if it is present in the first array. 2. Go through the M sized array and set bit 1 of the hash table entry to 1 if the element belongs to 0 to 1024. 3. Go throug

[algogeeks] Re: MS Question :decrement, subtract and dividewith setZero, setEqual, increaseby1 and loop macro

2010-08-24 Thread Gene
You can really impress 'em by pointing out that this problem is related to some common ways of representing numbers and arithmetic operations in the lambda calculus. On Aug 24, 7:16 pm, Ashish Goel wrote: > inline int decrease (int v) { > int decreasedVal = 0; > int counter = 0; > loop( v) and {