From 7a71a9e47b1f8f86313ebe5279b54cd88aac66cf Mon Sep 17 00:00:00 2001 From: Sheetal Date: Fri, 2 Oct 2020 22:06:37 +0530 Subject: [PATCH 1/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc8ab107..bc80f8cc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # **Scripts Dump!** +[![Open Source Love](https://firstcontributions.github.io/open-source-badges/badges/open-source-v1/open-source.svg)](https://github.com/firstcontributions/open-source-badges) [![Pull Requests Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com) > Your goto place to find and dump any script you want. > @@ -45,7 +46,6 @@ ScriptsDump is a complete repository of all kind of scripts we and you can think - **[Graph Algorithms](/Graph_Algorithms/src)** - ## Maintainers We're always looking out for people who're enthusiastic to work and collaborate with people. If you want to become a maintainer at ScriptsDump you can contact us support@codezoned.com From f991b8c149a49612b0f96738466eece1ca818e67 Mon Sep 17 00:00:00 2001 From: Sheetal Date: Fri, 2 Oct 2020 22:27:43 +0530 Subject: [PATCH 2/9] Add files via upload --- Arrays-Sorting/src/oddEvenSort.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Arrays-Sorting/src/oddEvenSort.py diff --git a/Arrays-Sorting/src/oddEvenSort.py b/Arrays-Sorting/src/oddEvenSort.py new file mode 100644 index 00000000..e8ccbbca --- /dev/null +++ b/Arrays-Sorting/src/oddEvenSort.py @@ -0,0 +1,25 @@ + +#Python Program to implement Odd-Even / Brick Sort +def oddEvenSort(arr, n): + isSorted = 0 + while isSorted == 0: + isSorted = 1 + temp = 0 + for i in range(1, n-1, 2): + if arr[i] > arr[i+1]: + arr[i], arr[i+1] = arr[i+1], arr[i] + isSorted = 0 + + for i in range(0, n-1, 2): + if arr[i] > arr[i+1]: + arr[i], arr[i+1] = arr[i+1], arr[i] + isSorted = 0 + + return + +arr = [34, 2, 10, -9] +n = len(arr) +oddEvenSort(arr, n); + +for i in range(0, n): + print(arr[i], end = ' ') \ No newline at end of file From b00c6d4eefd90e1657526ab8553da5657e2cef1e Mon Sep 17 00:00:00 2001 From: Sheetal Date: Fri, 2 Oct 2020 22:34:04 +0530 Subject: [PATCH 3/9] Add files via upload --- Arrays-searching/src/linear_search.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Arrays-searching/src/linear_search.py diff --git a/Arrays-searching/src/linear_search.py b/Arrays-searching/src/linear_search.py new file mode 100644 index 00000000..171f45dd --- /dev/null +++ b/Arrays-searching/src/linear_search.py @@ -0,0 +1,25 @@ +def search(arr, n, x): + + for i in range (0, n): + + if (arr[i] == x): + + return i; + + return -1; + +arr = [ 2, 3, 4, 10, 40 ]; + +x = 10; + +n = len(arr); + +result = search(arr, n, x) + +if(result == -1): + + print("Element is not present in array") + +else: + + print("Element is present at index", result); \ No newline at end of file From 550e6f553901fb88966da51bd8545b815e80c7d7 Mon Sep 17 00:00:00 2001 From: Sheetal Date: Fri, 2 Oct 2020 22:42:27 +0530 Subject: [PATCH 4/9] Add files via upload --- .../src/Linked Lists/circular_linked_list.py | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 Data_Structure/src/Linked Lists/circular_linked_list.py diff --git a/Data_Structure/src/Linked Lists/circular_linked_list.py b/Data_Structure/src/Linked Lists/circular_linked_list.py new file mode 100644 index 00000000..ed9792ab --- /dev/null +++ b/Data_Structure/src/Linked Lists/circular_linked_list.py @@ -0,0 +1,137 @@ +class Node: + + def init(self, data): + + self.data = data + + self.next = None + +class CircularLinkedList: + + def init(self): + + self.last = None + + # for empty list + + def addToEmpty(self, data): + + if (self.last != None): + + return self.last + + # Creating the newnode temp + + temp = Node(data) + + self.last = temp + + # Create Link + + self.last.next = self.last + + return self.last + + def addBegin(self, data): + + if (self.last == None): + + return self.addToEmpty(data) + + temp = Node(data) + + temp.next = self.last.next + + self.last.next = temp + + return self.last + + def addEnd(self, data): + + if (self.last == None): + + return self.addToEmpty(data) + + temp = Node(data) + + temp.next = self.last.next + + self.last.next = temp + + self.last = temp + + return self.last + + def addAfter(self, data, item): + + if (self.last == None): + + return None + + temp = Node(data) + + p = self.last.next + + while p: + + if (p.data == item): + + temp.next = p.next + + p.next = temp + + if (p == self.last): + + self.last = temp + + return self.last + + else: + + return self.last + + p = p.next + + if (p == self.last.next): + + print(item, "not present in the list") + + break + + def traverse(self): + + if (self.last == None): + + print("List is empty") + + return + + temp = self.last.next + + while temp: + + print(temp.data, end = " ") + + temp = temp.next + + if temp == self.last.next: + + break + +if name == 'main': + + llist = CircularLinkedList() + + last = llist.addToEmpty(6) + + last = llist.addBegin(4) + + last = llist.addBegin(2) + + last = llist.addEnd(8) + + last = llist.addEnd(12) + + last = llist.addAfter(10,8) + + llist.traverse() \ No newline at end of file From 11d2903431aee8726ac7532aef7b977f28502a40 Mon Sep 17 00:00:00 2001 From: Sheetal Date: Sat, 3 Oct 2020 22:53:26 +0530 Subject: [PATCH 5/9] Delete linear_search.py --- Arrays-searching/src/linear_search.py | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 Arrays-searching/src/linear_search.py diff --git a/Arrays-searching/src/linear_search.py b/Arrays-searching/src/linear_search.py deleted file mode 100644 index 171f45dd..00000000 --- a/Arrays-searching/src/linear_search.py +++ /dev/null @@ -1,25 +0,0 @@ -def search(arr, n, x): - - for i in range (0, n): - - if (arr[i] == x): - - return i; - - return -1; - -arr = [ 2, 3, 4, 10, 40 ]; - -x = 10; - -n = len(arr); - -result = search(arr, n, x) - -if(result == -1): - - print("Element is not present in array") - -else: - - print("Element is present at index", result); \ No newline at end of file From 4c8a6543bd21e17c90bb40508f5622b143d31219 Mon Sep 17 00:00:00 2001 From: Sheetal Date: Sat, 3 Oct 2020 22:54:52 +0530 Subject: [PATCH 6/9] Create linear_search_recursion.py --- .../src/linear_search_recursion.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Arrays-searching/src/linear_search_recursion.py diff --git a/Arrays-searching/src/linear_search_recursion.py b/Arrays-searching/src/linear_search_recursion.py new file mode 100644 index 00000000..238aeb5a --- /dev/null +++ b/Arrays-searching/src/linear_search_recursion.py @@ -0,0 +1,19 @@ +# Recursive function to search x in arr[l..r] +def rec_search( arr, l, r, x): + if r < l: + return -1 + if arr[l] == x: + return l + if arr[r] == x: + return r + return rec_search(arr, l+1, r-1, x) + +# Main Code +arr = [12, 34, 54, 2, 3] +n = len(arr) +x = 3 +index = rec_search(arr, 0, n-1, x) +if index != -1: + print "Element", x,"is present at index %d" %(index) +else: + print "Element %d is not present" %(x) From 27395b62eebfe26d5eb951f365db1021a5702bdc Mon Sep 17 00:00:00 2001 From: Sheetal Date: Sun, 4 Oct 2020 23:28:26 +0530 Subject: [PATCH 7/9] Update oddEvenSort.py --- Arrays-Sorting/src/oddEvenSort.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Arrays-Sorting/src/oddEvenSort.py b/Arrays-Sorting/src/oddEvenSort.py index e8ccbbca..843e8927 100644 --- a/Arrays-Sorting/src/oddEvenSort.py +++ b/Arrays-Sorting/src/oddEvenSort.py @@ -1,5 +1,8 @@ #Python Program to implement Odd-Even / Brick Sort +#A python program to implement odd-even sorting or Brick Sort. +#It is a kind of bubble sort since it is divided into two phases, +#i.e. odd phase & even phase and bubble sort is implemented on each of the phases. def oddEvenSort(arr, n): isSorted = 0 while isSorted == 0: @@ -22,4 +25,4 @@ def oddEvenSort(arr, n): oddEvenSort(arr, n); for i in range(0, n): - print(arr[i], end = ' ') \ No newline at end of file + print(arr[i], end = ' ') From ef43bf9206655842f54db584f1e7f2693ede950b Mon Sep 17 00:00:00 2001 From: Sheetal Date: Sun, 4 Oct 2020 23:29:42 +0530 Subject: [PATCH 8/9] Update linear_search_recursion.py --- Arrays-searching/src/linear_search_recursion.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Arrays-searching/src/linear_search_recursion.py b/Arrays-searching/src/linear_search_recursion.py index 238aeb5a..08ea42d4 100644 --- a/Arrays-searching/src/linear_search_recursion.py +++ b/Arrays-searching/src/linear_search_recursion.py @@ -1,4 +1,6 @@ -# Recursive function to search x in arr[l..r] +# Recursive function to search x in arr[l..r] +# Another python program to search an element linearly in an array using Recursion (Read again 💯 ) +#Why recursion? Because it makes the task easier and reduces time complexity. def rec_search( arr, l, r, x): if r < l: return -1 From 2139485d50db75e7d904c063f44786af8f9629c5 Mon Sep 17 00:00:00 2001 From: Sheetal Date: Sun, 4 Oct 2020 23:31:28 +0530 Subject: [PATCH 9/9] Update circular_linked_list.py --- Data_Structure/src/Linked Lists/circular_linked_list.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Data_Structure/src/Linked Lists/circular_linked_list.py b/Data_Structure/src/Linked Lists/circular_linked_list.py index ed9792ab..abbd7739 100644 --- a/Data_Structure/src/Linked Lists/circular_linked_list.py +++ b/Data_Structure/src/Linked Lists/circular_linked_list.py @@ -1,3 +1,10 @@ +#Another python program to implement and Insert a node by taking an pointer pointing to locations one want to insert a node to. +#The insertion operations are carried out: +#a. in empty linked list +#b. at beginning of the linked list +#c. at end of the linked list +#d. in between the nodes + class Node: def init(self, data): @@ -134,4 +141,4 @@ def traverse(self): last = llist.addAfter(10,8) - llist.traverse() \ No newline at end of file + llist.traverse()