Skip to content

This code implements a basic singly linked list in Python. It supports operations like inserting at the beginning, end, or a random position, deleting from the start, end, or a random position, and searching for a value. It also includes error handling and user prompts for interaction via a menu.

License

Notifications You must be signed in to change notification settings

nishuR31/Linked_list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linked List Management System

Overview

This Python program provides a command-line interface to manage a singly linked list. It supports various operations including insertion, deletion, and searching for elements. The list is managed using a set of methods that allow manipulation at the beginning, end, and random positions within the list.

GitHub Repo Size Sponsor Me Open Source Love Follow Me Custom Badge Issue Count Issue Count


Readme Card


Features

  • Insert elements at the beginning, end, or random position in the linked list.
  • Delete elements from the beginning, end, or a random position in the linked list.
  • Search for elements in the linked list.
  • Display the entire linked list.

Requirements

  • Python 3.x
  • colorama package for colored terminal output

Installation

  1. Clone the repository:

    git clone https://github.com/nishuR31/Linked_list.git
    cd Linked_list
    
    

Create a virtual environment (recommended) or use python pip:

python -m venv venv

if don't have pip. Then, run:

python -m ensurepip

Activate the virtual environment:

On Windows:

venv\Scripts\activate

On macOS/Linux:

source venv/bin/activate

Install the required packages:

pip install -r requirements.txt

or

pip intall colorama

Usage

python ll.py

or

python -u "ll.py"

Interact with the menu:

The script provides a menu with the following options:

1: Insert at the beginning 2: Insert at the end 3: Insert at a random position 4: Delete from the beginning 5: Delete from the end 6: Delete from a random position 7: Display the linked list 8: Search for an element 0: Exit

Follow the prompts to perform the desired operations.

  • Code Overview node Class Represents an individual node in the linked list with attributes for storing data and a reference to the next node.

linkedList Class Contains methods for managing the linked list:

display(): Displays all elements in the list.
insertFirst(): Inserts an element at the beginning.
insertLast(): Inserts an element at the end.
insertRandom(): Inserts an element at a random position.
delFirst(): Deletes the first element.
delLast(): Deletes the last element.
delRandom(): Deletes an element at a random position.
search(): Searches for an element in the list.
menu(): Function

Provides a command-line interface to interact with the linked list.

Example

1: Insert at beginning
2: Insert at end
3: Insert at random
4: Delete from start
5: Delete from last
6: Delete randomly
7: Display
8: Search
0: Exit
Enter your choice=> 7

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Feel free to contribute by opening issues or pull requests.

Contact

For any questions or collaborations, please reach out to me at:

About

This code implements a basic singly linked list in Python. It supports operations like inserting at the beginning, end, or a random position, deleting from the start, end, or a random position, and searching for a value. It also includes error handling and user prompts for interaction via a menu.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages