We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,605 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

strings

Given two strings u and v and text T,i need help to find whether there is an occurrence of u and v interwoven in T, possibly with spaces. For example, the strings abac and bbc occur interwoven in cabcbabdcca (cabcbabdcca) along with other characters (in black). i tried to implement this but i'm stuck ! i hope someone here can help me

3
Contributors
6
Replies
4 Days
Discussion Span
9 Months Ago
Last Updated
7
Views
shsh111
Newbie Poster
14 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

what computer language -- e.g. c++, c, vb, java, assembly, cobol, fortran, etc. etc.

Ancient Dragon
Achieved Level 70
Team Colleague
32,109 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,575
Skill Endorsements: 68

any language

shsh111
Newbie Poster
14 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

write a function that returns true of false that indicates if one string is contained in another string. For example if "hello" is contained in "hello world". You can call that function as many times as you wish. If you have two strings "hello" and "world" call the function for each word to find out whether or not they are contained in a third string "hello world".

Ancient Dragon
Achieved Level 70
Team Colleague
32,109 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,575
Skill Endorsements: 68

For example, the strings abac and bbc occur interwoven in cabcbabdcca (cabcbabdcca) along with other characters (in black).

The color doesn't show up so I am not sure what you mean by "interwoven"? Please give a better example or try to add ASCII visual instead.

Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17

Tayein -do you undestand in computer biological?

shsh111
Newbie Poster
14 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

No, I don't understand the word "computer biological." But if it is similar to a DNA sequence (as 'abc' is a molecule sequence consists of a, b, and c), then I understand what it is. However, when you use the word "interwoven," and said you have added color to the display, I am not sure how you want the result to be?

By the way, a computer language is trivia in your case but algorithm is. In this case, it is not that easy when there is a possibility of multiple appearances of substring in a string. If a brute force algorithm is suffice, then it would not be too difficult.

//i.e.
//String T = "cabcbabdcca";
//String u = "abac";
//String v = "bbc";
//Result of scanning string u in T   | Result of scanning string v in T
// cabcbabdcca                       |  cabcbabdcca
//  12  3  4                         |    12    3
// cabcbabdcca                       |  cabcbabdcca
//  12  3   4                        |    12     3
// cabcbabdcca                       |  cabcbabdcca
//  1  23  4                         |    1     23
// cabcbabdcca                       |  cabcbabdcca
//  1  23   4                        |      1   23
//                                   |  cabcbabdcca
//                                   |        1 23
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 375
Skill Endorsements: 17

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.5176 seconds using 2.57MB