Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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

Java, Programming

  • Category:- Java
  • Reference No.:- M91979357

Have any Question?


Related Questions in Java

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As