Data Models A major retail company has hired your team as database specialists to determine the data model — relational, object-oriented, or multidimensional — best suited for its applications. The….
Implement a find and replacement algorithm for sequence of characters found within a linked data structure; replace the last occurrence of the sequence with that owned by another linked data structure.
The bulk of this assignment is for you to implement theDNAstrandtype that maintains a singly linked list of nucleotides. EachDNAstrandobject will represent a single strand of DNA, rather than the double-helix/double-strand found in nature. The primary behavior of aDNAstrandobject will be to cleave and join a newDNAstrandinto the existing strand. These processes simulate the creation of recombinant DNA, where a restriction enzyme cuts a strand of DNA matching a specific pattern and new DNA is spliced-in place.
You will define aSpliceInbehavior for yourDNAstrandtype that will recognize thelast occurrenceof a particular pattern of DNA in a given sequence, “cleave” those nodes from the sequence, and add the nodes taken from another DNAstrand object in-place of the cleaved nodes. The last step of the process can be thought of as an ownership transfer (i.e., move) of the dynamically allocated nodes “owned” by oneDNAstrandobject into the singly linked list of the otherDNAstrandobject.
Learning objectives and outcomes
- Implement a type that uses dynamic memory and avoids memory leaks
- Understand the process of allocating and deallocating dynamic memory through the RAII approach
- Understand how dynamically allocated objects can be strung together into a linked list, and
- Implement a find and replacement algorithm for sequence of characters found within a linked data structure; replace the last occurrence of the sequence with that owned by another linked data structure.