Skip to content

Latest commit

 

History

History

linked_list

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Linked List

Concept

Update later...

Examples

With CPP

  1. Example with Singly Linked List
  2. Example with Doubly Linked List
  3. Example with Circular Linked List

Exercises

*Note: LinkedList always has default constructor and arguments constructor.

  1. Create a linked list class whose Nodes have a data part is integer type and it has a print method. Initialize 5 linked list instances and print their element’s data to console.
  2. Create a linked list class whose Nodes have a data part is Point (Point is a class that has 2 private properties indicating for coordinate) and it has a print method. Initialize a linked list instance and print its element’s data to console.
  3. Create a linked list class whose Nodes have a data part is integer type and it has print, insertLast, insertFirst methods. Declare a linked list instance, then add numbers of random int numbers and print its element’s data to console.
  4. Create a linked list class similar to question 3, but Its Nodes’ data part is Point type. Initialize a linked list instance, then add numbers of random Points and print its element’s data to console.
  5. Create a generic linked list class has print, insertLast, insertFirst methods. Initialize a number type linked list instance and add numbers of random Points to a declared Point type linked list instance that are generated from generic linked list class and print their element’s data to console.
  6. Create an int (number) linked list class has print, insertLast, insertFirst, insertAt. Initialize a linked list instance to perform all of its methods.

Note: print, insertLast, insertFirst and insertAt methods are required in LinkedList now.

  1. Create an int (number) linked list class has required methods, removeLast, removeFirst and removeAt. Declare a linked list instance and add numbers of random numbers and perform all of its methods.
  2. Create an int (number) linked list class has getAt method. Initialize a linked list and perform getAt method.
  3. Create an int (number) linked list class has insertByOrder method. Declare a linked list and add numbers of random numbers with insertByOrder.
  4. Create an int (number) linked list class has all methods that are mentioned in every previous question. Declare a doubly linked list and perform all of its methods.

Note: removeLast, removeFirst, removeAt, getAt and insertByOrder methods are required in LinkedList now too.

  1. Create a generic linked list class, a Point class with x and y properties and a Person class with name, age properties. Use generic linked list class to declare 2 linked lists
    • Point Linked List: add 2 points with insertFirst, 2 points with insertLast, 2 points with insertAt and 2 points with insertByOrder. Get arbitrary 4 points with getAt. Then remove tail, remove head, remove a random point.
    • Person Linked List: add 2 people with insertFirst, 2 people with insertLast, 2 people with insertAt and 2 people with insertByOrder. Get arbitrary 4 people with getAt. Then remove tail, remove head, remove 2 random people.
  2. Create a generic doubly linked list class has the same methods as the generic singly linked list class in Question 11 and 2 two classes Point and Person. Use generic doubly linked list class to declare 2 doubly linked lists and do tasks like Question 11.