Friday, April 15, 2016

Using Divide and Conquer Strategies to design an efficient class for Concurrent Quick Sort and the input data is stored using XML. Use object oriented software design method and Modelio. Perform the efficiency comparison with any two software design methods. Use necessary USE-CASE diagrams and justify its use with the help of mathematical modeling. Implement the design using Scala/Python/Java/C++.

File: q.py

import threading
import xml.etree.ElementTree as X
def part(arr,low,high):
p,i=arr[high],low
for j in range(low,high):
if arr[j]<=p:
arr[i],arr[j]=arr[j],arr[i]
i+=1
arr[i],arr[high]=arr[high],arr[i]
return i
def qsort(arr,low,high):
if low<high:
p=part(arr,low,high)
t1=threading.Thread(target=qsort,args=(arr,p+1,high))
t2=threading.Thread(target=qsort,args=(arr,low,p-1))
t1.start()
t2.start()
t1.join()
print t1.getName()
t2.join()
print t2.getName()
r=X.parse('input.xml').getroot()
arr=map(int,r.text.split())
qsort(arr,0,len(arr)-1)
for i in arr:
print i

File: input.xml

<sample> 2 45 12 90 34 11 115 3 </sample>

Output

[amodi@localhost Quicksort]$ python q.py
Thread-5
Thread-6
Thread-3
Thread-9
Thread-10
Thread-7
Thread-8
Thread-4
Thread-1
Thread-2
2
3
11
12
34
45
90
115

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. qsort(arr,0,len(arr)-1)
    TypeError: object of type 'map' has no len()

    ReplyDelete

Perform a suitable assignment using Xen Hypervisor or equivalent open source to configure it. Give necessary GUI.

 To install kvm on Fedora:  yum install kvm  yum install virt-manager libvirt libvirt-python python-virtinst  su -c "yum install @v...