-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SkipList.py: Added SkipList Data Structure Implementation #236
Conversation
This adds the implementation of Skip List Data Structure in python, this also adds the operation that can be done in a SkipList Data Structure like Insertion, Deletion, Traversal. Closes NITSkmOS#234
skip_list/Python/SkipList.py
Outdated
x = x.next[i] | ||
update[i] = x | ||
return update | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains following spacing inconsistencies:
- Trailing whitespaces.
Origin: SpaceConsistencyBear, Section: all.pyjava
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
+++ b/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
@@ -62,7 +62,7 @@
x = x.next[i]
update[i] = x
return update
-
+
'''
This function inserts an element in the correct possition.
The insertion operation takes O(n) time complexity
skip_list/Python/SkipList.py
Outdated
self.maxHeight = max(self.maxHeight, len(node.next)) | ||
while len(self.head.next) < len(node.next): | ||
self.head.next.append(None) | ||
update = self.updateList(elem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains following spacing inconsistencies:
- Trailing whitespaces.
Origin: SpaceConsistencyBear, Section: all.pyjava
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
+++ b/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
@@ -73,7 +73,7 @@
self.maxHeight = max(self.maxHeight, len(node.next))
while len(self.head.next) < len(node.next):
self.head.next.append(None)
- update = self.updateList(elem)
+ update = self.updateList(elem)
if self.find(elem, update) == None:
for i in range(len(node.next)):
node.next[i] = update[i].next[i]
self.len += 1 | ||
|
||
''' | ||
This function will remove the specified element from the list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains following spacing inconsistencies:
- Trailing whitespaces.
Origin: SpaceConsistencyBear, Section: all.pyjava
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
+++ b/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
@@ -81,7 +81,7 @@
self.len += 1
'''
- This function will remove the specified element from the list.
+ This function will remove the specified element from the list.
The deletion operation in Skip List takes O(log(n)) time.
'''
def remove(self, elem):
skip_list/Python/SkipList.py
Outdated
update[i].next[i] = x.next[i] | ||
if self.head.next[i] == None: | ||
self.maxHeight -= 1 | ||
self.len -= 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains following spacing inconsistencies:
- Trailing whitespaces.
Origin: SpaceConsistencyBear, Section: all.pyjava
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
+++ b/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
@@ -92,7 +92,7 @@
update[i].next[i] = x.next[i]
if self.head.next[i] == None:
self.maxHeight -= 1
- self.len -= 1
+ self.len -= 1
'''
This function will print the entier Data Structure, level by level (top to bottom)
|
||
''' | ||
This function will print the entier Data Structure, level by level (top to bottom) | ||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains following spacing inconsistencies:
- Trailing whitespaces.
Origin: SpaceConsistencyBear, Section: all.pyjava
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
+++ b/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
@@ -96,7 +96,7 @@
'''
This function will print the entier Data Structure, level by level (top to bottom)
- '''
+ '''
def printList(self):
for i in range(len(self.head.next)-1, -1, -1):
x = self.head
skip_list/Python/SkipList.py
Outdated
t0 = time.time() | ||
# Skip List takes the maximum time to search the elements in the middle. | ||
print(skipList.find(596536) != None) | ||
print("Time taken to search in a list of size 1 Million: "+str(time.time() - t0)+" s.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains following spacing inconsistencies:
- No newline at EOF.
Origin: SpaceConsistencyBear, Section: all.pyjava
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
+++ b/tmp/tmpphsfotv0/skip_list/Python/SkipList.py
@@ -119,4 +119,4 @@
t0 = time.time()
# Skip List takes the maximum time to search the elements in the middle.
print(skipList.find(596536) != None)
- print("Time taken to search in a list of size 1 Million: "+str(time.time() - t0)+" s.")+ print("Time taken to search in a list of size 1 Million: "+str(time.time() - t0)+" s.")
Never open a PR from master branch. Read the guidelines before solving any issue |
This adds the implementation of Skip List Data Structure in python, this also adds the operation that can be done in a SkipList Data Structure like Insertion, Deletion, Traversal. Closes NITSkmOS#234
level by level (top to bottom) | ||
''' | ||
def printList(self): | ||
for i in range(len(self.head.next)-1, -1, -1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains following spacing inconsistencies:
- Trailing whitespaces.
Origin: SpaceConsistencyBear, Section: all.pyjava
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmphyrtd5og/skip_list/Python/SkipList.py
+++ b/tmp/tmphyrtd5og/skip_list/Python/SkipList.py
@@ -56,7 +56,7 @@
while x.next[i]!=None and x.next[i].elem<elem:
x=x.next[i]
update[i]=x
- return update
+ return update
'''
This function inserts an element in the correct possition.
The insertion operation takes O(n) time complexity
This adds the implementation of Skip List Data Structure in python, this also adds the operation that can be done in a SkipList Data Structure like Insertion, Deletion, Traversal. Closes NITSkmOS#234
Comment on d08032f, file skip_list/Python/SkipList.py, line 59. Line contains following spacing inconsistencies:
Origin: SpaceConsistencyBear, Section: The issue can be fixed by applying the following patch: --- a/tmp/tmpn2153vea/skip_list/Python/SkipList.py
+++ b/tmp/tmpn2153vea/skip_list/Python/SkipList.py
@@ -56,7 +56,7 @@
while x.next[i]!=None and x.next[i].elem<elem:
x=x.next[i]
update[i]=x
- return update
+ return update
'''
This function inserts an element in the correct possition.
The insertion operation takes O(n) time complexity |
Comment on d08032f, file skip_list/Python/SkipList.py, line 69. Line contains following spacing inconsistencies:
Origin: SpaceConsistencyBear, Section: The issue can be fixed by applying the following patch: --- a/tmp/tmpn2153vea/skip_list/Python/SkipList.py
+++ b/tmp/tmpn2153vea/skip_list/Python/SkipList.py
@@ -66,7 +66,7 @@
self.maxHeight=max(self.maxHeight,len(node.next))
while(len(self.head.next)<len(node.next)):
self.head.next.append(None)
- update=self.updateList(elem)
+ update=self.updateList(elem)
if(self.find(elem, update)==None):
for i in range(len(node.next)):
node.next[i]=update[i].next[i] |
Comment on d08032f, file skip_list/Python/SkipList.py, line 76. Line contains following spacing inconsistencies:
Origin: SpaceConsistencyBear, Section: The issue can be fixed by applying the following patch: --- a/tmp/tmpn2153vea/skip_list/Python/SkipList.py
+++ b/tmp/tmpn2153vea/skip_list/Python/SkipList.py
@@ -73,7 +73,7 @@
update[i].next[i]=node
self.len+=1
'''
- This function will remove the specified element from the list.
+ This function will remove the specified element from the list.
The deletion operation in Skip List takes O(log(n)) time.
'''
def remove(self,elem): |
Comment on d08032f, file skip_list/Python/SkipList.py, line 87. Line contains following spacing inconsistencies:
Origin: SpaceConsistencyBear, Section: The issue can be fixed by applying the following patch: --- a/tmp/tmpn2153vea/skip_list/Python/SkipList.py
+++ b/tmp/tmpn2153vea/skip_list/Python/SkipList.py
@@ -84,7 +84,7 @@
update[i].next[i]=x.next[i]
if(self.head.next[i]==None):
self.maxHeight-=1
- self.len-=1
+ self.len-=1
'''
This function will print the entier Data Structure,
level by level (top to bottom) |
Comment on d08032f, file skip_list/Python/SkipList.py, line 91. Line contains following spacing inconsistencies:
Origin: SpaceConsistencyBear, Section: The issue can be fixed by applying the following patch: --- a/tmp/tmpn2153vea/skip_list/Python/SkipList.py
+++ b/tmp/tmpn2153vea/skip_list/Python/SkipList.py
@@ -88,7 +88,7 @@
'''
This function will print the entier Data Structure,
level by level (top to bottom)
- '''
+ '''
def printList(self):
for i in range(len(self.head.next)-1, -1, -1):
x=self.head |
added Linear search python implementation
added linear search implementation in c.
@@ -0,0 +1,24 @@ | |||
#include <stdio.h> | |||
void main() | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ should almost always be at the end of the previous line [whitespace/braces] [4]
Origin: CPPLintBear, Section: all.cpplint
.
#include <stdio.h> | ||
void main() | ||
{ | ||
int a[10], i, item,n,flag=0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing spaces around = [whitespace/operators] [4]
Origin: CPPLintBear, Section: all.cpplint
.
#include <stdio.h> | ||
void main() | ||
{ | ||
int a[10], i, item,n,flag=0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after , [whitespace/comma] [3]
Origin: CPPLintBear, Section: all.cpplint
.
{ | ||
int a[10], i, item,n,flag=0; | ||
printf("Enter number of elements : "); | ||
scanf("%d",&n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after , [whitespace/comma] [3]
Origin: CPPLintBear, Section: all.cpplint
.
printf("Enter number of elements : "); | ||
scanf("%d",&n); | ||
printf("\nEnter elements of an array:\n"); | ||
for (i=0; i<n; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing spaces around < [whitespace/operators] [3]
Origin: CPPLintBear, Section: all.cpplint
.
scanf("%d", &a[i]);} | ||
printf("\nEnter item to search: "); | ||
scanf("%d", &item); | ||
for (i=0; i<n; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing spaces around < [whitespace/operators] [3]
Origin: CPPLintBear, Section: all.cpplint
.
printf("\nEnter item to search: "); | ||
scanf("%d", &item); | ||
for (i=0; i<n; i++) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ should almost always be at the end of the previous line [whitespace/braces] [4]
Origin: CPPLintBear, Section: all.cpplint
.
for (i=0; i<n; i++) | ||
{ | ||
if (item == a[i]) | ||
{ flag=1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing spaces around = [whitespace/operators] [4]
Origin: CPPLintBear, Section: all.cpplint
.
break; | ||
} | ||
} | ||
if (flag==0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing spaces around == [whitespace/operators] [3]
Origin: CPPLintBear, Section: all.cpplint
.
Added c implementation of merge sort.
Added Cpp implementation of Quick sort
Added python implementtion for queue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow https://github.com/NITSkmOS/Algorithms#contributing.
Open new one after rebasing your local repo.
For rebase, get help from https://github.com/NITSkmOS/Algorithms/blob/master/GIT_BASICS.md
For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!
Fixes #234
By submitting this pull request I confirm I've read and complied with the
below declarations.
{Tag}: Add {Algorithm/DS name} [{Language}]
, notUpdate README.md
orAdded new code
.After you submit your pull request, DO NOT click the 'Update Branch' button.