Solved

FInd the repeating words in sequence

Posted on 2002-06-27
7
324 Views
Last Modified: 2010-04-15
I enter the sequence. for eg: ACTGCTACTG .

I need to find out the number of occurence of G and c in this string.

TIA
0
Comment
Question by:kousis
7 Comments
 
LVL 1

Expert Comment

by:dclaydon
ID: 7113219
Two methods

1) The systematic approach - start from one end and check each character one at a time for each character and keep counts of each letter

2) Recursive
utilise the function char* strstr(str1, str2) from stdio.h

returns a pointer to the first occurance of str2 (excluding the null terminator) within str1
0
 
LVL 22

Expert Comment

by:cookre
ID: 7114457
Something like:

int NumG=0;
int NumC=0;
char *p;
char Target[256];

p=Target;
while (p<Target+strlen(Target))
      {
      if (*p=='G') NumG++;
      if (*p=='c') Numc++;
      p++;
      )
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 7115406
Is it always going to be full of characters?
Can there be numbers?
Will you ever do groups of words?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Accepted Solution

by:
harrlow earned 50 total points
ID: 7115624
kousis,
Your example sequence looks like a gene sequence to me.
In that case, it's probably going to very long but would only consists of 4 different letters.

So, i think the system approach proposed by dclaydon is better because the recursive approach will be very resource intensive.
0
 
LVL 10

Expert Comment

by:oleber
ID: 7116333
int CountLetter(char* strSource, char cMatch)
{
   int nCounter=0;
   for (;strSource != '\0';strSource++)
     if (*strSource == cMatch)
        nCounter++;
}
0
 

Author Comment

by:kousis
ID: 7116413
yes. it's DNA sequence
thanx for ur reply
0
 
LVL 1

Expert Comment

by:harrlow
ID: 7121768
Actually, i think the others contributed.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now