Data structures define a specification on the format data can be represented, organized and structured in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Data structures define a specification on the format data can be represented, organized and structured in memory, and on the set of operations we can perform on the data. The choice of data structure often dictates (or affects) the efficiency of those operations. To exemplify this relation between efficiency and the underlying data structures, in the lecture we discussed two different implementations of the search operation: one where the data structures stored the data in an array in a random order and another one where it stores the data sorted. In the first case, we were restricted to using a Linear Search algorithm while in the second case we were able to use a Binary search in improve search performance. To further demonstrate the need for efficient data structures, in this problem set you will implement generic versions of the linear search and binary search algorithms (i.e. that can operate on any type of Object data) and apply them specifically to the Tweet dataset. This problem set build on the classes you completed on problem set 01; refer to problem set one of more information about the specification of dependent classes. Program Specification: • Dataset description: you are provided with a data files, called tweet_data_sorted.csv which includes a list of tweets that are sorted by tweet id. Each line corresponds to a tweet record. Each tweet record has a unique id, a sentiment category (positive or negative), and the text of the tweet. A sample record in the file might look as follows Pos, 1400, My iPhone 4S battery lasted longer than a day. • Update the Tweet class Implementation: you must update the Tweet class you implemented in problem set 1, to override the 'equals` method and the 'compare To` method from the Comparable interface. o The 'equals' methods should take as an input an object to type Tweet and return the value True, if the tweet id of the current instance equals the tweet id of the input Tweet instance, or False otherwise. The 'equals' method must have the following method declaration: O public boolean equals(Object o) {...} Similarly, the 'CompareTo' method should take as an input an object of type Tweet and must return the following: ▪ A negative integer (i.e. -1) if the current object's tweet-id value is less than the tweet-id of the input Tweet instance. ● A positive integer (i.e. 1), if the current object's tweet-id value is less than the tweet-id of the input Tweet instance. The value zero, if the current object's tweet-id value and the tweet-id of the input Tweet instance are equal. The 'compare To' method must have the following method declaration: public int compareTo (Object o) {...} Use the TweetLoader class to load a list of Tweet. Use the TweetLoader class you implement in problem set 01 to load the list of sorted Tweet objects. • Implement an SearchObject class. Implement a class with the name SearchObject that will provide the implementation to the following static methods: o public static Object[] linearSearch(Object[] inputArray, int arraySize, Object searchKey) The method takes as input: an array of type Object, an integer value (array Size) that stores the number of elements currently in the array (i.e. in case of a partially filled array), and a searchKey of type Object. The method need to employ a linear Search algorithm on the input Array to find the index where the object in the array equals the searchKey object. o public static Object[] binarySearch(Object[] inputArray, int array Size, Comparable searchKey) The method takes as input: an array of type Object, an integer value (arraySize) that stores the number of elements currently in the array (i.e. in case of a partially filled array), and a searchKey of type Comparable (Notice this is different from the linearSearch definition). The method needs to employ a Binary Search algorithm on the input Array to find the index where the object in the array equals the searchKey comparable. Implement a Main class: you must create a Main class that demonstrates the functionality of the SearchObject class. Your 'main' method of the Main class should use the 'LoadAsArray' method (implemented in the TweetLoader class) to load the list of tweets stored from 'tweet_data_sorted.csv' in an Array. It should then invoke the linearSearch and binarySearch methods you implemented in the ObjectSearch class to locate tweet in the array. You must provide examples where your method searchers for the following Tweet id values (1000, 1005, 1804, 2499, 2504 and 2800) and display the Tweet results. Your implementation for the above program should comply with the following requirements and specifications: Your program should implement all the specification outlined above. Your code must be well organized, code must be indented. You must use the data file provided as input to your program. Source code files must be submitted (not the compiled files) You must use the template code provided. Your program must compile and run without errors and generate the expected output. Data structures define a specification on the format data can be represented, organized and structured in memory, and on the set of operations we can perform on the data. The choice of data structure often dictates (or affects) the efficiency of those operations. To exemplify this relation between efficiency and the underlying data structures, in the lecture we discussed two different implementations of the search operation: one where the data structures stored the data in an array in a random order and another one where it stores the data sorted. In the first case, we were restricted to using a Linear Search algorithm while in the second case we were able to use a Binary search in improve search performance. To further demonstrate the need for efficient data structures, in this problem set you will implement generic versions of the linear search and binary search algorithms (i.e. that can operate on any type of Object data) and apply them specifically to the Tweet dataset. This problem set build on the classes you completed on problem set 01; refer to problem set one of more information about the specification of dependent classes. Program Specification: • Dataset description: you are provided with a data files, called tweet_data_sorted.csv which includes a list of tweets that are sorted by tweet id. Each line corresponds to a tweet record. Each tweet record has a unique id, a sentiment category (positive or negative), and the text of the tweet. A sample record in the file might look as follows Pos, 1400, My iPhone 4S battery lasted longer than a day. • Update the Tweet class Implementation: you must update the Tweet class you implemented in problem set 1, to override the 'equals` method and the 'compare To` method from the Comparable interface. o The 'equals' methods should take as an input an object to type Tweet and return the value True, if the tweet id of the current instance equals the tweet id of the input Tweet instance, or False otherwise. The 'equals' method must have the following method declaration: O public boolean equals(Object o) {...} Similarly, the 'CompareTo' method should take as an input an object of type Tweet and must return the following: ▪ A negative integer (i.e. -1) if the current object's tweet-id value is less than the tweet-id of the input Tweet instance. ● A positive integer (i.e. 1), if the current object's tweet-id value is less than the tweet-id of the input Tweet instance. The value zero, if the current object's tweet-id value and the tweet-id of the input Tweet instance are equal. The 'compare To' method must have the following method declaration: public int compareTo (Object o) {...} Use the TweetLoader class to load a list of Tweet. Use the TweetLoader class you implement in problem set 01 to load the list of sorted Tweet objects. • Implement an SearchObject class. Implement a class with the name SearchObject that will provide the implementation to the following static methods: o public static Object[] linearSearch(Object[] inputArray, int arraySize, Object searchKey) The method takes as input: an array of type Object, an integer value (array Size) that stores the number of elements currently in the array (i.e. in case of a partially filled array), and a searchKey of type Object. The method need to employ a linear Search algorithm on the input Array to find the index where the object in the array equals the searchKey object. o public static Object[] binarySearch(Object[] inputArray, int array Size, Comparable searchKey) The method takes as input: an array of type Object, an integer value (arraySize) that stores the number of elements currently in the array (i.e. in case of a partially filled array), and a searchKey of type Comparable (Notice this is different from the linearSearch definition). The method needs to employ a Binary Search algorithm on the input Array to find the index where the object in the array equals the searchKey comparable. Implement a Main class: you must create a Main class that demonstrates the functionality of the SearchObject class. Your 'main' method of the Main class should use the 'LoadAsArray' method (implemented in the TweetLoader class) to load the list of tweets stored from 'tweet_data_sorted.csv' in an Array. It should then invoke the linearSearch and binarySearch methods you implemented in the ObjectSearch class to locate tweet in the array. You must provide examples where your method searchers for the following Tweet id values (1000, 1005, 1804, 2499, 2504 and 2800) and display the Tweet results. Your implementation for the above program should comply with the following requirements and specifications: Your program should implement all the specification outlined above. Your code must be well organized, code must be indented. You must use the data file provided as input to your program. Source code files must be submitted (not the compiled files) You must use the template code provided. Your program must compile and run without errors and generate the expected output.
Expert Answer:
Answer rating: 100% (QA)
Based on the provided specifications heres a basic outline of how you can structure your Java progr... View the full answer
Related Book For
Computer Architecture A Quantitative Approach
ISBN: 978-0123704900
4th edition
Authors: John L. Hennessy, David A. Patterson
Posted Date:
Students also viewed these programming questions
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
1. Suppose that a stoichiometric mixture of isooctane (C8H18) and air is burned in an engine and then the fuel is changed to 10% (by liquid volume) ethanol and 90% by liquid volume isooctane. If the...
-
Choose a setting from student life. Try to model it as a game, with a set number of players, payoffs, and actions. Is it like any of the classic games studied in this chapter?
-
What is meant by the term "risk mitigation" in finance? 2. What are some common strategies for mitigating risk in investment portfolios? 3. How can diversification help investors reduce risk? 4. What...
-
The accounting records of Compass Bookstores, Inc., include the following: Requirement Report these liabilities on Compass Bookstores' balance sheet, including headings and totals for current...
-
Jake Tweet hosts a psychology talk show on KRAN radio. Jakes advice averages 10 minutes per caller but varies according to an exponential distribution. The average time between calls is 25 minutes,...
-
1. We will denote the value of S xn-1 e dx by G(n). Assume n > 1. Using calculus, show that G(n+1) is the same as nG(n).
-
Ashton and Melody Webb are a married couple in their mid-20s. Ashton has a good start as an electrical engineer and Melody works as a sales representative. Since their marriage four years ago, Ashton...
-
The figure (Figure 1) shows voltage and current graphs for a resistor. f=25 Hz, R=20 amps Draw the resistor?s voltage and current phasors at t =15ms. Draw the vectors with their tails at the origin....
-
Thomlinson Company is considering the development of two products: no . 6 5 or no . 6 6 . Manufacturing cost ( in $ ) information follows: Manufacturing cost Costs No . 6 5 No . 6 6 Annual fixed...
-
Property Relations Instructions: Determine the classification of each proeprty shown below. Answer the questions found at the bottom of the sheet. Date of Marriage: February 23, 2010 Property 8...
-
Jacks grandparents have a 2 - bedroom cottage near Bear Mountain State Park, about an hour north of Manhattan. Their cottage is listed on Airbnb through a property management company, which charges 3...
-
Prepare entries to record the following non - strategic investment transactions of Arrowhead Investment Corporation. ( If no entry is required for a transaction / event , select " No journal entry...
-
Techie Technology Company (TTC) is a publicly traded technology company that specializes in the creation and maintenance of finance and accounting software programs for a variety of specialty areas....
-
The immediate external environment includes: (A) Divisions B) S. B. U. s C) Competitors (D) Management
-
As of January 1, 2018, Room Designs, Inc. had a balance of $9,900 in Cash, $3,500 in Common Stock, and $6,400 in Retained Earnings. These were the only accounts with balances in the ledger on January...
-
Imagine that your company is trying to decide between a single-processor system and a dual-processor system. Figure 1.26 gives the performance on two sets of benchmarks-a memory benchmark and a...
-
Many snooping coherence protocols have additional states, state transitions, or bus transactions to reduce the overhead of maintaining cache coherency. In Implementation 1 of Exercise 4.2, misses are...
-
The following questions investigate the impact of small and simple caches using CACTI, and assume a 90 nm (0.09 m) technology. a. Compare the access times of 32 KB caches with 64-byte blocks and a...
-
The efficiency of the viscous-shear pump of Fig. P8.29 is given by \[\eta=6 q \frac{(1-2 q)}{(4-6 q)}\] where \(q=Q / a b R \omega\) is a dimensionless flow rate, \(Q\) is the flow rate at pressure...
-
A continuous belt, passing upward through a chemical bath at speed \(U_{0}\), picks up a liquid film of thickness \(h\), density \(ho\), and viscosity \(\mu\). Gravity tends to make the liquid drain...
-
A wet paint film of uniform thickness, \(\delta\), is painted on a vertical wall. The wet paint can be approximated as a Bingham fluid with a yield stress, \(\tau_{y}\), and density, \(ho\). Derive...
Study smarter with the SolutionInn App