Re: [algogeeks] string question

2012-11-15 Thread shivendra singh
But remember that if you are using CPP then its better to allocate sufficient memory to str1 , since you are copying str into str1. if str is very big string it might give a core dump since the possiblity of illegal memory access arises. On Thu, Nov 15, 2012 at 3:33 PM, shivendra singh

Re: [algogeeks] string matching problem

2012-09-03 Thread atul anand
above link was for reference , extending the logic was obvious :) :) On Mon, Sep 3, 2012 at 11:22 AM, bharat b bagana.bharatku...@gmail.comwrote: @atul: question is to find the largest continuous sub array .. not just continuous sub array .. we can do this with same logic as mentioned in the

Re: [algogeeks] string matching problem

2012-09-03 Thread bharat b
why can't we change the question to sum=0 .. On Mon, Sep 3, 2012 at 12:57 PM, atul anand atul.87fri...@gmail.com wrote: above link was for reference , extending the logic was obvious :) :) On Mon, Sep 3, 2012 at 11:22 AM, bharat b bagana.bharatku...@gmail.comwrote: @atul: question is to

Re: [algogeeks] string matching problem

2012-09-02 Thread atul anand
http://www.geeksforgeeks.org/archives/19267 On Mon, Sep 3, 2012 at 7:41 AM, Amitesh Singh singh.amit...@gmail.comwrote: Given a array, find the largest contiguous sub-array having its sum equal to N. -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] string matching problem

2012-09-02 Thread bharat b
@atul: question is to find the largest continuous sub array .. not just continuous sub array .. we can do this with same logic as mentioned in the above link.. we have to traverse whole array.. even if we get the solution .. whenever we get the solution,update the largest_subarray_start_index and

Re: [algogeeks] String comparison

2012-04-18 Thread Shiva Kumar
Hi Abhishek, You can use following string comparison function strcmplogicalw you can refer http://msdn.microsoft.com/en-us/library/windows/desktop/bb759947%28v=vs.85%29.aspx Regards, Shivakumar On Wed, Apr 18, 2012 at 9:16 AM, abhishek zeal.gosw...@gmail.com wrote: Hi, I need to

[algogeeks] string comparsion

2012-04-17 Thread Abhishek Goswami
Hi, I need to compare string into following way. Can anyone provide me some insight or algorithm in c++. For example: a5 a11- because 5 is less than 11 6xxx 007asdf- because 6 7 00042Q 42s - because Q s alphabetically 6 8 006 9 - because 8 9

[algogeeks] String comparison

2012-04-17 Thread abhishek
Hi, I need to compare string into following way. Can anyone provide me some insight or algorithm in c++. For example: a5 a11- because 5 is less than 11 6xxx 007asdf- because 6 7 00042Q 42s - because Q s alphabetically 6 8 006 9 - because 8 9

[algogeeks] string compress/expand

2011-10-02 Thread rahul sharma
Write a routine that takes input as a string such as aabbccdef and o/p a2b2c2def or a4bd2g4 for bdd if i want to make a general program for this..cani do by checking the 2nd array item if it is a number then i will call a fxn expandelse i will call

[algogeeks] string permutation

2011-10-01 Thread rahul sharma
guys plz xplain logic behind the string permutation.n if we have duplicates that should program display the duplicates or notnyone plz tell the logic/code for this. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

[algogeeks] string cutting in c

2011-10-01 Thread Srividhya
hi frnds..can any of you pls tell how to cut strings in optimal time..in dynamic programming.. thanx:) -- 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

Re: [algogeeks] string cutting in c

2011-10-01 Thread shady
problem description ? any link to the problem ? On Sat, Oct 1, 2011 at 7:55 PM, Srividhya srisam261...@gmail.com wrote: hi frnds..can any of you pls tell how to cut strings in optimal time..in dynamic programming.. thanx:) -- You received this message because you are subscribed to the

Re: [algogeeks] string permutation

2011-10-01 Thread Prakash D
if the string is like abcdef then they will be numbered like 012345 and now we represent them in base 5 numbering and also in sorted order the next permutation is 012354 012435 012453 012534 012543 013245 and so on.. On Sat, Oct 1, 2011 at 4:11 PM, rahul sharma rahul23111...@gmail.comwrote:

Re: [algogeeks] string permutation

2011-10-01 Thread rahul sharma
i have searched the archives.any give me algorithm with example...it would be great help..thnx in advance On Sun, Oct 2, 2011 at 2:57 AM, Prakash D cegprak...@gmail.com wrote: if the string is like abcdef then they will be numbered like 012345 and now we represent them in base 5 numbering

Re: [algogeeks] string permutation

2011-10-01 Thread Thayumanavar S
i have searched the archives.any give me algorithm with example...it would be great help..thnx in advance #include iostream #include string #include stdio.h using namespace std; void permute(string inp, string oth) { if ( inp == ) { coutothendl;

Re: [algogeeks] STRING help

2011-09-30 Thread rahul vatsa
c style string is just the char array which is null terminated. On Fri, Sep 30, 2011 at 1:27 AM, rahul sharma rahul23111...@gmail.comwrote: what is c style string??n wats diff b/w c and c++ strings representtaion.. -- You received this message because you are subscribed to the

[algogeeks] STRING help

2011-09-29 Thread rahul sharma
what is c style string??n wats diff b/w c and c++ strings representtaion.. -- 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] string problem

2011-09-20 Thread Prakash D
no.. each ans[s] is stored before returning.. so there is no recalculation of any substring On Sun, Sep 18, 2011 at 4:12 AM, Marcelo Amorim Menegali mmeneg...@gmail.com wrote: *ans[s]=find(s+1,len-1);* if(s[0]'3's[1]'7') *ans[s] = ans[s]+find(s+2,len-2);* -- You

[algogeeks] string problem

2011-09-17 Thread cegprakash
i'm trying out this problem www.spoj.pl/problems/ACODE i'm getting TLE.. I donno y my recursion leads to tle #includeiostream #includemap #includestdio.h #includestring.h using namespace std; mapstring, long long ans; mapstring, bool flags; long long find(char *s, int len){ if(flags[s])

Re: [algogeeks] string problem

2011-09-17 Thread Marcelo Amorim Menegali
I think you're getting TLE because your solution calculate the same stuff over and over again. Look at this part: else{ *ans[s]=find(s+1,len-1);* if(s[0]'3's[1]'7') *ans[s] = ans[s]+find(s+2,len-2);* } Calculating find(s+1,len-1) imply that

Re: [algogeeks] String

2011-09-13 Thread Anshul Khandelwal
U can take command line argument in main main(int argc,char * argv[ ]) { for(i=argc-1,i=0;i--) printf(%s ,argv[i]); } On Tue, Sep 13, 2011 at 12:05 AM, hary rathor harry.rat...@gmail.comwrote: kapil : in your solution you are required extra O(n+n*sizeOf(int *)) both memory to create a link

Re: [algogeeks] String

2011-09-13 Thread shady
search archives, already done On Tue, Sep 13, 2011 at 1:39 PM, Anshul Khandelwal anshul.dans1...@gmail.com wrote: U can take command line argument in main main(int argc,char * argv[ ]) { for(i=argc-1,i=0;i--) printf(%s ,argv[i]); } On Tue, Sep 13, 2011 at 12:05 AM, hary rathor

Re: [algogeeks] String

2011-09-13 Thread guna sekaran
please write a code any one On Tue, Sep 13, 2011 at 2:06 PM, shady sinv...@gmail.com wrote: search archives, already done On Tue, Sep 13, 2011 at 1:39 PM, Anshul Khandelwal anshul.dans1...@gmail.com wrote: U can take command line argument in main main(int argc,char * argv[ ]) {

Re: [algogeeks] String

2011-09-13 Thread kARTHIK R
Something like this. stackchar * S; void function(char *s) { char *ptr=s; while(*ptr++ !=' ') {} *ptr = '\0'; S.push(s); // Will push the string till NULL into the stack function(ptr+1); } // Pop from stack to get words

Re: [algogeeks] String

2011-09-13 Thread sagar sindwani
Awesome solution karthik R On Tue, Sep 13, 2011 at 3:02 PM, kARTHIK R k4rth...@gmail.com wrote: Something like this. stackchar * S; void function(char *s) { char *ptr=s; while(*ptr++ !=' ') {} *ptr = '\0'; S.push(s); // Will push

Re: [algogeeks] String

2011-09-13 Thread shashi kant
hey Karthik phodd diya yaar tune .tejas waale cha gaye On Tue, Sep 13, 2011 at 3:02 PM, kARTHIK R k4rth...@gmail.com wrote: Something like this. stackchar * S; void function(char *s) { char *ptr=s; while(*ptr++ !=' ') {} *ptr = '\0';

Re: [algogeeks] String

2011-09-13 Thread Sanjay Rajpal
#includestdio.h #includestdlib.h #includestring.h void Swap(char *a,char *b) { char c; c=*a; *a=*b; *b=c; } int main() { char input[100]; printf(Enter a string (Length 100) : ); scanf(%[^\n],input); //Reversing the string int len=strlen(input); int i=0,j=len-1; while(i j) {

Re: [algogeeks] String

2011-09-13 Thread Kapil Gupta
+1 Karthik On Tue, Sep 13, 2011 at 3:02 PM, kARTHIK R k4rth...@gmail.com wrote: Something like this. stackchar * S; void function(char *s) { char *ptr=s; while(*ptr++ !=' ') {} *ptr = '\0'; S.push(s); // Will push the string till

Re: [algogeeks] String

2011-09-13 Thread guna sekaran
Thanks to all On Tue, Sep 13, 2011 at 4:35 PM, Kapil Gupta kapilkeda...@gmail.com wrote: +1 Karthik On Tue, Sep 13, 2011 at 3:02 PM, kARTHIK R k4rth...@gmail.com wrote: Something like this. stackchar * S; void function(char *s) {    char *ptr=s;    while(*ptr++ !=' ')

Re: [algogeeks] String

2011-09-13 Thread shady
sorry, but first try doing it yourself. btw, code is also present in archives. On Tue, Sep 13, 2011 at 2:50 PM, guna sekaran vgun...@gmail.com wrote: please write a code any one On Tue, Sep 13, 2011 at 2:06 PM, shady sinv...@gmail.com wrote: search archives, already done On Tue, Sep 13,

[algogeeks] String

2011-09-12 Thread guna sekaran
String Reverse: input : welcome to all output: all to welcome -- 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] String

2011-09-12 Thread abhinav gupta
First reverse the whole string then reverse the individual words .Simple ! On Mon, Sep 12, 2011 at 11:08 AM, guna sekaran vgun...@gmail.com wrote: String Reverse: input : welcome to all output: all to welcome -- You received this message because you are subscribed to the Google

Re: [algogeeks] String

2011-09-12 Thread Kapil Gupta
convert each word to a token in linked list than print the reversal. On Mon, Sep 12, 2011 at 11:54 PM, abhinav gupta guptaabhinav...@gmail.comwrote: First reverse the whole string then reverse the individual words .Simple ! On Mon, Sep 12, 2011 at 11:08 AM, guna sekaran vgun...@gmail.com

Re: [algogeeks] String

2011-09-12 Thread hary rathor
kapil : in your solution you are required extra O(n+n*sizeOf(int *)) both memory to create a link list that really costly -- 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

[algogeeks] String Reverse

2011-08-29 Thread rShetty
Give an algorithm/C Code to reverse a string using a recursive function without swapping or using any extra memory? -- 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

Re: [algogeeks] String Reverse

2011-08-29 Thread saurabh singh
http://www.ideone.com/kSaff On Mon, Aug 29, 2011 at 4:17 PM, rohit agarwal agarwal.rohi...@gmail.comwrote: Print the last character of a string and call the function recursively with remaining string (of length (n-1)) -- * Thanks and Regards* ┌─┐ Rohit

Re: [algogeeks] String Reverse

2011-08-29 Thread Dheeraj Sharma
void rev_str(int i) { if(i==((length/2))) return ; rev_str(i+1); SWAP(str[i],str[length-1-i],t); } passing 0 as parameter... On Mon, Aug 29, 2011 at 5:43 PM, mani walia manis...@gmail.com wrote: aa chak code #includeconio.h #includestdio.h void rev(char*); int

Re: [algogeeks] String Reverse

2011-08-29 Thread Karan Thakral
use xor inplace of a swap...u wont require extra space or memory... printing isnt a solution... On Mon, Aug 29, 2011 at 6:15 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: void rev_str(int i) { if(i==((length/2))) return ; rev_str(i+1);

Re: [algogeeks] String Reverse

2011-08-29 Thread rajeev bharshetty
@Dheeraj : I think the question says no swapping. On Mon, Aug 29, 2011 at 6:56 PM, Karan Thakral karanthak...@gmail.comwrote: use xor inplace of a swap...u wont require extra space or memory... printing isnt a solution... On Mon, Aug 29, 2011 at 6:15 PM, Dheeraj Sharma

Re: [algogeeks] String Reverse

2011-08-29 Thread Ankit Agarwal
void function(int start, int end){ if (start end) return; int x= a[end]-a[start]; a[start] = a[start] + x; a[end] = a[end] - x; function(start+1, end-1); } main(){ scanf(%s, a[0]); int len = strlen(a); function(0,len-1); printf(%s\n, a); } -- Ankit Agarwal

[algogeeks] String passing

2011-08-27 Thread raj kumar
modify(char a[],char *b) { a[0]='a'//gives runtime error why? b[0]='b'//gives runtime error } main() { char p[]=hello; char *x=hello; x[0]='x';//will give run time error i know why p[0]='p' //works fine i know why modify(string,pointer); } why un function modify both the assignments

Re: [algogeeks] string confusion

2011-08-14 Thread sagar pareek
arshad u got my point or not? On Sun, Aug 14, 2011 at 1:16 PM, Arshad Alam alam3...@gmail.com wrote: program is running smooth but I have one confusion at line number 8. why it is *while(s[i]!=0)* instead of *while(s[i]!='\0')* 1.#includestdio.h 2.#includeconio.h 3.void

Re: [algogeeks] string confusion

2011-08-14 Thread Dipankar Patro
@ Gaurav: in ASCII code : '\0' is actually 0, if you are confused with '0' and 0, first one the character and later one is Remember that '0' is not 0 in ASCII, rather value of '0' is 48. So they can be used in place of each other. [ Just expanding what Sagar is trying to say] On 14 August 2011

Re: [algogeeks] String Question

2011-08-14 Thread WgpShashank
@all I Went Through Similar Question Some Times back,i hope piyesh used the same idea, have a look @ Naive efficient Algorithm for doing the same. http://shashank7s.blogspot.com/2011/06/wap-to-output-all-intervals-i-j-where.html * **Regards Shashank Mani Computer Science Is Awesome So Why I

Re: [algogeeks] String Question

2011-08-14 Thread rohit
Nice one.. -- 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/-/ShfCI3o9YY0J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from

[algogeeks] string confusion

2011-08-14 Thread Arshad Alam
program is running smooth but I have one confusion at line number 8. why it is *while(s[i]!=0)* instead of *while(s[i]!='\0')* 1.#includestdio.h 2.#includeconio.h 3.void main() 4.{ 5.clrscr(); 6.char s[]=No two viruses; 7.int i=0; 8.while(s[i]!=0)

[algogeeks] String Question

2011-08-13 Thread vicky S
Given a string which oly has 0's and 1's . Find the maximum largest substring which have equal no of 0's and 1's and give the length of the substring . whether it can be solved in DP ?? or any other soln ? for example : given string : 001101000 output :0101 -- You received this message

[algogeeks] String questions

2011-08-13 Thread vicky S
Given a string which has repeating pattern .Find the repeating pattern and the length of the pattern . Example: 123123123123123 output : 123 lenth is 3 1122222211 output : 112211 lenght is 6 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] String Question

2011-08-13 Thread Raghavan
- Keep an counter for first stuck number(0/1) - increment it, if you stuck on other number, start decrementing it - if the counter becomes zero,note that seq - finally take the longest seq Hope this could solve the problem. On Sat, Aug 13, 2011 at 1:56 PM, vicky S

[algogeeks] String Doubt

2011-08-13 Thread Raman
Which of the following statements are correct about the below declarations? *char *p = Sanjay; char a[] = Sanjay;*1:There is no difference in the declarations and both serve the same purpose.2:*p* is a non-const pointer pointing to a non-const string, whereas *a* is a const pointer pointing to a

Re: [algogeeks] String Doubt

2011-08-13 Thread Rohit Srivastava
2. On Sat, Aug 13, 2011 at 7:24 PM, Raman raman.u...@gmail.com wrote: Which of the following statements are correct about the below declarations? *char *p = Sanjay; char a[] = Sanjay;*1:There is no difference in the declarations and both serve the same purpose.2:*p* is a non-const pointer

Re: [algogeeks] String Doubt

2011-08-13 Thread Rohit Srivastava
also 3,4 On Sat, Aug 13, 2011 at 7:30 PM, Rohit Srivastava access2ro...@gmail.comwrote: 2. On Sat, Aug 13, 2011 at 7:24 PM, Raman raman.u...@gmail.com wrote: Which of the following statements are correct about the below declarations? *char *p = Sanjay; char a[] = Sanjay;* 1: There is no

Re: [algogeeks] String Doubt

2011-08-13 Thread Raman
In statement 2, isn't p pointing to const string, as we cannot modify the characters of the string. -- 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] String Doubt

2011-08-13 Thread rajeev bharshetty
3,4 On Sat, Aug 13, 2011 at 7:39 PM, Raman raman.u...@gmail.com wrote: In statement 2, isn't p pointing to const string, as we cannot modify the characters of the string. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this

Re: [algogeeks] String Question

2011-08-13 Thread aditi garg
@raghavan: can u explain wid an example plz On Sat, Aug 13, 2011 at 4:11 PM, Raghavan its...@gmail.com wrote: - Keep an counter for first stuck number(0/1) - increment it, if you stuck on other number, start decrementing it - if the counter becomes zero,note that seq - finally

Re: [algogeeks] String Doubt

2011-08-13 Thread Rohit Srivastava
my bad only 3,4 On Sat, Aug 13, 2011 at 7:41 PM, rajeev bharshetty rajeevr...@gmail.comwrote: 3,4 On Sat, Aug 13, 2011 at 7:39 PM, Raman raman.u...@gmail.com wrote: In statement 2, isn't p pointing to const string, as we cannot modify the characters of the string. -- You received this

Re: [algogeeks] String Question

2011-08-13 Thread Yasir
Me too didn't get Raghavan's algo... Pls explain.. It seems that above algo will find only longest sequence starting from index 0. Just a thought: Along with raghavan's algo, what if I keep and array_of_integers[string_length] and keep on storing the count in this array. Once string is

Re: [algogeeks] String Question

2011-08-13 Thread Piyush Kapoor
Here is my algo: 1)Replace all '0' with '1' and '1' with '-1'(.i.e, 1 0 1 --- -1 1 -1) 2)Now take an array to calculate the sum of all elements from 1 to that index, which can be calculated as sum[i]=sum[i-1]+ar[i],take 0th element as 0. 3)Now the problem becomes finding two indices (say i,j)

[algogeeks] string confusion

2011-08-13 Thread Arshad Alam
program is running smooth but I have one confusion at line number 8. why it is *while(s[i]!=0)* instead of *while(s[i]!='\0')* 1.#includestdio.h 2.#includeconio.h 3.void main() 4.{ 5.clrscr(); 6.char s[]=No two viruses; 7.int i=0; 8.while(s[i]!=0)

Re: [algogeeks] string confusion

2011-08-13 Thread sagar pareek
ascii value of '\0' is 0 so they can be used in place of each other On Sun, Aug 14, 2011 at 10:24 AM, Arshad Alam alam3...@gmail.com wrote: program is running smooth but I have one confusion at line number 8. why it is *while(s[i]!=0)* instead of *while(s[i]!='\0')* 1.#includestdio.h

Re: [algogeeks] string confusion

2011-08-13 Thread Gaurav Menghani
Well, this can have undefined behavior. Technically you should append - First allocate memory for a string - Then append the terminating char In this case, the memory location after the last character is set to zero, but then you do not have control over it. It may not be zero when you run it the

Re: [algogeeks] string confusion

2011-08-13 Thread sagar pareek
gaurav he is asking why we are using 0 in place of '\0' in line 8 On Sun, Aug 14, 2011 at 10:51 AM, Gaurav Menghani gaurav.mengh...@gmail.com wrote: Well, this can have undefined behavior. Technically you should append - First allocate memory for a string - Then append the terminating char

[algogeeks] string easy question

2011-08-02 Thread Vijay Khandar
#includestdio.h #includeconio.h #includestring.h void main() { clrscr(); char str1[]=Hello; char str2[]=Hello; int i; if(strcmp(str1,str2)) printf (\n Equal); else printf(\n Unequal); getch(); } Plz anyone explain me o/p with explanation. Vijay -- You received this

Re: [algogeeks] string easy question

2011-08-02 Thread prateek gupta
When the strings are equal then strcmp returns zero so your condition will become if (0). In order to correct it use if(strcmp(str1,str2)==0) pritnf(equal); else Unequal. On Tue, Aug 2, 2011 at 7:47 PM, Vijay Khandar vijaykhand...@gmail.comwrote: #includestdio.h #includeconio.h

Re: [algogeeks] string easy question

2011-08-02 Thread Vijay Khandar
Thanks Prateek.. On Tue, Aug 2, 2011 at 7:52 PM, prateek gupta prateek00...@gmail.comwrote: When the strings are equal then strcmp returns zero so your condition will become if (0). In order to correct it use if(strcmp(str1,str2)==0) pritnf(equal); else Unequal. On Tue, Aug 2,

[algogeeks] String vs char array

2011-07-29 Thread Grapher
string str(Hello); int main() { str[3]=0; coutstr; } O/P : Hel o int main() { char arr[] = Hello; arr[3] = 0; coutarr; } O/P: Hel What is the delimiter in string class in c++ then ? Why is it not limiting it to NULL ? -- You received this message because you are

Re: [algogeeks] String vs char array

2011-07-29 Thread sanjay ahuja
string class also stores the length of the string associated with it. When the string is printed, it prints it till the length but char array does not store any length variable. On Sat, Jul 30, 2011 at 10:36 AM, Grapher ggrap...@gmail.com wrote: string str(Hello); int main() {    str[3]=0;  

[algogeeks] String burn,measure time puzle

2011-07-08 Thread oppilas .
You have 2 pieces of string of different, unspecified length, and some matches. Each piece of string takes exactly an hour to burn, but the burn rate is not constant. . The strings have different burn rates, and of course you don't know the rates anyway. Using only the matches and the strings,

Re: [algogeeks] string matching

2011-06-23 Thread aseem garg
Patrick!!! On Thu, Jun 23, 2011 at 11:29 AM, prateek gupta prateek00...@gmail.comwrote: yup, got it thanks!!! On Thu, Jun 23, 2011 at 11:27 AM, sunny agrawal sunny816.i...@gmail.comwrote: last line is *in worst case k=1 only 2*n comparisons will be there hence O(n)* On Thu, Jun 23,

RE: [algogeeks] string matching

2011-06-23 Thread Navneet Gupta
String matching can be performed in linear time with KMP algorithm. could you say what more optimization you are looking for here? Sent from my Windows Phone -- From: prateek gupta Sent: 23/06/2011 11:17 To: algogeeks@googlegroups.com Subject: [algogeeks] string

[algogeeks] string matching

2011-06-22 Thread prateek gupta
In naive string matching how can the knowledge abt. pattern that it has all different characters can be used to accelerate the algorithm to O(n) . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] string matching

2011-06-22 Thread Piyush Sinha
Read KMP algorithm.. On Thu, Jun 23, 2011 at 11:17 AM, prateek gupta prateek00...@gmail.comwrote: In naive string matching how can the knowledge abt. pattern that it has all different characters can be used to accelerate the algorithm to O(n) . -- You received this message because you are

Re: [algogeeks] string matching

2011-06-22 Thread sunny agrawal
last line is *in worst case k=1 only 2*n comparisons will be there hence O(n)* On Thu, Jun 23, 2011 at 11:26 AM, sunny agrawal sunny816.i...@gmail.comwrote: Lets Consider the case of Naive matching in which at some shift s first k characters are matched and next character does not match so

Re: [algogeeks] string matching

2011-06-22 Thread prateek gupta
yup, got it thanks!!! On Thu, Jun 23, 2011 at 11:27 AM, sunny agrawal sunny816.i...@gmail.comwrote: last line is *in worst case k=1 only 2*n comparisons will be there hence O(n)* On Thu, Jun 23, 2011 at 11:26 AM, sunny agrawal sunny816.i...@gmail.comwrote: Lets Consider the case of

Re: [algogeeks] String Swapping Problem

2011-06-17 Thread Apoorve Mohan
@sharma: dis has been explained to tiwari...ask him...:) On Fri, Jun 17, 2011 at 3:12 AM, DIPANKAR DUTTA dutta.dipanka...@gmail.comwrote: instead of calling swap(ps[0],ps[1]) can u try with swap(ps[0],ps[1]) or swap(ps[0][0],ps[1][0]) ? On Fri, Jun 17, 2011 at 5:05 AM, udit sharma

[algogeeks] String Swapping Problem

2011-06-16 Thread udit sharma
#includestdio.hvoid swap(char *,char *);int main(){char *ps[2]={ Hello, Good Mornning, };swap(ps[0],ps[1]);printf(%s \t %s\n,ps[0],ps[1]);return 0;} void swap(char *p,char *q){char *t;t=p;p=q;q=t;} why the output is: HelloGood Mornning --

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread DIPANKAR DUTTA
instead of calling swap(ps[0],ps[1]) can u try with swap(ps[0],ps[1]) or swap(ps[0][0],ps[1][0]) ? On Fri, Jun 17, 2011 at 5:05 AM, udit sharma sharmaudit...@gmail.comwrote: #includestdio.hvoid swap(char *,char *);int main(){char *ps[2]={ Hello, Good Mornning,

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread udit sharma
Ohh Sry... The qus was: #includestdio.hvoid swap(char *,char *);int main(){char *ps[2]={ Hello, Good Mornning, };swap(ps[0],ps[1]);printf(%s \t %s\n,ps[0],ps[1]);return 0;} void swap(char *p,char *q){char *t;t=p;p=q;q=t;} why the output is: Hello

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread Rohit Sindhu
The function swap just swaps it's local copy of pointers which does not mean that it swap array elements. You have to do it explicitly. On Fri, Jun 17, 2011 at 3:17 AM, udit sharma sharmaudit...@gmail.comwrote: Ohh Sry... The qus was: #includestdio.hvoid swap(char *,char *);int

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread Rohit Sindhu
#includestdio.h void swap(char **p,char **q) { char *t; t=*p; *p=*q; *q=t; } int main(){ char *ps[2]={ Hello, Good Morning, }; swap( ps[0] , ps[1]); printf(%s \t %s\n,ps[0],ps[1]); return 0; } This one breaks the ice ... as you have to change the contents of the array

[algogeeks] String of Max Length Which Repeats More Then Onep

2011-02-24 Thread bittu
Given a string (assume there no spaces or punctuations), write a program that returns the max. length of the string that has repeated more than once. Thanks Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] String Operation

2011-02-16 Thread bittu
Given a group of strings, find a string by concatenating all the strings in any order which produces the lexicographically smallest string. For e.g strings are acc bcc abb So the string formed should be abbaccbcc Thanks Shashank -- You received this message because you are subscribed to the

[algogeeks] string

2010-07-18 Thread Ratnesh Thakur
Given a string A, and a string B, and a dictionary, how would you convert A to B in the minimum no of operations, given that: i) All the intermediate words must be from the dictionary ii) An ‘operation’ is defined as: a) Delete any character from a string ex dog → do b) Insert any character

Re: [algogeeks] string

2010-07-18 Thread Ashish Goel
http://en.wikipedia.org/wiki/Levenshtein_distance Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sun, Jul 18, 2010 at 6:08 PM, Ratnesh Thakur ratneshthaku...@gmail.comwrote: Given a string A, and a string B, and a dictionary, how would you

[algogeeks] String Problem

2010-07-11 Thread amit
given a string find the number of distinct substrings of the string. ex: input- output- 4(a, aa, aaa, ) input-abcd output-10(a, b, c, d, ab, bc, cd, abc, bcd, abcd) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] String Problem

2010-06-26 Thread amit
You r given a large string of characters lets call it Sbig. Then there is a small set of characters lets call it Ssmall. You have to find smallest substring of Sbig which contains all characters in Ssmall. For example you are given Sbig = hello what are you doing Ssmall= eo answer is ello 24 --

Re: [algogeeks] String Problem

2010-06-26 Thread Anand
http://codepad.org/NDAeIpxR http://codepad.org/NDAeIpxRHere is code for it On Sat, Jun 26, 2010 at 9:54 PM, Anand anandut2...@gmail.com wrote: you can use Longest common subsequence algorithm to solve it. On Sat, Jun 26, 2010 at 4:04 PM, amit amitjaspal...@gmail.com wrote: You r given a

[algogeeks] String Mathching and RegEx [Good Old Days]

2010-06-06 Thread Veer Sharma
Hi All Here is a problem for us to solve: Write a function which takes as parameters one regular expression(only ? and * are the special characters to consider) and a string and returns whether the string matched the regular expression. -- You received this message because you are subscribed

Re: [algogeeks] String Mathching and RegEx [Good Old Days]

2010-06-06 Thread sharad kumar
lets say u entered a*.nw aab is i/p string then recursivley substitute a and check for it.or use a table for storing the augmented grammer On Sun, Jun 6, 2010 at 6:02 PM, Veer Sharma thisisv...@rediffmail.comwrote: Hi All Here is a problem for us to solve: Write a function which takes

Re: [algogeeks] String Problems

2010-05-20 Thread naga vinod kumar
Use trie data structure ,construct it from given matrix On Thu, May 20, 2010 at 7:23 AM, Mario Ynocente Castro ycma...@gmail.comwrote: I don't think 1014 needs any special algorithm, if we've got an H x W matrix, then we've got (4H+4W-2) strings in which you must look, and you can do this

Re: [algogeeks] String Problems

2010-05-20 Thread vignesh radhakrishnan
@Marcio, I get your algo now. So a substring match is also a match. I get your approach. Thank you. Any ideas for the second problem? On 20 May 2010 10:45, vignesh radhakrishnan rvignesh1...@gmail.com wrote: @Mario Your estimate of no. of strings, I guess doesn't consider strings of length

Re: [algogeeks] String Problems

2010-05-20 Thread gopinath sikha
I think you have to look at this book Algorithms on Strings, Trees and Sequences: Computer Science and Computational Biology By Dan gusfield. It has wonderful data structure which works really fast for string operations. On Wed, May 19, 2010 at 4:16 PM, vignesh radhakrishnan

Re: [algogeeks] String Problems

2010-05-20 Thread vignesh radhakrishnan
@Mario Your estimate of no. of strings, I guess doesn't consider strings of length less than length H or W. it would order(4H^2+4W^2) approximately. I guess I 've understood it right. correct me if I'm wrong On 20 May 2010 07:23, Mario Ynocente Castro ycma...@gmail.com wrote: I don't think

Re: [algogeeks] String Problems

2010-05-20 Thread Mario Ynocente Castro
I was thinking about a substring matching, but if that's not what you need, then you still have the same number of strings, but finding a matching in a string would take quadratic time on the length of the string, instead of linear time. 2010/5/20 vignesh radhakrishnan rvignesh1...@gmail.com

[algogeeks] String Problems

2010-05-19 Thread vignesh radhakrishnan
I'm trying to solve some string problems somewat efficiently. Can someone tell me what would be efficient DS for solving these problems http://acm.jlu.edu.cn/joj/showproblem.php?pid=1014 http://acm.jlu.edu.cn/joj/showproblem.php?pid=1873 Thanks, Regards, Vignesh -- There are two kinds of people.

Re: [algogeeks] String Problems

2010-05-19 Thread Mario Ynocente Castro
I don't think 1014 needs any special algorithm, if we've got an H x W matrix, then we've got (4H+4W-2) strings in which you must look, and you can do this with a greedy strategy. 2010/5/19 vignesh radhakrishnan rvignesh1...@gmail.com I'm trying to solve some string problems somewat efficiently.

Re: [algogeeks] string question

2010-05-16 Thread sharad kumar
suppose if i give Ssmall:es Sbig:he's a algogeek and he's rocking wat will be o/p? On Sun, May 16, 2010 at 8:12 PM, divya sweetdivya@gmail.com wrote: You r given a large string of characters lets call it Sbig. Then there is a small set of characters lets call it Ssmall. You have to find

Re: [algogeeks] string question

2010-05-16 Thread divya jain
output ll be : e's On 16 May 2010 20:17, sharad kumar aryansmit3...@gmail.com wrote: suppose if i give Ssmall:es Sbig:he's a algogeek and he's rocking wat will be o/p? On Sun, May 16, 2010 at 8:12 PM, divya sweetdivya@gmail.com wrote: You r given a large string of characters

Re: [algogeeks] string question

2010-05-16 Thread Navin Naidu
use dp to solve this. On Sun, May 16, 2010 at 8:17 PM, sharad kumar aryansmit3...@gmail.comwrote: suppose if i give Ssmall:es Sbig:he's a algogeek and he's rocking wat will be o/p? On Sun, May 16, 2010 at 8:12 PM, divya sweetdivya@gmail.com wrote: You r given a large string of

Re: [algogeeks] string question

2010-05-16 Thread sharad kumar
@navin naidu like LCS in CLRS??? On Sun, May 16, 2010 at 8:20 PM, divya jain sweetdivya@gmail.comwrote: output ll be : e's On 16 May 2010 20:17, sharad kumar aryansmit3...@gmail.com wrote: suppose if i give Ssmall:es Sbig:he's a algogeek and he's rocking wat will be o/p? On

  1   2   >