2) X With the help of an example, explain the following: i) Algorithm. ii) iii) Running time of an algorithm. b) Using Fig. 7.1 in page 147 (page 172 in the third edition) of the book as the model, illustrate the operation of PARTITION on the array A = {3, 10, 8, 5, 12,9,6, 13, 4, 2,7} Input and output for an algorithm.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
i pj
(a)
2 8713 5 6 4
p,i j
(b)
28713 564
p.i
(c)
7|1
3 |5|64
p.i
(d)
8.
1|356 4
pi
(e)
2 178 3 564
P
(f)
1
38|75| 64
(g)
2 |1|387|564
i
(h)
2 138756 4
i
(i)
2 13 47 56 8
Figure 7.1 The operation of PARTITION Oon a sample aray. Array entry A[r] becomes the pivot
element x. Lightly shaded aray elements are all in the first partition with values no greater than x.
Heavily shaded elements are in the second partition with values greater than x. The unshaded el-
ements have not yet been put in one of the first two partitions, and the final white element is the
pivot x. (a) The initial array and variable settings. None of the elements have been placed in either
of the firsttwo partitions. (b) The value 2 is “swapped with itself" and put in the partition of smaller
val ues. (c)-(d) The values 8 and 7 are added to the partition of larger values. (e) The values 1 and 8
are swapped, and the smaller partition grows. () The values 3 and 7 are swapped, and the smaller
partition grows. (g)-(h) The larger partition grows to include 5 and 6, and the loop terminates. (i) In
lines 7-8, the pivot element is swapped so that it lies between the two partitions.
Transcribed Image Text:i pj (a) 2 8713 5 6 4 p,i j (b) 28713 564 p.i (c) 7|1 3 |5|64 p.i (d) 8. 1|356 4 pi (e) 2 178 3 564 P (f) 1 38|75| 64 (g) 2 |1|387|564 i (h) 2 138756 4 i (i) 2 13 47 56 8 Figure 7.1 The operation of PARTITION Oon a sample aray. Array entry A[r] becomes the pivot element x. Lightly shaded aray elements are all in the first partition with values no greater than x. Heavily shaded elements are in the second partition with values greater than x. The unshaded el- ements have not yet been put in one of the first two partitions, and the final white element is the pivot x. (a) The initial array and variable settings. None of the elements have been placed in either of the firsttwo partitions. (b) The value 2 is “swapped with itself" and put in the partition of smaller val ues. (c)-(d) The values 8 and 7 are added to the partition of larger values. (e) The values 1 and 8 are swapped, and the smaller partition grows. () The values 3 and 7 are swapped, and the smaller partition grows. (g)-(h) The larger partition grows to include 5 and 6, and the loop terminates. (i) In lines 7-8, the pivot element is swapped so that it lies between the two partitions.
2) X
With the help of an example, explain the following:
i)
Algorithm.
ii) Input and output for an algorithm.
iii) Running time of an algorithm.
b) Using Fig. 7.1 in page 147 (page 172 in the third edition) of the book as the model, illustrate the
operation of PARTITION on the array A =
{3,10,8,5, 12,9,6, 13,4, 2,7}
Transcribed Image Text:2) X With the help of an example, explain the following: i) Algorithm. ii) Input and output for an algorithm. iii) Running time of an algorithm. b) Using Fig. 7.1 in page 147 (page 172 in the third edition) of the book as the model, illustrate the operation of PARTITION on the array A = {3,10,8,5, 12,9,6, 13,4, 2,7}
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Mergesort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education