question archive DNA strands are made up of smaller units called nucleotides

DNA strands are made up of smaller units called nucleotides

Subject:Computer SciencePrice: Bought3

DNA strands are made up of smaller units called nucleotides. There are four different nucleotides present in DNA, which are represented by the letters A, C, G, and T. Any DNA strand, therefore, can be thought of as linked structure consisting of the nucleotides that make up that strand, in order. In software, we might represent a nucleotide as a doubly-linked list made of individual units that look like this:

struct Nucleotide {

  char value; // 'A', 'C', 'G', or 'T' 

  Nucleotide* next;

  Nucleotide* prev;

};

 

For example, the DNA sequence TAGCAT would be represented as follows:

 

Although they aren't pictured here, the prev pointer of the first T and the next pointer of the last T would each be set to nullptr. For visual simplicity, we're going to leave those pointers out of future pictures as well, but it doesn't hurt to draw them in! There are four milestones in this part of the assignment, and they're spelled out over the next pages.

What we will do: We will together complete a function

void deleteNucleotides(Nucleotide* dna);

 

that takes as input a pointer to a DNA strand, then deletes all the memory used by the nucleotides in that strand. It's possible that the input pointer is nullptr if the DNA strand is empty, in which case this function should do nothing. Next, we will be doing this function:

string fromDNA(Nucleotide* dna);

 

This function takes as input a sequence of nucleotides, then returns a string representation of the DNA strand. For example, calling fromDNA on the dna pointer shown below would return "GTTCAGT":

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE