In the lecture, we introduced a new linear data structure called Linked-list. A Linked-list allows us...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In the lecture, we introduced a new linear data structure called Linked-list. A Linked-list allows us to store a collection of objects of the same data type so that the ordering of those objects is determined by references stored within each object. That is to say, each object in the Linked- List stores information about the location of its successor object. In this problem set, you will implement a Linked-List data structure to store different object types. Moreover, you will practice using generic classes, that would allow you to build a Linked-list data structure whose type of objects it can store is defined at instantiation time. Learning Activity 1: Watch the video lectures on Linked-List and particular the coding sessions "Linked Lists Java Implementation" and "Linked List using Genetic Classes". The session "Linked Lists Java Implementation" showcases step-by-step how to implement and use a LinkedList to store a specific object type (namely Tweet Objects). The session “Linked List using Genetic Classes" introduces the concept of generic classes and showcases how to implement and use a linked-list data structure using genetic classes. Task 1: Reproduce the object-specific Linked-List functionality. In this task, you are asked to reproduce the functionality presented in “Linked Lists Java Implementation" by creating and using an object-specific LinkedList (i.e. without using genetic classes). In particular, you need to implement the following classes: • Create a new class called User that stores information about a User. Specifically, the "User" class should maintain three public attributes, namely: userId, a userName, and user Age. In addition, the User class should implement a constructor method that takes as input values for all three attributes and initializes them. Finally, the User class should override the toString() method so it displays the UserId as its output. • Create a UserNode class. This class should implement a node functionality to be used in a LinkedList. The class should mirror the functionality of the "TweetNode" class introduced in Linked Lists Java Implementation". • Create a UserLinkedList class. This class should implement a LinkedList functionality to store and manipulate objects of type UserNode. The class should mirror the functionality of the "TweetLinkedList" class introduced in "Linked Lists Java Implementation" session. Specifically, the UserLinkedList class should implement the following methods: public void addLast(User a) public void addFirst(User a) public void addAt(User a, int index) Task 2: Reproduce the Generic Linked-List functionality. In this task, you are asked to reproduce the functionality presented in "Linked Lists Java Implementation" by creating and using an generic LinkedList (i.e. using genetic classes). In particular, you need to implement the following classes: • Create a Node class. This class should be a generic class that implement a node functionality to be used in a genetic LinkedList. The class should mirror the functionality of the Node class introduced in "Linked List using Genetic Classes". • Create a LinkedList class. This class should be a generic class implement a LinkedList functionality to store and manipulate any type of input object. The class should mirror the functionality of the "LinkedList" class introduced in "Linked List using Genetic Classes" session. Specifically, the LinkedList class should implement the same methods as the UserLinkedList but using generic types. Task 3: Demonstrate the correctness of your Linked-List implementation Create a Main.java class to demonstrate the correct implementation and use of the UserLinkedList and LinkedList classes. As part of the main method of the Main class implement the following use-case: • Demonstrate the correctness of UserLinkedList class • о о Create a new instance of the UserLinkedList class in a variable called mylist. Create four instances of User objects with their userid set to 100,200, 300, and 400 respectively (choose values for each user's name and age) Add each of the four instances to the mylist LinkedList in order, using the addFirst method. Print the content of the mylist by invoking the printList() method. Create a fifth instance of a User Object with its userid set to the value 500. Add this instance to the mylist LinkedList at index 3, using the addAt method. Print the content of the mylist by invoking the printList() method. Remove the object from the mylist LinkedList from index 3 using the remove method. Print the content of the mylist by invoking the printList() method. Demonstrate the correctness of LinkedList class Create a new instance of the LinkedList class in a variable called mylist. Create four additional instances of User objects with their userid set to 1000,2000, 3000, and 4000 respectively (choose values for each user's name and age) о Add each of the four instances to the mylist Genertic LinkedList in order, using the addFirst method. Print the content of the mylistGenertic by invoking the printList() method. Create a fifth instance of a User Object with its userid set to the value 5000. Add this instance to the mylistGenertic LinkedList at index 3, using the addAt method. Print the content of the mylistGenertic t by invoking the printList() method. Remove the object from the mylistGenertic LinkedList from index 3 using the remove method. Print the content of the mylistGenertic by invoking the printList() method. O O O 00 Program Requirement 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 implementation should be efficient; unnecessary computations or unnecessary use of memory will be penalized. Do not use any helper methods/functions other than those provided. 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 (if provided). Your program must compile and run without errors and generate the expected output. In the lecture, we introduced a new linear data structure called Linked-list. A Linked-list allows us to store a collection of objects of the same data type so that the ordering of those objects is determined by references stored within each object. That is to say, each object in the Linked- List stores information about the location of its successor object. In this problem set, you will implement a Linked-List data structure to store different object types. Moreover, you will practice using generic classes, that would allow you to build a Linked-list data structure whose type of objects it can store is defined at instantiation time. Learning Activity 1: Watch the video lectures on Linked-List and particular the coding sessions "Linked Lists Java Implementation" and "Linked List using Genetic Classes". The session "Linked Lists Java Implementation" showcases step-by-step how to implement and use a LinkedList to store a specific object type (namely Tweet Objects). The session “Linked List using Genetic Classes" introduces the concept of generic classes and showcases how to implement and use a linked-list data structure using genetic classes. Task 1: Reproduce the object-specific Linked-List functionality. In this task, you are asked to reproduce the functionality presented in “Linked Lists Java Implementation" by creating and using an object-specific LinkedList (i.e. without using genetic classes). In particular, you need to implement the following classes: • Create a new class called User that stores information about a User. Specifically, the "User" class should maintain three public attributes, namely: userId, a userName, and user Age. In addition, the User class should implement a constructor method that takes as input values for all three attributes and initializes them. Finally, the User class should override the toString() method so it displays the UserId as its output. • Create a UserNode class. This class should implement a node functionality to be used in a LinkedList. The class should mirror the functionality of the "TweetNode" class introduced in Linked Lists Java Implementation". • Create a UserLinkedList class. This class should implement a LinkedList functionality to store and manipulate objects of type UserNode. The class should mirror the functionality of the "TweetLinkedList" class introduced in "Linked Lists Java Implementation" session. Specifically, the UserLinkedList class should implement the following methods: public void addLast(User a) public void addFirst(User a) public void addAt(User a, int index) Task 2: Reproduce the Generic Linked-List functionality. In this task, you are asked to reproduce the functionality presented in "Linked Lists Java Implementation" by creating and using an generic LinkedList (i.e. using genetic classes). In particular, you need to implement the following classes: • Create a Node class. This class should be a generic class that implement a node functionality to be used in a genetic LinkedList. The class should mirror the functionality of the Node class introduced in "Linked List using Genetic Classes". • Create a LinkedList class. This class should be a generic class implement a LinkedList functionality to store and manipulate any type of input object. The class should mirror the functionality of the "LinkedList" class introduced in "Linked List using Genetic Classes" session. Specifically, the LinkedList class should implement the same methods as the UserLinkedList but using generic types. Task 3: Demonstrate the correctness of your Linked-List implementation Create a Main.java class to demonstrate the correct implementation and use of the UserLinkedList and LinkedList classes. As part of the main method of the Main class implement the following use-case: • Demonstrate the correctness of UserLinkedList class • о о Create a new instance of the UserLinkedList class in a variable called mylist. Create four instances of User objects with their userid set to 100,200, 300, and 400 respectively (choose values for each user's name and age) Add each of the four instances to the mylist LinkedList in order, using the addFirst method. Print the content of the mylist by invoking the printList() method. Create a fifth instance of a User Object with its userid set to the value 500. Add this instance to the mylist LinkedList at index 3, using the addAt method. Print the content of the mylist by invoking the printList() method. Remove the object from the mylist LinkedList from index 3 using the remove method. Print the content of the mylist by invoking the printList() method. Demonstrate the correctness of LinkedList class Create a new instance of the LinkedList class in a variable called mylist. Create four additional instances of User objects with their userid set to 1000,2000, 3000, and 4000 respectively (choose values for each user's name and age) о Add each of the four instances to the mylist Genertic LinkedList in order, using the addFirst method. Print the content of the mylistGenertic by invoking the printList() method. Create a fifth instance of a User Object with its userid set to the value 5000. Add this instance to the mylistGenertic LinkedList at index 3, using the addAt method. Print the content of the mylistGenertic t by invoking the printList() method. Remove the object from the mylistGenertic LinkedList from index 3 using the remove method. Print the content of the mylistGenertic by invoking the printList() method. O O O 00 Program Requirement 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 implementation should be efficient; unnecessary computations or unnecessary use of memory will be penalized. Do not use any helper methods/functions other than those provided. 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 (if provided). Your program must compile and run without errors and generate the expected output.
Expert Answer:
Answer rating: 100% (QA)
Below is a basic implementation in Java for the described problemThis code implements a generic LinkedList in Java allowing it to store and manipulate ... View the full answer
Related Book For
International Marketing And Export Management
ISBN: 9781292016924
8th Edition
Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr
Posted Date:
Students also viewed these programming questions
-
A store sells merchandise through Internet auctions. The owner needs to mail a $15,000 hexagonal antique picture frame. He has instructed his employee, Nellie, to buy packaging that will make sure...
-
Pinnacle Plus declared and paid a cash dividend of $ 6 , 6 0 0 in the current year. Its comparative financial statements, prepared at December 3 1 , reported the following summarized information:...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
?Claim: A of adults would erase all of their personalinformation online if they could. A software firm survey of 511randomly selected adults showed that 36 ?% of them would erase allof their pe...
-
Discuss the effect on the solution to Problem 37 if the limit on phosphoric acid is increased to 1,000 pounds. In Problem, construct a mathematical model in the form of a linear programming problem....
-
a. Do you think Mr Smith should take the trip? Outline any ethical concerns involved.
-
Explain briefly two reasons as to why it is nearly impossible for individuals living in rural areas to find effective crop insurance.
-
Use the GSS 1OSSDS data file to study the relationship between the number of siblings a respondent has (SIBS) and his or her number of children (CHILDS). a. Construct a scatterplot of these two...
-
5. Simplify. Write each expression with only positive exponents. 2 a) a xa b) e(es) d)
-
Consider a scenario in which state colleges must actively recruit students. California Sci has $750,000 in assets available. Its Board of Regents has to consider several options. The board may decide...
-
Klara is 25 years old and is planning for her retirement. She wants to consider both options of retiring at age 60 or at age 65, and has no savings into her RRSP yet. She figures she would like to...
-
Fill in the Blank. If the band of frequencies has finite cut-off frequencies for a white noise, it is called ____________ white noise.
-
For a normal probability density function, \(\operatorname{Prob}[-3 \sigma \leq x(t) \leq 3 \sigma]\) is a. 0.6827 b. 0.999937 c. 0.9973
-
Fill in the Blank. The main advantage of a stroboscope is that it can measure the speed without making _______________ with the rotating body.
-
Fill in the Blank. The lateral vibration of a thin beam is governed by a(n) _________ order partial differential continuous system.
-
How are fixed boundary conditions incorporated in the finite element equations?
-
! Required information [The following information applies to the questions displayed below.] Taylor's is a popular restaurant that offers customers a large dining room and comfortable bar area....
-
Find i 0 (t) for t > 0 in the circuit in Fig. 16.72 . 2 + Vo 1 7.5e-2t u(t) V ( +) 4.5[1 u(t)]V 0.5v. 1H
-
Explain the meaning of the following statement: Managing multiculturalism within the international marketing organization and within the markets it serves is what makes international marketing...
-
Go to a European companys website, an Asian/Pacific companys website, and a US or Canadian companys website and evaluate each in terms of its use for marketing communications about the companys...
-
In mid-2004 the president of Elis Cheesecake Company, Mr Marc Schulman, was reviewing the policies that had guided the international expansion of the firm. In the 1990s the company had recognized the...
-
When a team of people is able to achieve more than what its members could by working individually, this is called ____________. (a) distributed leadership (b) consensus (c) team viability (d) synergy
-
Which statement about self-managing teams is correct? (a) They can improve performance but not satisfaction. (b) They should have limited decision-making authority (c) They should operate without any...
-
Members of a team tend to become more motivated and better able to deal with conflict during the ____________ stage of team development. (a) forming (b) norming (c) performing (d) adjourning
Study smarter with the SolutionInn App