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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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