Compute the character with maximum number of connections

Assignment Help C/C++ Programming
Reference no: EM131103124

Central Character

Purpose: branching and looping

Network theory has a host of applications. One fun application is to find the central character in a novel. Such an analysis was recently performed on the hugely popular book "The Songs of Fire and Ice" by George R.R. Martin which has been made into the the television show "Game of Thrones.. 1" The central character is defined by the one with the most connections to other characters. The authors of the paper considered two characters to be connected if their names appeared within 17 words of each other.

In this problem we will apply a similar procedure to the book "Storybook Treasury of Dick and Jane and Friends" by William S. Gray. This book was among the first books your parents (or grandparents) studied when they were learning to read. This book is very short and has only three main characters : Dick, Jane, and Sally. Due to the simplicity of the book we consider the two characters to be connected if their names appear within 5 words of each other.

See Dick run. Run Dick run. See Jane run. Dick likes to play with Spot. Sally likes Puff. Dick likes Puff.

In the above text :

 Dick has 3 connections : 2 with Jane and 1 with Sally
 Jane has 2 connections: 2 with Dick
 Sally has 1 connection: 1 with Dick

Your task to to read in a set of text and determine which of the 3 main characters is the most connected.

Input: The first line of input will contain an integer t representing the number of test cases to be tested. Each test case will be on 2lines. The first line of the test case will contain a single integer n representing the number of words to be considered. The second line of the test case hold n words each words. Each word separated a single space with no punctuation.

Output: For each test case your program will display which character name {Dick, Jane or Sally }which has the most connections in the text, followed by the number of connections on a single line. If there is a tie, list the character that comes first alphabetically.

Sample Input
1
21
See Dick run Run Dick run See Jane run Dick likes to play with Spot Sally likes Puff Dick likes Puff
Sample Output
Dick 3

Possible Algorithm

(the connection length (number of words between a connection should be a named constant)) You can read each word
If the word is one of the three characters

check the last location of the other two characters and if they are within 5 update the number of connections of that character and the character just read update the last location of the character just read

After all the words are read, compute the character with maximum number of connections print out the result

Reference no: EM131103124

Questions Cloud

Do corporations often sell convertibles on a rights basis : Why do corporations often sell convertibles on a rights basis?
Explain what the following code does : Explain what the following code does?
Negotiate with suppliers to bring his variable costs down : PJ thinks he can sell 130 bikes next year if he lowers the price of each bike to $2000. His fixed costs cannot be brought down, but he thinks he can negotiate with suppliers to bring his variable costs down. In order to break even, what does his n..
Analyze the contents of online shopping carts : One way the author of this textbook recommends to effectively manage credibility concerns with online information is to. Analyzing the contents of online "shopping carts" is an example of which class of Internet-based data sources?
Compute the character with maximum number of connections : Compute the character with maximum number of connections print out the result - Network theory has a host of applications. One fun application is to find the central character in a novel.
Evaluate the statement : Evaluate the following statement: "Issuing convertible securities represents a means by which a firm can sell common stock at a price above the existing market."
Sketch a picture of a residual plot : Sketch a picture of a residual plot that shows non-constant variance and linearity. Sketch a picture of a residual plot that shows constant variance and nonlinearity. Sketch a picture of a residual plot that shows non-constant variance and nonlineari..
What is the justification for the following deviations : What is the justification for the following deviations from recognizing revenue at the time of sale?
How does a firm''s dividend policy affect each : How does a firm's dividend policy affect each of the following? a. The value of its long-term warrants. b. The likelihood that its convertible bonds will be converted. c. The likelihood that its warrants will be exercised.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  What will be the value of xafter executing the above switch

If x = 3, then what will be the value of xafter executing the above switch statement?

  Implement and test the given function

Implement and test the following function: bool is_palindrome(string s); // Returns true iff s is a palindrome // EXAMPLES: is_palindrome("RADAR") returns true, // is_palindrome("ABCD") returns false

  For this program reads the first 11 characters

E main for this program reads the first 11 characters from input, saving them. It then reads 26 short integers into |vals|, and passes them and the characters to EmbedWatermark, which subtly alters the contents of vals to contain the characters. A..

  Calculate the total expences

Trying to fugure out how to enter a formula in a cell(d10) that multiplies 30 by the value in another cell (c27), then make the other cell (c27) an absolute cell reference in the formula. Copy the formula to cells d11:d13, and then calculate the t..

  Change temperature fahrenheit to celsius and kelvin

Write a program in c++ that takes the temperature in Fahrenheit and convert it to Celsius And Kelvin:

  Write test program to call function several times for gcd

Greatest common divisor of two integers is largest integer which will evenly divide both integers. Implement this function in assembly language and write test program which calls function several times, passing it different values.

  From the worker''s gross pay

An employee is paid at a rate of $16.78 per hour for the first 40 hours worked in a week. Any hours over the regular 40 hours are paid at the overtime rate of one-and-one-half times that. From the worker's gross pay

  Rational class performs operations on fractions

Write a C++ program that, using the rational class performs operations on fractions. Test your class thoroughly.

  Write a program that displays the cubes of the numbers

Write a program that displays the cubes of the numbers from 1 to 10. Recall that the cubes of a number is just the number multiplied by itself and then by itself again.

  Write a c program which takes a string from command line

Write a c program which takes a string from command line with mainfunction has no parameter and convert the string in upperca

  Elements that must be included in a loop

What are the three elements that must be included in a loop in order for the loop to successfully perform correctly - What will happen if these statements are not included? Provide examples.

  Write the definitions of the member functions

Write the definitions of the member functions of the class complexType as designed and Rewrite the definition of the class complexType

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd