Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assume you are in charge of a news website and want to show the k most oft en clicked articles on the landing page,
Assume you are in charge of a news website and want to show the k most oft en clicked articles on the landing page, in descending order of clicks received. You are given an array A of m articles where A[i] includes the heading (string) and the click count (int eger) of article i. 1. What Abstract Data Type would suit this application? Explain your choice! 2. From the discussed datastructures (implementations) for this ADT which is the most efficient implementation given this problem description? 3. Write a met hod that uses this ADT to return the k most clicked entries. Use this template for java 1 class Entry implements Comparable 3 4 5 6 7 8 9 10. 11 12 13 14 15 16 17 18 19 21 22 23 24 25 27 28 29 30 31 } public String heading; public Integer clickCount; public Entry (String heading, Integer clicks) { this.heading heading; this.clickCount = clicks; } public static Entry [] top_entries (Entry[] entries, int k) { // TODO: Use your chosen ADT here to //get the top k entries and return them } public static void main (String[] args) { Entry] entries ( new Entry ("aa3", 3), new Entry("aa10", 10), new Entry ("aal", 1), new Entry("aa100", 100), new Entry("aa4", 4), } new Entry ("aa20", 20), new Entry("aa5", 5), }; for (Entry e: Entry.top_entries (entries, 3)) { System.out.println(String.format ("%s %d", e.heading, e.clickCount)); 4. What are the complexities of the methods that you use in your implementation?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started