Write a method called select_set

Assignment Help JAVA Programming
Reference no: EM131223431

Twitter is a popular social media platform for users to send out a short message (a "tweet") to other users who are registered as his/her followers. Figure 1 shows a graph. (The topic on graphs will be covered after your term break, and you are not required to understand graphs for this lab; it's a very useful illustration for this scenario nonetheless).

945_Figure.png

The circles labeled "0", "1", "2" etc. are called nodes (or vertices) of the graph, and the arrows connecting the nodes are called edges. This graph shows a small network of Twitter users with the nodes representing users, and the edges show which user is following which other users: an arrow means "is following" (and not "is followed by"). The graph in figure 1 can hence be interpreted as a network of 11 tweeter users (users 0, 1, 2... 10). Users 0 and 3 are following 1, 1 is following 2, 3 and 4, 2 is following 0 and 3, and so on. By studying this simple graph, it should be obvious that user 3 has the most number of followers (four followers), and is hence the most influential user since a tweet initiated by user 3 will be received by four users.

We would like to start a viral marketing campaign. The approach is to select five Twitter users, and pay them to tweet an advertisement. The problem is to identify which five users to select so that we will reach as many unique followers as possible.

For simplicity, assume that Tweeter user IDs are sequential numbers starting from 0. So if there are 11 users, their user IDs will be 0, 1, 2... 10. The Tweeter graph above can be represented in the form of a table like this:

User ID

Direct Follower User IDs

0

2

1

0, 3

2

0, 1

3

1, 2, 4, 5

4

1, 6, 10

5

 

6

7, 8

7

 

8

 

9

8

10

9

Instead of selecting only five Tweeter users to send the advertisement, management has approved a budget to pay many more Tweeter users to send the advertisement. However this time round, management wants EVERY user to get the message. So, the new goal for you is to select the smallest number of Tweeter users who need to send the advertisement so that everyone will get it.

Requirements:

Write a method called select_set that takes in 1 parameter: followers (a 2D array of Tweeter users) and returns the user IDs of any number of users (as an array of integers) selected by your algorithm who will be selected to broadcast the advertisement. followers.length will give you the total number of Tweeter users in the Tweeter universe.

The objective is to make select_set as small as possible such that every user gets the advertisement.

Your solution will be checked using this method: all_users_got_message?. This method takes in your array of selected tweeters (selected) and the original followers 2D array, and returns true (if every Tweeter user would have gotten the message) or false (if at least one Tweeter user hasn't gotten the message). If all_users_got_message?istrue, your solution's quality will depend on the number of users in your selected set (selected.length).

Attachment:- Project Assignment.rar

Reference no: EM131223431

Questions Cloud

Describe the long run impact on inflation and output : Describe the long-run impact on inflation and output if the central bank implicitly allows its inflation target to rise.
Journalize all entries to income statements-balance sheet : Company Z sells annual subscription to their online magazine. Clients must pay a year subscriptions in advance. Company Z has a policy to prepare reversing entries when possible. It is also their policy to journalize all entries to income statements/..
How the economy could fall into a deflationary spiral : Explain in terms of the aggregate demand-aggregate supply framework how the economy could fall into a deflationary spiral if it were hit by a negative aggregate demand shock.
Person indifferent between these two investments : A person plans to save $1 for 20 years. They can invest at an annual rate of 10% (r=0.1). This investment opportunity "compounds annually" (meaning that they receive interest payments at the end of each year). For what value of  r~ is the person indi..
Write a method called select_set : Write a method called select_set that takes in 1 parameter: followers (a 2D array of Tweeter users) and returns the user IDs of any number of users (as an array of integers) selected by your algorithm who will be selected to broadcast the advertis..
What would be the likely consequences for inflation : If the central bank bases its policy decisions on the consensus forecast, - what would be the likely consequences for inflation assuming it maintains its existing inflation target?
Which is incorporated in the state of alpha : You are the 100% owner of X Corporation, which is incorporated in the state of Alpha and has its principal place of business there. Your company has 5 employees, including you, and does computer consulting services for small businesses. You do all of..
Which page that first appears once you logged into grantham : Start each search from the GLife home page within Grantham's website, which is the page that first appears once you've logged into Grantham, and then tell me exactly which items you clicked on and where they were located until you got to your fina..
Would you anticipate the bank lending channel : In the wake of the financial crisis of 2007-2009, would you anticipate the bank lending channel becoming more or less important in the United States in the near future?

Reviews

Write a Review

 

JAVA Programming Questions & Answers

  Step and size of the screen

How to draw a square spiral with specified initial coordinates, step and size of the screen? Let the spiral start drawing from point with coordinates (startX, startY) in the row: to the right, up, left, down (size of the screen 800x600).

  Java program ask user to enter 10-character telephone number

Write a Java program that asks the user to enter a 10-character telephone number in the format XXX-XXX-XXXX. The program should display the telephone number with any alphabetic characters

  Testing a leap year library

Write a program Checkerboard.java that takes an integer command-line argument N, and uses two nested for loops to print an N-by-N "checkerboard" pattern

  What are some other examples that could use inheritance

One of the topics covered this week is "Inheritance". The chapter shows the Person/Employee example, what are some other examples that could use Inheritance?

  How can i maintain a single instance of an object in applet

How can I maintain a single instance of an object in an applet? What is UDP and how does it work?

  Java file input and outputnbspcreate a file that contains

java file input and outputnbspcreate a file that contains your favorite movie quote. use a text editor such as notepad

  Application that generates a quiz

Create an application that generates a quiz. Prompt for the user's first and last name, college major, and confidence in test taking (high, medium, or low). The quiz should contain at least five true/false questions about horticulture. When the user ..

  Describe how an eavesdropped can gain access

Describe how an eavesdropped can gain access to the remote server with a relatively modest number of guesses ( Hint:  The eavesdropped starts guessing after the original user has typed all but one character of the password.

  Design and code a swing gui to translate test

Use a FLOWLAYOUT with a JTEXTAREA for the source text and separate JTEXTAREA for the translated text. Add a JBUTTON with an event to perform the translation

  Create an interactive java application for insurance agent

Create an interactive Java application for insurance agent in order to generate a quote for a household. According to your design, the program must: Implement all the four Java classes described with the correct inheritance of abstract classes.

  Create a class named box that includes integer data fields

Create a class named Box that includes integer data fields for length, width and height. Create three constructors that require one, two and three arguments, respectively.

  Collection of scores (type int) for the last exam i

After being given a collection of scores (type int) for the last exam in your computer course, you are to computer the average of the scores and assign grades (O, S, U i.e. Outstanding, Satisfactory, Unsatisfactory)) to each student according to the ..

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