Question: Data structures define a specification on the format data can be represented, organized and structured in memory, and on the set of operations we


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.
Step by Step Solution
3.54 Rating (157 Votes )
There are 3 Steps involved in it
Based on the provided specifications heres a basic outline of how you can structure your Java progr... View full answer
Get step-by-step solutions from verified subject matter experts
