Visual C++ :: Search Technique On DNA Sequence

May 10, 2013

Given a set of DNA string. Find minimum length string S so that, given DNA strings are subsequence of S.

For example, if given set of string is: {CAGT, ATGC, CGTT, ACGT, AATT} then answer is: 8. Because, ACAGTGCT contains all given DNA as subsequence.

Given n such DNA string (n <= 8), each of length atmost 5. Find out the least length.

Sample:
5
AATT
CGTT
CAGT
ACGT
ATGC

Output:
8

View 2 Replies


ADVERTISEMENT

C++ :: Binary Search Algorithm - Find Sum Of Used Number In Sequence

Mar 27, 2014

I have to made a programme which will search for given number and it must work in O(log(n)). The problem is that this programme beside finding this number have to find how many times this given number is used in this sequence.

Sequence is from lowest to highest only one possibility to use binary search algorithm

For example when we have squence
-1 -2 3 3 3 3 4 5 6 7 7 8 9 9 9 9 10

The numbers we need to search are
1 , 3 , 7 , 9 , 11 , 12

The answer is
0 , 4 , 2 , 4 , 0 , 0

So we need to find the sum of used number in sequence.

I have written algorithm Code: int start = 0;
int end = sequencelenght - 1;
int mid = 0;
/// Binary serach
while (start<=end) {
int mid=(start+end)/2;
if (sequence[mid]==givennumber) {

[Code] .....

As u see i search for given numer with binary with O(log(n)) but when i have to sum the duplicates the only good way i see is using loop to right and left but this have got log(n) specification (because when sequence would be for example 7 7 7 7 7 7 7 7 7 and given number to search will be 7 this will be O(n) loop).

How would look the most optimal algorithm look for this exercise? I mean O(log(n)) the fastest algorithm....

View 6 Replies View Related

Visual C++ :: Print Sequence Data Structure

Sep 15, 2012

Printing out a sequence data structure. I am using a PC running Windows 7 with Microsoft Visual Studio 2008. This sequence has a dynamic array which stores a value_type which can be any of the built in data types for C++. Initially the sequence is 30 slots long. When the program starts the user starts at the beginning of the sequence by choosing the "!" option from the menu. The user will then insert a number such as 11 by selecting the "I" option (upper or lower case). Then the user will go to the next position in the sequence by selecting the "+" option then insert 22, then go to the next position and insert 33.

To show that the numbers are actually in the sequence the user goes back to the beginning of the array by selecting "!" and then select "C" to display the current number of 11. Then the user goes to the next position by selecting "+" and then "C" to display 22 and so forth. At this point the member function called current() works just find , but when trying to print the contents of the entire sequence the program displays garbage. Why?

Code:
// FILE: sequence_test.cpp
// An interactive test program for the new sequence class
#include <cctype> // Provides toupper
#include <iostream> // Provides cout and cin
#include <cstdlib> // Provides EXIT_SUCCESS
#include "sequence2.h" // With value_type defined as double
using namespace std;
using namespace CISP430_A2;

[Code].....

View 2 Replies View Related

C/C++ :: How To Pad Characters In RSA Cryptography Technique

Oct 7, 2014

How to pad characters in rsa algortihm.eg 'H' becomes 45 so how to do it so that i can use that in my equation.

View 1 Replies View Related

C :: Bitfield Array - Using Standard Technique Of Creating A Structure Within Union

Mar 27, 2013

Any way that one could create a bitfield using the standard technique of creating a structure within a union, as follows:

Code:
typedef union {
struct {
unsigned b0 : 1;
unsigned b1 : 1;
:
:
unsigned b(n-1) : 1;
} bits;
unsigned int value;
}

BIT_FIELD_TYPE; Except, what I'd like to do is to replace all the single-bit elements in the bits structure with a single statement that creates an array of, say, 32 values. The clear advantage of this is that it could be traversed using an iterator, ...

Code:
main() {
BIT_FIELD_TYPE foo;
unsigned int i;
...
for (i = 0; i < n; i++) {
... (print out foo.bits.b[i]) ...
}

So far, I've not figured out a way to do it, either as an array, or using a pointer to iterate through the individual bits.

View 6 Replies View Related

C :: Make A Hash Table Array Of Linked Lists / Separate Chaining Technique

Jul 5, 2013

how to create a hash table array and use linked lists inside the elements.

View 5 Replies View Related

Visual C++ :: Reverse String Sequence In String Buffer

Apr 27, 2013

I made a simple little program that takes text from the clipboard, and spits out all the lines I've copied one at a time (so my program can analyze it).

everything works perfectly, except, it spits it own in the wrong order, I want it to spit out from bottom to top. but currently it spits out the data from top to bottom. here is my code :

Code:
#include <iostream>
#include <Windows.h>
#include <string>
#include <sstream>
using namespace std;
int main() {
HANDLE clip; // assigns the var. clip to hold a handle ID.

[Code] .....

I want this loop to run backwards! Like it say's what I want to work backwards. Where as I know how to flip a while loop like this: while(x < 5), how to flip a loop like the one I'm using. how I can do this?

View 8 Replies View Related

Visual C++ :: How To Search For Object That Has Been Hashed

May 27, 2013

Ran into a logic issue with my hashing program that stores a state object. It's storing the object just fine now but I need to be able to search for it. The user enters a state name and I'm supposed to be able to search for it. I am at a complete loss on how to handle hashing objects.

here is the main

Code:
#include <iostream>
#include <fstream>
#include <string>
#include "hashT.h"

[Code]....

View 2 Replies View Related

Visual C++ :: How To Do Binary Search On A Vector Of Strings

Sep 25, 2012

I'm trying to do a binary search on a vector of strings and keep getting this error. This is the PhoneEntry header file with the class declaration:

Code:
using namespace std;
#include<string>
#include<iostream>
#include<fstream>
#include<vector>
#include"phoneNumber.h"

[Code] .....

View 5 Replies View Related

Visual C++ :: Merge Sort - Binary Search

Feb 25, 2013

I have created a program that first sorts a series of numbers that are input dynamically then an option is given to either use a sequential search or a Binary search. my sequential search works fine but the merge sort coupled with the binary search has a small bug that I just can't seem to figure how to eliminate. I first used my own merge sort but it was really in efficient so a I took a more efficient example and incorporated it in my program but I cant seem to get rid of this bug I'm dealing with. and it seems to be causing a further problem with the Binary seach.

Code:
#include <iostream>
#include <cmath>
using namespace std;
const int N = 10;

[Code] .....

View 3 Replies View Related

Visual C++ :: Linked List Search Function

Feb 9, 2014

The program I have below. If you copy and paste it it should work. However, When I uncomment my search function I get lots of errors and I think it has to do with incorrect syntax of it being a template. Need to do this search function:

Linked.h header file

Code:
#ifndef LINKED_H
#define LINKED_H
#include<iostream>
template <class T>
class Linked {
private:
// Declare a structure for the list

[Code] .....

View 2 Replies View Related

Visual C++ :: Binary Search Tree - Implementing Insert Function

Nov 18, 2013

I am unable to implement the insert function properly,every time i run the program i just get the first value and name,i am not getting other Id's and name.

Code:
"(Header File)"
#include <iostream>
#include <string>
using namespace std;
class node {
public:
int ID;
node (string StudentName, int IDNumber) {

[Code] ....

View 4 Replies View Related

Visual C++ :: Search Function - Ask User To Input Name And Brings Out Line From TXT File Containing Information

Dec 8, 2013

How to get this thing to work. All i need to do is ask user to input a name and then it brings out the line from the .txt file containing the information.

For example in my case I'm doing a member search function I'm required to ask user to input the name of the customer and then print out all the details (which consumes 1 text line in the .txt file)

Here is the code, This is the write to text file method (100% working)

Code:
cout << "Customer Name: ";
cin >> name;
// ...
ofstream myfile("customer.txt", ios::app);

[Code] .....

View 3 Replies View Related

C++ :: Search And Find The Shortest Queue And Search After Some Condition?

Mar 7, 2013

I am trying to implement a Task scheduler where i have n number of tasks. The Idea behind my task scheduler is that in a loop of queues of a vector, task should get enqueued to the shortest queue among the loop of queues, which is done by the following code.

#include <vector>
#include <queue>
std::vector<std::queue<int> > q
int min_index = 0;
task t // implemented in the other part of the program

[Code] ....

Next i am trying to extend this paradigm to reduce the overhead time of the scheduler, Instead of searching the shortest queue every time, search after some condition ie. search the shortest queue after 5 tasks gets enqueued to the shortest queue.

i need to do something like this

#include <vector>
#include <queue>
std::vector<std::queue<int> > q
task t // implemented in the other part of the program
while(q[min_index].size()!=q[min_index].size()+5) // check whether current min_index queue's size is increased 5 more times if not goto enqueue

[code].....

View 1 Replies View Related

C++ :: Binary Search And Sequential Search Algorithm

Sep 16, 2013

Write a program to find the number of comparisons using the binary search and sequential search algorithms

//main.cpp
#include <cstdlib>
#include <iostream>
#include "orderedArrayListType.h"
using namespace std;
int main() {
cout << "." << endl;

[code]....

View 4 Replies View Related

C++ :: Binary Search Or Linear Search For 3D Array

Oct 7, 2014

inputting a search array. I tried putting a binary search but I can't get it to work. everything else works up until I put the value I am searching for in the array, then it just crashes.

How it suppose to work: input 2 coordinates with a value each then it calculates the distance between them then it suppose to let user search the coordinates for a value and state if found which coordinate it is at.

#include "stdafx.h"
#include <iostream>
#include <iomanip> //for setprecision
#include <math.h>

[Code].....

View 3 Replies View Related

C++ :: Getting Incomplete Sequence

Jan 14, 2014

unsigned char x1, x2, x3;
size_t ix = 0;
size_t count;
std::string Input = "EFEF9E9475C8C2D938C204EAE058F2B3";

[code]....

when debug and have a watch on out i get incomplete sequence,

View 8 Replies View Related

C :: Fibonnaci Sequence Function

Mar 6, 2013

Code:

int main()
{
int n;
int* fib;
printf("
Fibonacci test 1: enter an integer
");
scanf("%d",&n);
fib = fibonacci(n);
printf("fib(%d) = ", n);
for(int i = 0; i < n; ++i){
printf("%d ", fib[i]);
}

What should I do/write for the fibonnaci function Code: int fibonnaci(int size)

View 7 Replies View Related

C :: FIbonacci Sequence With Formatting

Sep 2, 2014

I made a fibonacci series with label above it now how to put the label after the first layer because as you can see in the screenshot the label is continuous.

View 2 Replies View Related

C++ :: Indicating A Sequence Of Elements

May 20, 2013

Why is it that in the STL it is standard to indicate a sequence of elements in a container by a begin iterator that points to the first element and an end iterator that points to one past the last element?

View 2 Replies View Related

C++ :: Hailstone Sequence - If Else If Loop

Aug 22, 2013

My assignment is to write a program that reads in a number from the user and then generates the hailstone sequence from that point. I'm not sure if I should use an if statement or string loop. The beginning of an attempt

#include <iostream>
#include <vector>
#include <string>
using namespace std;
vector<string> Numbers;
/// if n is equal to 1 the sequence has ended
/// if n is even divide the number by 2
/// if n is odd, multiply by 3 and add 1 to new number

[Code] ....

View 2 Replies View Related

C++ :: Finding Nth Number Of A Sequence?

Sep 16, 2013

I have to write a program to find the nth number of the Ulam numbers.

It's a bit complicated to explain what an Ulam number is but Wolfram explains it very well here: [URL]

I have to find the nth Ulam number but I don't know what I have to do to get that. My program gives me all the Ulam numbers from a range of 0 to n.

What I want the program to do is tell me that the 49th Ulam number is 243.

/*
C++ Program to find nth Ulam Number
*/
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int num = 0;
vector<int> v;

[code]....

View 4 Replies View Related

C/C++ :: Printing Out Arithmetic Sequence

Oct 6, 2014

I made a program that prints out arithmetic sequence.. but problem is that,

when I enter a(first term) =5, d(differnce)=2.4 and n=3 the program prints out only first two terms not three.. for all the other numbers it works correctly..

View 1 Replies View Related

C++ :: Number Of Sequence In Array?

Apr 24, 2013

I am trying to write a program that checks whether the number is in sequence(as in if the numbers are in order it is a sequence). Ex: If the numbers are {1,2,3,6,7,8,9,10,11,13,15,17,20,21}, then, the underlined parts are a sequence. Now i want to find

1) the no of sequence in the array(in the above it is 3 )
2) the longest sequence (7to 11 which is 5).

View 2 Replies View Related

C/C++ :: How To Do Fibonacci Sequence Program

May 5, 2014

Q) How to do nested loops?
Q) How to do Array?
Q) How to do Fibonacci sequence?

View 1 Replies View Related

C++ :: Sequence Of Fibonacci Number

Feb 16, 2014

The next code is right. I mean it works. It gives the sequence of fibonaci numbers ...

Code:
#include <iostream>
#include <iomanip>
using namespace std;
int fibo(int pos) {

if(!pos)return 0;
if(pos==1)return 1;

[Code] .....

But.... when I change the lines:

Code:
int r1=fibo(pos1);
int r2=fibo(pos2);
int r=r1+r2;

For the lines:

Code:
int r=fibo(pos1)+fibo(pos2);

It doesn't work right. Apparently it should work the same.

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved