Question

3) Create a single-linked list (StudentList) where the data in the link is an object of type pointer to Student as defined beDefinition of Student: class Student{ private: String name; int age; public: Student 0 name-; age 0; ) Student(String n, inParameters Action insertHead Student*sInsert a link pointing to the object s at the head of insertTail Student*s Insert a lin

Using Python.

3) Create a single-linked list (StudentList) where the data in the link is an object of type pointer to Student as defined below. Note that you need to store and pass a pointer of type Student so that you do not create duplicate objects. Test your list with the provided program. You will find example code for a single-linked list of integers in Moodle that you can base your solution on. For your find methods, you can either use getName0 to check for equality of two Student objects or you can overload operator== and use the same code as provided in the Moodle example for integers. I would suggest placing the Student class in a Student.h file and the StudentList class in a separate .h/.cpp pair. Note that you will have to name your link for StudentList different from your link for TextClass or the compiler will complain of duplicate names. StudentList should support the following methods:
Definition of Student: class Student{ private: String name; int age; public: Student 0 name-""; age 0; ) Student(String n, int a) fname - n; age- a; ) void setName( String n ) { name-n; } String getName O {return name; void setAge (int a ) age-a;) int getAge O {return age; )
Parameters Action insertHead Student*sInsert a link pointing to the object s at the head of insertTail Student*s Insert a link pointing to the object s at the end of deleteHeadNone isEmpty the list the list Delete first link and return its value. Throw an exception if the list is empty. Return true if list is empty None findKeyString name Return true if a link exists containing a Student with the name. If the key is not found in the list, return false. deleteKey String Name Delete the first link you find that contains a Student with the name. Return true if success, false if failure.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

linklist linklis File Edit Format Run Options Window Help class Student: def init__(self, name, age) self.name-name self.age-linklist linklis File Edit Format Run Options Window Help while (laste.nextval): laste.nextval-NewNode if self.headval is Nonlinklist linklis File Edit Format Run Options Window Help aste -Laste.nextva return True else: return False def deleteKey (slinklist linklis File Edit Format Run Options Window Help if f return True else: return False def LListprint (self): printvalinklistu File Edit Format Run Options Window Help print( print(Delete at head) listl.deleteHead) listl.listprint () print2 Shell File Edit Shell Debug Options Window Help Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Int2 Shell File Edit Shell Debug Options Window Help Harry 39 Delete at head Mack 20 Jack Tom 23 Harry 39 List is Empty or not F2 Shell File Edit Shell Debug Options Window Help Maaz 18 Mack 20 Jack от 23 insert at tail Maaz 18 Mack 20 Jack Tom 23 Harry2 Shell File Edit Shell Debug Options Window Help insert at tail Maaz 18 Mack 20 Jack Tom 23 Harry 39 Delete at head Mack 20

Add a comment
Know the answer?
Add Answer to:
Using Python. 3) Create a single-linked list (StudentList) where the data in the link is an object of type pointer to Student as defined below. Note that you need to store and pass a pointer of type...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Ever...

    C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a "next" pointer. Textbook Туре String String String Attribute title author ISBN Textbook* next Library class should have a head node as an attribute to keep the list of the books. Also, following member...

  • Q) Modify the class Linked List below to make it a Doubly Linked List. Name your...

    Q) Modify the class Linked List below to make it a Doubly Linked List. Name your class DoublyLinkedList. Add a method addEnd to add an integer at the end of the list and a method displayInReverse to print the list backwards. void addEnd(int x): create this method to add x to the end of the list. void displayInReverse(): create this method to display the list elements from the last item to the first one. Create a main() function to test...

  • You are now going to create a LinkedList class, that will work very similarly to the...

    You are now going to create a LinkedList class, that will work very similarly to the Stack class seen in the book (and used in the previous exercise). Then write new methods as follows: add ( LinkedList::Link* l, int n ): will insert in the linked list, after link l, a chain of n new links. Each link will store an integer that will be set to receive, in order, a value starting from 0 until n-1. In the last...

  • USE JAVA PROGRAMMING Create a program that would collect list of persons using double link list...

    USE JAVA PROGRAMMING Create a program that would collect list of persons using double link list and use a Merge Sort to sort the object by age. Create a class called Person : name and age Create methods that add, and delete Person from the link list Create a method that sorts the persons' objects by age. package mergesort; public class MergeSortExample { private static Comparable[] aux; // auxiliary array for merges public static void sort(Comparable[] a) { aux =...

  • Using an appropriate definition of ListNode, design a simple linked list class called StringList with the...

    Using an appropriate definition of ListNode, design a simple linked list class called StringList with the following member functions: void add (std::string); int positionOf (std::string); bool setNodeVal(int, std::string); std::vector<std::string> getAsVector(); a default constructor a copy constructor a destructor The add() function adds a new node containing the value of the parameter to the end of the list. The positionOf() function returns the (zero-based) position in the list for the first occurrence of the parameter in the list, or -1 if...

  • In this lab, using C++, you will create an abstract data type, using a doubly-linked circular...

    In this lab, using C++, you will create an abstract data type, using a doubly-linked circular structure to store the values and links. You must create it by your own and not use any existing containers. You will need a QueueNode. You can use a struct for this, as each node will not have any associated functions. It will have members for data, and the next and previous pointers. Data will be positive integers. There will be no NULL pointers....

  • C programming A linked list is a linear data structure that allows us to add and remove items fro...

    c programming A linked list is a linear data structure that allows us to add and remove items from the list very quickly, by simply changing a few pointers. There are many different variations of linked lists. We have studied the doubly-linked, circular, with a dummy-header-node version of a linked list. In the class notes we studied several functions to manipulate a Linked List. For this assignment you must write the code for the following additional linked list functions: addFirst,...

  • CSBP 319 Data structures - Linked Lists - USE JAVA (NetBeans) A company would like to...

    CSBP 319 Data structures - Linked Lists - USE JAVA (NetBeans) A company would like to implement its inventory of computing machines as a linked list, called ComputerList. Write a Computer node class, called ComputerNode, to hold the following information about a Computer: • code (as a String) • brand (as a String) • model (as a String) • price (as double) • quantity (as int) ComputerNode should have constructors and methods (getters, setters, and toString()) to manage the above...

  • C++ - I have a doubly linked list, but I haven't been able to get the...

    C++ - I have a doubly linked list, but I haven't been able to get the "reverse list" option in the code to work(It's option #in the menu in the program). I received this guidance for testing: Test 4 cases by entering (in this order) c,a,z,k,l,m This tests empty list, head of list, end of list and middle of list. Then delete (in this order) a,z,l. This tests beginning, end and middle deletes. This exhaustively tests for pointer errors. #include...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT