Free Essay

Quick Sort Algorithm

In:

Submitted By owatheowais
Words 1243
Pages 5
7.6.5

Quick Sort

Implementation
Next, recall that our goal is to partition all remaining elements based on whether they are smaller than or greater than the pivot We will find two entries:
– One larger than the pivot (staring from the front) – One smaller than the pivot (starting from the back)

which are out of order and then correct the ordering
– I.e., swap them

1

7.6.5

Quick Sort

Implementation
Continue doing so until the appropriate entries you find are actually in order The index to the larger entry we found would be the first large entry in the list (as seen from the left) Therefore, we could move this entry into the last entry of the list We can fill this spot with the pivot

2

7.6.5

Quick Sort

Quick Sort Example
First, we examine the first, middle, and last entries of the full list The span below will indicate which list we are currently sorting

3

7.6.5

Quick Sort

Quick Sort Example
We select 57 to be our pivot
– We move 24 into the first location

4

7.6.5

Quick Sort

Quick Sort Example
Starting at the 2nd and 2nd-last locations:
– we search forward until we find 70 > 57 – we search backward until we find 49 < 57

5

7.6.5

Quick Sort

Quick Sort Example
We swap 70 and 49, placing them in order with respect to eachother

6

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 97 > 57 We search backward until we find 16 < 57

7

7.6.5

Quick Sort

Quick Sort Example
We swap 16 and 97 which are now in order with respect to each other

8

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 63 > 57 We search backward until we find 55 < 57

9

7.6.5

Quick Sort

Quick Sort Example
We swap 63 and 55

10

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 85 > 57 We search backward until we find 36 < 57

11

7.6.5

Quick Sort

Quick Sort Example
We swap 85 and 36, placing them in order with respect to each other

12

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 68 > 57 We search backward until we find 9 < 57

13

7.6.5

Quick Sort

Quick Sort Example
We swap 68 and 9

14

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 76 > 57 We search backward until we find 9 < 57
– The indices are out of order, so we stop

15

7.6.5

Quick Sort

Quick Sort Example
We move the larger indexed item to the vacancy at the end of the array We fill the empty location with the pivot, 57 The pivot is now in the correct location

16

7.6.5

Quick Sort

Quick Sort Example
We will now recursively call quick sort on the first half of the list When we are finished, all entries < 57 will be sorted

17

7.6.5

Quick Sort

Quick Sort Example
We examine the first, middle, and last elements of this sub list

18

7.6.5

Quick Sort

Quick Sort Example
We choose 24 to be our pivot We move 9 into the first location in this sub-list

19

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 49 > 24 We search backward until we find 21 < 24

20

7.6.5

Quick Sort

Quick Sort Example
We swap 49 and 21, placing them in order with respect to eachother

21

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 38 > 24 We search backward until we find 16 < 24 The indices are reversed, so we stop

22

7.6.5

Quick Sort

Quick Sort Example
We move 38 to the vacant location and move the pivot 24 into the location previously occupied by 38
– 24 is now in the correct location

23

7.6.5

Quick Sort

Quick Sort Example
We will now recursively call quick sort on the left and right halves of those entries which are < 57

24

7.6.5

Quick Sort

Quick Sort Example
The first partition has three entries, so we sort it using insertion sort

25

7.6.5

Quick Sort

Quick Sort Example
The second partition also has only four entries, so again, we use insertion sort

26

7.6.5

Quick Sort

Quick Sort Example
First we examine the first, middle, and last entries of the sub-list

27

7.6.5

Quick Sort

Quick Sort Example
We choose 74 to be our pivot We move 76 to the vacancy left by 74

28

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 81 > 74 We search backward until we find 70 < 74

29

7.6.5

Quick Sort

Quick Sort Example
We swap 70 and 84 placing them in order

30

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 85 > 74 We search backward until we find 61 < 74

31

7.6.5

Quick Sort

Quick Sort Example
We swap 85 and 61 placing them in order

32

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 79 > 74 We search backward until we find 63 < 74 The indices are reversed, so we stop

33

7.6.5

Quick Sort

Quick Sort Example
We move 79 to the vacant location and move the pivot 74 into the location previously occupied by 79 74 is now in the correct location

34

7.6.5

Quick Sort

Quick Sort Example
We sort the left sub-list first It has four elements, so we simply use insertion sort

35

7.6.5

Quick Sort

Quick Sort Example
Having sorted the four elements, we focus on the remaining sub-list of seven entries

36

7.6.5

Quick Sort

Quick Sort Example
To sort the next sub-list, we examine the first, middle, and last entries

37

7.6.5

Quick Sort

Quick Sort Example
We select 79 as our pivot and move:
– 76 into the lowest position – 85 into the highest position

38

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 85 > 79 We search backward until we find 77 < 79

39

7.6.5

Quick Sort

Quick Sort Example
We swap 85 and 77, placing them in order

40

7.6.5

Quick Sort

Quick Sort Example
We search forward until we find 97 > 79 We search backward until we find 77 < 79 The indices are reversed, so we stop

41

7.6.5

Quick Sort

Quick Sort Example
Finally, we move 97 to the vacant location and copy 79 into the appropriate location
– 79 is now in the correct location

42

7.6.5

Quick Sort

Quick Sort Example
This splits the sub-list into two sub-lists of size 2 and 4 We use insertion sort for the first sub-list

43

7.6.5

Quick Sort

Quick Sort Example
We are left with one sub-list with four entries, so again, we use insertion sort

44

7.6.5

Quick Sort

Quick Sort Example
Sorting the last sub-list, we arrive at an ordered list

45

Similar Documents

Premium Essay

Comparative Analysis Of Sorting Algorithm

...COMPARATIVE ANALYSIS OF VARIOUS SORTING ALGORITHM ABSTRACT: Sorting is a commonly used operation in computer science. In addition to its main job, sorting is often required to facilitate some other operation such as searching, merging and normalization. A sorting algorithm consists of comparison, swap, and assignment operations. There are several elementary and advanced sorting algorithms that are being used in practical life as well as in computation such as Quick sort, Bubble sort, Merge sort, Bucket sort, Heap sort, Radix sort etc. But the application of these algorithms depends on the problem statement. This paper introduces MQ sort which combines the advantages of quick sort and Merge sort. The comparative analysis of performance and complexity...

Words: 2578 - Pages: 11

Premium Essay

Sort

...Computer Simulation Clump Sort: A Stable Alternative To Heap Sort For Sorting Medical Data Visvasuresh Victor Govindaswamy Matthew Caudill Jeff Wilson Computer Science Texas A&M University-Texarkana Texarkana, USA lovebat814@yahoo.com Computer Science Texas A&M University-Texarkana Texarkana, USA Computer Science Texas A&M University-Texarkana Texarkana, USA Daniel Brower G. Balasekaran, FACSM Computer Science Texas A&M University-Texarkana Texarkana, USA Medical and Sports Science Nanyang Technology University Singapore Abstract—Sorting data sets are a thoroughly researched field. Several sorting algorithms have been introduced and these include Bubble, Insertion, Selection, Shell, Quick, Merge and Heap. In this paper, we present a novel sorting algorithm, named Clump Sort, to take advantage of ordered segments already present in medical data sets. It succeeds in sorting the medical data considerably better than all the sorts except when using totally non-clumped data. In this test using totally nonclumped data, Heap sort does only slightly better than Clump sort. However, Clump sort has the advantage of being a stable sort as the original order of equal elements is preserved whereas in Heap sort, it is not since it does not guarantee that equal elements will appear in their original order after sorting. As such, Clump Sort will have considerably better data cache performance with both clumped and non-clumped data, outperforming Heap Sort on a modern desktop PC, because...

Words: 1753 - Pages: 8

Premium Essay

Clump Sort

...Computer Simulation Clump Sort: A Stable Alternative To Heap Sort For Sorting Medical Data Visvasuresh Victor Govindaswamy Computer Science Texas A&M University-Texarkana Texarkana, USA lovebat814@yahoo.com Matthew Caudill Computer Science Texas A&M University-Texarkana Texarkana, USA Jeff Wilson Computer Science Texas A&M University-Texarkana Texarkana, USA Daniel Brower Computer Science Texas A&M University-Texarkana Texarkana, USA G. Balasekaran, FACSM Medical and Sports Science Nanyang Technology University Singapore Abstract—Sorting data sets are a thoroughly researched field. Several sorting algorithms have been introduced and these include Bubble, Insertion, Selection, Shell, Quick, Merge and Heap. In this paper, we present a novel sorting algorithm, named Clump Sort, to take advantage of ordered segments already present in medical data sets. It succeeds in sorting the medical data considerably better than all the sorts except when using totally non-clumped data. In this test using totally nonclumped data, Heap sort does only slightly better than Clump sort. However, Clump sort has the advantage of being a stable sort as the original order of equal elements is preserved whereas in Heap sort, it is not since it does not guarantee that equal elements will appear in their original order after sorting. As such, Clump Sort will have considerably better data cache performance with both clumped and non-clumped data, outperforming Heap Sort on a modern desktop PC...

Words: 1753 - Pages: 8

Premium Essay

Nt1330 Unit 1 Assignment

...1 - Algorithms Describe the key characteristics and roles of Algorithms Programs and Informal instructions The key characteristics of algorithms are, precision, finiteness, effectiveness, input and output. Precision mean that the algorithm needs to be clear and precisely defined so that a computer can follow the steps. Finiteness means that the algorithm has to finish. The algorithm needs to stop after it has executed all the steps set. Effectiveness means that the algorithm needs to be effective, such as that the algorithm can be done to its precise steps and done in a finite length of time, computer programming language independent. Input means that the algorithm has zero or more...

Words: 1521 - Pages: 7

Free Essay

Sorting Algorithms

...REVIEW ON SORTING ALGORITHMS A comparative study on two sorting algorithms By Pooja Adhikari A Term Paper Submitted to the Faculty of Dr. Gene Boggess Mississippi State University In the Department of Computer Science & Engineering Mississippi State, Mississippi 04 20072 ABSTRACT Any number of practical applications in computing requires things to be in order. The performance of any computation depends upon the performance of sorting algorithms. Like all complicated problems, there are many solutions that can achieve the same results. One sort algorithm can do sorting of data faster than another. A lot of sorting algorithms has been developed to enhance the performance in terms of computational complexity, memory and other factors. This paper choose two of the sorting algorithms among them selection sort and shell sort and compares the various performance factor among them. 1. INTRODUCTION Sorting is the rearrangement of things in a list into their correct lexicographic order. A number of sorting algorithms have been developed like include heap sort , merge sort, quick sort, selection sort all of which are comparison based sort .There is another class of sorting algorithms which are non comparison based sort. This paper gives the brief introduction about sorting algorithms [2] where it discuss about the class of sorting algorithms and their running times. It mainly analyses the performance between two...

Words: 841 - Pages: 4

Free Essay

Reserch Paper on Sorting and Dictionaries

...lists are two basic data structures used to store information. We may wish to search, insert or delete records in a database based on a key value. This section examines the performance of these operations on arrays and linked lists. In this research paper we studied about the sorting and types of sorting. This is followed by techniques for implementing dictionaries, structures that allow efficient search, insert, and delete operations. We have also illustrated algorithms that sort data and implement dictionaries for very large files Keywords-insertion sort, quick sort, sort ,binary search tree, skip list. 1. Introduction Arrays and linked lists are two basic data structures used to store information. We may wish to search, insert or delete records in a database based on a key value. This section examines the performance of these operations on arrays and linked lists. 1.1 Arrays Figure 1-1 shows an array, seven elements long, containing numeric values. To search the array sequentially, we may use the algorithm in Figure 1-2. The maximum number of comparisons is 7, and occurs when the key we are searching for is in A[6]. Figure 1-1: An Array int function SequentialSearch(Array A , int Lb, int Ub, int Key ); begin for i= Lbto Ub do if A [ i ]= Key then return i ; return –1; end; | Figure 1-2: Sequential Search If the data is sorted,...

Words: 2248 - Pages: 9

Free Essay

Programming

...TeamLRN Robert Lafore Teach Yourself Data Structures and Algorithms in 24 Hours 201 West 103rd St., Indianapolis, Indiana, 46290 USA Sams Teach Yourself Data Structures and Algorithms in 24 Hours Copyright © 1999 by Sams Publishing All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. International Standard Book Number: 0-672-31633-1 Library of Congress Catalog Card Number: 98-83221 Printed in the United States of America First Printing: May 1999 01 00 99 4 3 2 1 EXECUTIVE EDITOR Brian Gill DEVELOPMENT EDITOR Jeff Durham MANAGING EDITOR Jodi Jensen PROJECT EDITOR Tonya Simpson COPY EDITOR Mike Henry INDEXER Larry Sweazy PROOFREADERS Mona Brown Jill Mazurczyk TECHNICAL EDITOR Richard Wright Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this...

Words: 10065 - Pages: 41

Free Essay

Quick Sort Analysis

...Here is an analysis of the time complexity of quick-sort in detail. In quick sort, we pick an element called the pivot in each step and re-arrange the array in such a way that all elements less than the pivot now appear to the left of the pivot, and all elements larger than the pivot appear on the right side of the pivot. In all subsequent iterations of the sorting algorithm, the position of this pivot will remain unchanged, because it has been put in its correct place. The total time taken to re-arrange the array as just described, is always O(n)1 , or αn where α is some constant [see footnote]. Let us suppose that the pivot we just chose has divided the array into two parts - one of size k and the other of size n − k. Notice that both these parts still need to be sorted. This gives us the following relation: T (n) = T (k) + T (n − k) + αn where T (n) refers to the time taken by the algorithm to sort n elements. WORST CASE ANALYSIS: Now consider the case, when the pivot happened to be the least element of the array, so that we had k = 1 and n − k = n − 1. In such a case, we have: T (n) = T (1) + T (n − 1) + αn Now let us analyse the time complexity of quick sort in such a case in detail by solving the recurrence as follows: T (n) = T (n − 1) + T (1) + αn = [T (n − 2) + T (1) + α(n − 1)] + T (1) + αn (Note: I have written T (n − 1) = T (1) + T (n − 2) + α(n − 1) by just substituting n − 1 instead of n. Note the implicit assumption that the pivot that was chosen divided the original...

Words: 1014 - Pages: 5

Free Essay

Systems

...Component 01 - Computing Principles | AS-Level (H046) | A-Level (H446) | 1 The characteristics of contemporary processors, input, output and storage devices | Structure and function of the processor | The Arithmetic and Logic Unit (ALU), Control Unit and registers: Program Counter (PC), Accumulator (ACC), Memory Address Register (MAR), Memory Data Register (MDR), Current Instruction Register (CIR).Buses: data, address and control: How this relates to assembly language programs.The fetch-decode-execute cycle, including its effect on registers.The factors affecting the performance of the CPU, clock speed, number of cores, cache.Von Neumann, Harvard and contemporary processor architecture. | The use of pipelining in a processor to improve efficiency. | Types of processor | The differences between, and uses of, CISC and RISC processors.Multicore and parallel systems. | GPUs and their uses (including those not related to graphics). | Input, output and storage | How different input output and storage devices can be applied as a solution of different problems.The uses of magnetic, flash and optical storage devices.RAM and ROM.Virtual storage. | | 2 Software and software development | Operating systems | The need for, function and purpose of operating systems.Memory management (paging, segmentation and virtual memory).Interrupts, the role of interrupts and Interrupt Service Routines (ISR), role within the fetch decode execute cycle.Scheduling: round robin, first come...

Words: 1302 - Pages: 6

Free Essay

Sorting

...1. Use class Sort.java provided in class, the dual-pivot Quicksort of Java 8 (Arrays.sort), and RadixSort.java provided in class.  2. Do the following for Mergesort, Quicksort, Heapsort and dual-pivot Quicksort: a. Create 100,000 random keys (of type long) and sort them. Repeat this 100 times. b. Compute the average CPU time taken to sort the keys for the four methods. c. Comment on the results and compare them to the average-case complexities discussed in class.  As we discussed in the class, all these sorting algorithms I used for testing have the same average-case complexities with O (n log n). But the data I got which shows in the upper diagram illustrate that Quick sort is the most fast sorting method especially when you need to sort a large amount of data. Dual-pivot quicksort is also fast than merge sort and Heap sort. Heap sort can be used when the pending data between 1000-1000, 000, and for Merge sort is the first choice when there are more than 1M data. 3. Do the following for the four sorting methods of #2, and for Radix sort: a. Create 100,000 random strings of length 4 and sort them using the five sorting methods. b. Repeat (a) 10 times Compute the average CPU time taken to sort the keys for the five methods. c. Repeat (a) and (b) with strings of length 6, 8, 10. d. Create a table with the results and compare the times with the average-case and worstcase complexities as studied in class.  The length of string is 4: The length of string...

Words: 910 - Pages: 4

Free Essay

Data Structures

...Data Structures and Algorithms DSA Annotated Reference with Examples Granville Barne Luca Del Tongo Data Structures and Algorithms: Annotated Reference with Examples First Edition Copyright c Granville Barnett, and Luca Del Tongo 2008. This book is made exclusively available from DotNetSlackers (http://dotnetslackers.com/) the place for .NET articles, and news from some of the leading minds in the software industry. Contents 1 Introduction 1.1 What this book is, and what it isn’t . . . 1.2 Assumed knowledge . . . . . . . . . . . . 1.2.1 Big Oh notation . . . . . . . . . . 1.2.2 Imperative programming language 1.2.3 Object oriented concepts . . . . . 1.3 Pseudocode . . . . . . . . . . . . . . . . . 1.4 Tips for working through the examples . . 1.5 Book outline . . . . . . . . . . . . . . . . 1.6 Testing . . . . . . . . . . . . . . . . . . . 1.7 Where can I get the code? . . . . . . . . . 1.8 Final messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 1 1 3 4 4 6 6 7 7 7 I Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . reverse order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

Words: 23014 - Pages: 93

Free Essay

Data Structure

...DATA STRUCTURES ANALYSIS OF ALGORITHMS Definition:-           The method of solving a problem is known as an algorithm.It is a sequence of instructions that act on some input data to produce some output in a finite number of steps. Properties:- a) Input:An algorithm must receive some input data supplied externally. b)Output:An algorithm must produce atleast one output as the result. c)Finiteness:The algorithm must terminate after a finite number of steps. d)Definiteness:The steps to be performed in the algorithm must be clear and unambiguous. e)Effectiveness:One must be able to perform the steps in the algorithm without applying any intelligence.           All algorithms basically fall under two broad categories-Iterative and Recursive algorithms.           Iterative Algorithms typically use loops and conditional statements.           Recursive Algorithms use a divide and Conquer strategy. As per this,the recursive algorithm breaks down a large problem into small pieces and then applies the algorithm to each of these smal pieces. Determining which algorithm is efficient than the other involves analysis of algorithms. While analyzing,time required to execute it determined .’time’ represents the number of operations that are carried out while executing the algorithm.           While analyzing iterative algorithms we need to determine how many times the loop is executed. To analyze a recursive algorithm one needs to determine amount of work done for three things: ...

Words: 2466 - Pages: 10

Free Essay

Algorithms Notes

...3PART ONE * Lecture 1 (01/09) Posted on: Monday, January 28, 2013 Topics: Stable Matching Reading: class handout * Lecture 2 (01/14) Posted on: Thursday, January 24, 2013 Topics: Graph Representation, BFS, DFS Reading: CLRS (Sections 22.1, 22.2, 22.3), KT (3.2, 3.3) Notes: 2 possible representations of a graph 1. Adjacency Matrix-used for dense graphs (V2 memory space) a. Aij=1 if edge exists between I and J but 0 if not 2. Adjacency List- Used for sparse graphs (V+E memory space or V+2E for undirected) b. Array adj of |V| lists, one for each vertex. c. Adj[u] contains all vertices adjacent (or reachable by one edge) to u Breadth First Search(G,s) BFS.G; s/ 1 for each vertex u in G.V –{s} 2 u.color = WHITE 3 u.disc =∞ 4 u.parent= NIL 5 s.color = GRAY 6 s.disc = 0 7 s.parent= NIL 8 Q = ∅; 9 ENQUEUE(Q,s) 10 while Q ≠ ∅ 11 u = DEQUEUE(Q) 12 for each v in G.Adj[u] 13 if v.color == WHITE 14 v.color = GRAY 15 v.disc = u.disc + 1 16 v.parent = u 17 ENQUEUE(Q,v) 18 u.color = BLACK White means not discovered yet, grey mean discovered but not finished, black means finished. Run time O(V+E) BFS gives shortest path from s to every vertex Lemma: x in Li and Y in Lj and edge (x,y) exists Then |i-j| less than or equal to 1 Depth First search Properties: 1) v is a descendenant of u iff v if discovered when u is gray 2) Parenthesis theorem, u and v in V. either discovery and finish times are...

Words: 5019 - Pages: 21

Premium Essay

It- 3rd Year

...E-COMMERCE (TIT-501) UNIT I Introduction What is E-Commerce, Forces behind E-Commerce Industry Framework, Brief history of ECommerce, Inter Organizational E-Commerce Intra Organizational E-Commerce, and Consumer to Business Electronic Commerce, Architectural framework Network Infrastructure for E-Commerce Network Infrastructure for E-Commerce, Market forces behind I Way, Component of I way Access Equipment, Global Information Distribution Network, Broad band Telecommunication. UNIT-II Mobile Commerce Introduction to Mobile Commerce, Mobile Computing Application, Wireless Application Protocols, WAP Technology, Mobile Information Devices, Web Security Introduction to Web security, Firewalls & Transaction Security, Client Server Network, Emerging Client Server Security Threats, firewalls & Network Security. UNIT-III Encryption World Wide Web & Security, Encryption, Transaction security, Secret Key Encryption, Public Key Encryption, Virtual Private Network (VPM), Implementation Management Issues. UNIT - IV Electronic Payments Overview of Electronics payments, Digital Token based Electronics payment System, Smart Cards, Credit Card I Debit Card based EPS, Emerging financial Instruments, Home Banking, Online Banking. UNIT-V Net Commerce EDA, EDI Application in Business, Legal requirement in E -Commerce, Introduction to supply Chain Management, CRM, issues in Customer Relationship Management. References: 1. Greenstein and Feinman, “E-Commerce”, TMH 2. Ravi Kalakota, Andrew Whinston...

Words: 2913 - Pages: 12

Free Essay

Parallel Computing and Algorithms

...i SASTRA UNIVERSITY Shanmugha Arts, Science, Technology and Research Academy Thirumalaisamudram Thanjavur – 613 402 BCSCCS705 PARALLEL COMPUTING AND ALGORITHMS LAB B.TECH (COMPUTER SCIENCE AND ENGINEERING) 7TH SEMESTER ii List of Exercises: 1. Basic arithmetic operations in parallel 2. Find out factorial of a number 3. Generation of Fibonacci series, finding prime numbers in an interval. 4. Evaluate the integral of a function 5. Merging of two sorted lists 6. Parallel tree traversals 7. Matrix multiplication 8. Enumeration sort 9. Odd-Even transposition sort 10. Bitonic merge 11. Quick sort 12. Single source shortest path iii Exercise 1 Aim: Basic Arithmetic Operations in parallel To perform a set of arithmetic operations in parallel using a cluster of computers Procedure: Step 1: Identify a set of numbers over which arithmetic operations are to be done Step 2: Identify the rank in the cluster Step 3: Split the set of numbers into domains and assign each domain to their corresponding processor Step 4: Get the result from each computer in the cluster and assimilate them at the master Step 5: Verify the time taken for the completion of each task. Algorithm:function sum(+,identity,a) = if #a == 1 then [identity] else let e = even_elts(a); o = odd_elts(a); s = scan_op(op,identity,{op(e,o): e in e; o in o}) in interleave(s,{op(s,e): s in s; e in e}); iv Input:- An array of integers Output: - The sum 3,2,7,6 P1 18 0,5,4,8 P2 17 62 2,0,1,5 P3 8...

Words: 1116 - Pages: 5