WIA1002/WIB1002/WXES1117 Data Structures Lab 7: Linked List/Doubly LinkedList

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (2 votes)

Q1 Create a package called SList and implement a node class called SNode. The SNode class consists of two constructors, respectively, a default constructor and a constructor that receives a generic item. 1) Initialise the variables appropriately in each constructor. 2) Create a generic class called SList and include the necessary declaration in the SList class. 3) Implement the following methods in class SList: i. public void appendEnd(E e) Append a new element at the end of the list. ii. public E removeInitial() Eliminate the first element in the list. iii. public boolean contains(E e) Search for an element and returns true if this list contains the searched element iv. public void clear() Empty all elements in the list and return a statement that reports that the list is empty. v. public void display() Display all values from the list in a successive order. 4) Write a test program called TestSList in the SList package. Using the appropriate methods you implemented in SList, do the following: 1) Append the following values individually: “Linked list, is, easy.” 2) Display these values. 3) Remove the word “Linked list” and display the removed value. 4) Check if ‘difficult’ is in the list. 5) Clear the list. WIA1002/WIB1002 Lab 7 Sem. 2, 2017/2018 Page 2 Q2 A kindergarten needs to use an online student management system enabling its admin staff to manage their student list. Write a program using singly linked list to demonstrate the following: i) public void add(E e) ii) public void removeElement(E e) iii) public void printList() iv) public int getSize() v) public boolean contains(E e) vi) public void replace(E e, E newE) The program should demonstrate the following functions: • Admin staff shall be able to interact with the program. The admin staff should enter a list of student’s names. • Display the list of the entered student’s names. • Calculate the number of students in the list. • Rename existing student’s name in the list with the new one specified by the admin staff. • Delete a student name as specified by the admin staff. Sample Output WIA1002/WIB1002 Lab 7 Sem. 2, 2017/2018 Page 3 Q3 1) Implement all the DoublyLinked List methods in the lecture’s slide. Write a test program by using the appropriate methods, do the following: 1) Add first node with value of 1 2) Add last node with value of 100 3) Add node with value of 2 at position index of 2 4) Remove node at position index of 3 5) Traverse Forward 6) Traverse Backward 7) Print current size of linked list 8) Clear all nodes in the linked list 9) Print again current size of linked list Sample Output: