1. Homepage
  2. Programming
  3. CSC3002: Introduction To Computer Science - Assignment 1: Permutations, DNA Match, Remove Comments and Banish Letter

CSC3002: Introduction To Computer Science - Assignment 1: Permutations, DNA Match, Remove Comments and Banish Letter

Engage in a Conversation
Hong KongCUHKChinese University of Hong KongCSC3002Introduction To Computer SciencePermutationsDNA MatchRemove CommentsBanish LetterC++

CSC3002 Assignment 1 CourseNana.COM


CourseNana.COM

CourseNana.COM

Problem 1 CourseNana.COM

Exercise 2.9 and 2.10:  CourseNana.COM

CourseNana.COM

The combinations function C(n,k) described in this chapter determines the number of ways you can choose k values from a set of n elements, ignoring the order of the elements. If the order of the value matters-so that, in the case of the coin example, choosing a quarter first and then a dime is seen as distinct from choosing a dime and then a quarter-you need to use a different function, which computes the number of permutations. This function is denoted as P(n,k), and has the following mathematical formulation: CourseNana.COM

P(n,k) = n! (nk)! CourseNana.COM

Although this definition is mathematically correct, it is not well suited to implementation in practice because the factorials involved can get much too large to store in an integer variable, even when the answer is small. For example, if you tried to use this formula to calculate the number of ways to select two cards from a standard 52 -card deck, you would end up trying to evaluate the following fraction: CourseNana.COM

80, 658, 175, 170, 943, 878, 571, 660, 636, 856, 403, 766, 975, 289, 505, 440, 883, 277, 824, 000, 000, 000, 000 30, 414, 093, 201, 713, 378, 043, 612, 608, 166, 064, 768, 844, 377, 641, 568, 960, 512, 000, 000, 000, 000 CourseNana.COM

even though the answer is the much more manageable 2652(52 × 51).
The
C(n,k) function from the text and the P(n,k) function come up often in computational CourseNana.COM

mathematics, particularly in an area called combinatorics, which is concerned with counting the ways objects can be combined. CourseNana.COM

Write a function permutations (n, k) that computes the P (n, k) function without calling the fact function in the file combinatorics.cpp. When you write the implementation, make sure to rewrite the code for the combinations function so that it uses the efficiency enhancements suggested for permutations. CourseNana.COM

Requirements: Please finish the file combinatorics.cpp. DO NOT modify the main() part, which is for the test unit. CourseNana.COM

Problem 2 CourseNana.COM

Exercise 3.20: CourseNana.COM

There is no gene for the human spirit. - Tagline for the 1997 film GATTACA CourseNana.COM

The genetic code for all living organisms is carried in its DNA-a molecule with the remarkable capacity to replicate its own structure. The DNA molecule itself consists of a long strand of chemical bases wound together with a similar strand in a double helix. DNA’s ability to replicate comes from the fact that its four constituent bases-adenosine, cytosine, guanine, and thymine-combine with each other only in the following ways: CourseNana.COM

Cytosine on one strand links only with guanine on the other, and vice versa CourseNana.COM

Adenosine links only with thymine, and vice versa. CourseNana.COM

Biologists abbreviate the names of the bases by writing only the initial letter: A, C, G, or T. Inside the cell, a DNA strand acts as a template to which other DNA strands can attach themselves. As an example, suppose that you have the following DNA strand, in which the position CourseNana.COM

of each base has been numbered as it would be in a C + + string: CourseNana.COM

Your mission in this exercise is to determine where a shorter DNA strand can attach itself to the longer one. If, for example, you were trying to find a match for the strand CourseNana.COM

the rules for DNA dictate that this strand can bind to the longer one only at position 1: CourseNana.COM

By contrast, the strand CourseNana.COM

matches at either position 2 or position 7. Write a function CourseNana.COM

page2image2223488page2image2212256page2image2220160page2image2214544 CourseNana.COM

int findDNAMatch (string s1, string s2, int start = 0 ) ; CourseNana.COM

that returns the first position at which the DNA strand s1 can attach to the strand s2. As in the find method for the string class, the optional start parameter indicates the index position at which the search should start. If there is no match, findDNAMatch should return -1. CourseNana.COM

Requirements: CourseNana.COM

Please finish the file FindDNAMatch.cpp. DO NOT modify the main() part, which is for the test unit. CourseNana.COM

Problem 3 CourseNana.COM

Exercise 4.8: CourseNana.COM

Even though comments are essential for human readers, the compiler simply ignores them. If you are writing a compiler, you therefore need to be able to recognize and eliminate comments that occur in a source file. CourseNana.COM

Write a function CourseNana.COM

void removeComments (istream & is, ostream & os) CourseNana.COM

that copies characters from the input stream is to the output stream os, except for charac- ters that appear inside C + + comments. Your implementation should recognize both comment conventions: CourseNana.COM

Any text beginning with /and ending with /, possibly many lines later. CourseNana.COM

Any text beginning with // and extending through the end of the line. CourseNana.COM

The real C + + compiler needs to check to make sure that these characters are not contained inside quoted strings, but you should feel free to ignore that detail. The problem is tricky enough as it stands. CourseNana.COM

Requirements: CourseNana.COM

Please finish the file RemoveComments.cpp. DO NOT modify the main() part, which is for the test unit. CourseNana.COM

Problem 4 CourseNana.COM

Exercise 4.9: CourseNana.COM

Books were bks and Robin Hood was Rbinhd. Little Goody Two Shoes lost her Os and so did Goldilocks, and the former became a whisper, and the latter sounded like a key jiggled in a lck. It was impossible to read ”cockadoodledoo” aloud, and parents gave up reading to their children, and some gave up reading altogether.... - James Thurber, The Wonderful O, 1957 CourseNana.COM

In James Thurber’s children’s story The Wonderful O, the island of Ooroo is invaded by pirates who set out to banish the letter O from the alphabet. Such censorship would be much easier with modern technology. Write a program that asks the user for an input file, an output file, and a string of letters to be eliminated. The program should then copy the input file to the output file, deleting any of the letters that appear in the string of censored letters, no matter whether they appear in uppercase or lowercase form. CourseNana.COM

As an example, suppose that you have a file containing the first few lines of Thurber’s novel, as follows: CourseNana.COM

If you run your program with the input CourseNana.COM

it should write the following file: CourseNana.COM

If you try to get greedy and banish all the vowels by entering aeiou in response to the prompt, the contents of the output file would be CourseNana.COM

Requirements: CourseNana.COM

Please finish the file BanishLetters.cpp. The test file TheWonderfulO.txt has been provided for your testing(or you can use others files for testing as well). DO NOT modify the main() part, which CourseNana.COM


CourseNana.COM

is for the test unit. CourseNana.COM

  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Hong Kong代写,CUHK代写,Chinese University of Hong Kong代写,CSC3002代写,Introduction To Computer Science代写,Permutations代写,DNA Match代写,Remove Comments代写,Banish Letter代写,C++代写,Hong Kong代编,CUHK代编,Chinese University of Hong Kong代编,CSC3002代编,Introduction To Computer Science代编,Permutations代编,DNA Match代编,Remove Comments代编,Banish Letter代编,C++代编,Hong Kong代考,CUHK代考,Chinese University of Hong Kong代考,CSC3002代考,Introduction To Computer Science代考,Permutations代考,DNA Match代考,Remove Comments代考,Banish Letter代考,C++代考,Hong Konghelp,CUHKhelp,Chinese University of Hong Konghelp,CSC3002help,Introduction To Computer Sciencehelp,Permutationshelp,DNA Matchhelp,Remove Commentshelp,Banish Letterhelp,C++help,Hong Kong作业代写,CUHK作业代写,Chinese University of Hong Kong作业代写,CSC3002作业代写,Introduction To Computer Science作业代写,Permutations作业代写,DNA Match作业代写,Remove Comments作业代写,Banish Letter作业代写,C++作业代写,Hong Kong编程代写,CUHK编程代写,Chinese University of Hong Kong编程代写,CSC3002编程代写,Introduction To Computer Science编程代写,Permutations编程代写,DNA Match编程代写,Remove Comments编程代写,Banish Letter编程代写,C++编程代写,Hong Kongprogramming help,CUHKprogramming help,Chinese University of Hong Kongprogramming help,CSC3002programming help,Introduction To Computer Scienceprogramming help,Permutationsprogramming help,DNA Matchprogramming help,Remove Commentsprogramming help,Banish Letterprogramming help,C++programming help,Hong Kongassignment help,CUHKassignment help,Chinese University of Hong Kongassignment help,CSC3002assignment help,Introduction To Computer Scienceassignment help,Permutationsassignment help,DNA Matchassignment help,Remove Commentsassignment help,Banish Letterassignment help,C++assignment help,Hong Kongsolution,CUHKsolution,Chinese University of Hong Kongsolution,CSC3002solution,Introduction To Computer Sciencesolution,Permutationssolution,DNA Matchsolution,Remove Commentssolution,Banish Lettersolution,C++solution,