omkarpathak / data-structures-using-python Goto Github PK
View Code? Open in Web Editor NEWThis is my repository for Data Structures using Python
License: GNU General Public License v3.0
This is my repository for Data Structures using Python
License: GNU General Public License v3.0
@OmkarPathak, In the delete method in linkedlist.py the last element will be deleted if the given key is not present and if only the head node is present then there will a reference error for prev node.
So I have made some changes and it works
# deleting an item based on data(or key)
def delete(self, data):
temp = self.head
# if data/key is found in head node itself
if(temp.data == data):
self.head = temp.next
temp = None
return
else:
# else search all the nodes
while(temp.next):
if(temp.data == data):
break
prev = temp #save current node as previous so that we can go on to next node
temp = temp.next
# node not found
if temp == None:
return
prev.next = temp.next
return
Your code breaks when you try to call insertAtEnd when the list is empty.
enqueue(): rear = (rear + 1)%size
This logic is not implemented, the present circular queue behaves more or less like queue.
Hi Omkar,
Append and Pop will add and remove the elements at the end of list.
Queue follows first come first serve property(FIFO). consider the following example
a = []
a.enqueue(1) # adding the element to empty queue
a
[1]
a.enqueue(2) # adding the second element
[1, 2]
a.dequeue() # removing the first element
a
[2]
To remove the first element use the pop(0) instead of pop()
Nice Collection of tutorials. Great Work!!
Thanks,
Sundeep Gullapudi.
Not int
or float
. I want to use class which is I defined. Plus, I don't use any list or dictionary type inside my class.
class Array(object):
''' sizeOfArray: denotes the total size of the array to be initialized
arrayType: denotes the data type of the array(as all the elements of the array have same data type)
arrayItems: values at each position of array
'''
def __init__(self, sizeOfArray, arrayType = int):
...
Thank you.
It would be nice to add a method to the BST class so that given an unsorted array of integers a balanced BST is constructed. I'm not sure whether it is already in the repo but I have not been able to find it. I'd be happy to take care of it if you find it interesting :)
#Array.ipynb file
'The array elements can be accessed in constant time by using the index of the parliculnr element as the subscript.'
want to add this circular doubly linked list program in python . do please assign me @OmkarPathak
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.