Skip to main content

Data structure components module

Project description

This module is build for all those working professionals/students who have basic knowledge of Data Structures and want to save coding time,this module contains various single LinkedList,stack,queue operations.It also contains 5 sorting algorithms and 2 searching algorithms.


Linked List Operations

from data_structure.linkedlist import create,traversal,insertAtEnd,insertBegin,insertMiddle

#Methods to create and Traverse Linked List

create("Hi") #To create node,creates one node at a time

create("How")

create("Are")

create("You")

traversal() #To traverse Linked List

Output:

Hi->How->Are->You->None

#Methods to Insert in Linked List

insertBegin("Hey,") #Insert at Beginning

traversal()

output:

Hey,->Hi->How->Are->You->None

insertMiddle(2,"Bro") #First parameter takes position,second parameter takes data

traversal()

output:

Hey,->Hi->Bro->How->Are->You->None

insertAtEnd("Doing") #Inserting at end

traversal()

output:

Hey,->Hi->Bro->How->Are->You->Doing->None


Stack Operations

from data_structure.stack import Stack

s = Stack()

#To push element in stack

s.push(50)

output:

'50 pushed'

s.push(80)

output:

'80 pushed'

#To peek the stack

s.peek()

output:

80

#To pop elements in stack

s.remove()

output:

80


Queue Operations

from data_structure.queue import Queue

q=Queue()

#To insert elements into queue

q.insert(40)

output:

'40 inserted'

q.insert(50)

output:

'50 inserted'

#To remove elements from queue

q.remove()

output:

40

#To check size of Queue

q.size()

output:

1


Sorting Operations

This module contains 5 sorting algorithms which are:

1)bubbleSort.

2)mergeSort.

3)insertionSort.

4)shellSort.

5)selectionSort.

from data_structure.sort import mergeSort,bubbleSort,insertionSort,shellSort,selectionSort

sort = mergeSort([5,101,35,121,55,75])

print(sort)

output:

[5, 35, 55, 75, 101, 121]

sort = selectionSort([5,101,35,121,55,75])

print(sort)

output:

[5, 35, 55, 75, 101, 121]


Searching Operations

from data_structure.search import linearSearch,binarySearch

#Linear Search

search = linearSearch([5,101,35,121,55,75],121)

print(search) S #Binary Search, Note list passed should be sorted

search = binarySearch([5, 35, 55, 75, 101, 121],121)

print(search)

output:

Found 121 at index 5


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

DataStructures15-0.0.1.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file DataStructures15-0.0.1.tar.gz.

File metadata

  • Download URL: DataStructures15-0.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.4rc1

File hashes

Hashes for DataStructures15-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0c3d1e63324f1ccafcb9ea1e87f605e7b7c6db143d59e701158df2b00de07dc9
MD5 d4a5e50cf975358ddada5395bda9f1fd
BLAKE2b-256 1b1228189d30d4793f98672532becead6aebde7488677380de24cefda596b59e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page