class merge: global a a=[] global b b=[] global link link=[] def ins1(self): print "enter no of elements" p=input() print "enter the numbers" i=0 while i<p: c=input() a.append(c) i=i+1 print "the given array is" while i<p: print a[i] i=i+1 while i<p-1: j=0 while j<p-i-1: if a[j]>a[j+1]: swap=a[j] a[j]=a[j+1] a[j+1]=swap j=j+1 i=i+1 print "the sorted array is" j=0 while j<p: print a[j] j=j+1 def ins2(self): print "enter no of elements" q=input() print "enter the numbers" x=0 while x<q: d=input() a.append(d) x=x+1 print "the given array is" while x<q: print a[x] x=x+1 while x<q-1: e=0 while e<q-x-1: if a[e]>a[e+1]: swap=a[e] a[e]=a[e+1] a[e+1]=swap e=e+1 x=x+1 print "the sorted array is" e=0 while e<q: print a[e] e=e+1 def lost(self,p,q,a,b): l1,l2,last=0,0,0 l,s1=1,1 s2=l2 while l1!=0 and l2!=0: if a[l1]<a[l2]: link[last]=l1 last=l1 l1=link[l1] else : link[last]=l2 last=l2 l2=link[l2] if l1==0: link[last]=l2 else: link[last]=l1 def display(self,p,q): last=0 print "the merge sorted array is" while last<p+q: print link[last] last=last+1 w=merge() w.ins1() w.ins2() w.lost(4,2,4,2) w.display(4,2)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question