Skip to content

Instantly share code, notes, and snippets.

View mahendrarathore1742's full-sized avatar
:octocat:

Mahendra Singh Rathore mahendrarathore1742

:octocat:
  • india
  • 08:37 (UTC +05:30)
View GitHub Profile
def middleinsert(self,mid,newnode):
Newnode=node(newnode);
Newnode.next=mid.next;
mid.next=Newnode
obj.middleinsert(obj.head.next,int(input('enter the item in middle in list==')));
obj.display()
def insertnode(self,newnode):
Newnode=node(newnode);
Newnode.next=self.head;
self.head=Newnode;
obj.insertnode(int(input('enter the item==')));
@mahendrarathore1742
mahendrarathore1742 / singly Linklist
Created October 28, 2019 10:12
singly Linklist
@mahendrarathore1742
mahendrarathore1742 / python
Last active November 7, 2019 04:03
Binary Search in python
pos=-1;
def binary_search(arr,n):
l=0;
r=len(arr);
while l<=r:
mid=(l+r)//2;
if arr[mid]==n:
def LinearSearch(arr,x,n):
for i in range(n):
if arr[i]==x:
return i;
return -1;
arr=[5,3,9,34,56,77];
x=56;
n=len(arr);
obj=LinearSearch(arr,x,n);
if obj==-1: