Building a Linked List
For this activity, you will need to be using an Integrated Development Environment (IDE). The recommended IDE for this module is JetBrains IntelliJ IDEA for Python and JetBrains CLion for C++. You can follow instructions at the following page to set up your development environment:
Setting up your Development Environment
Task 1 - Implementing a Singly Linked List
Write a Python script and create a singly linked-list data structure. The script should have functions and methods that can insert an item at the beginning or end of the list.
Task 2 - Searching a Linked List
Implement a function that will search the linked lists for a specific item. The function should return True
if the item
is found, otherwise it should return False
.
def search(int _target):
return NotImplemented
Task 3 - Inserting an Element into a Linked List
Implement a function that allows the end-user to insert an element into a sorted list, and maintain the order of the list. For this function, you may want to consider using the function you implemented in task two to aid in finding an element.
def insert(int _target):
index = search(_target)
return NotImplemented
Task 4 - Removing an Element from a Linked List
Implement a function that will remove elements from the singly-linked lists. For the purpose of this task, you will want to provide an implementation that satisfies both the first-in first-out, and last-in last-out principles. For this function, you may want to consider using the function you implemented in task two to aid in finding an element.
def remove(int _target):
index = search(_target)
return NotImplemented
Struggling?
If you are struggling with this lab activity, you may want to get some additional support. You can speak to the module leader/team in the room of when the lab week is active, or you can visit the Additional Support page for more information on how you can get extra support.