From 60802a1e008c7d8f2eb90e425a8a94da8223b4e8 Mon Sep 17 00:00:00 2001 From: shellygoyal15 <56556313+shellygoyal15@users.noreply.github.com> Date: Mon, 14 Oct 2019 22:28:29 +0530 Subject: [PATCH] function for the nodes and other task --- linearSearch.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/linearSearch.py b/linearSearch.py index 496a5ba..cd9c837 100644 --- a/linearSearch.py +++ b/linearSearch.py @@ -1,18 +1,25 @@ #!/usr/bin/python3 +class doubleLinklist: -def func(arr,n, x): - - for i in range(0,n): - if (arr[i] == x): - return i - return -1 + def __init__(self): + self.head = None + + def push(self, new_data): -arr =[1,2,3,5,6] + new_node = node(new_data) -x=10 + new_node.next = self.head + new_node.prev = None + + + if self.head is not None: + + self.head.prev = new_node + + self.head = new_node n = len(arr) result = func(arr, n,x)