STARTING OUT WITH C++ MPL
STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 14, Problem 3PC
Program Plan Intro

QuickSort template

Program Plan:

“main.cpp”

  • Include the required header files.
  • Define the main () function.
    • Declare and define the necessary variables using “for” loop.
    • Prompt and get “10” array elements from the user.
    • Call the method “quicksort ()” to perform the sort operation for the given elements.
    • The sorted values are being displayed to the user using “for” loop.

“Quicksort.h”

  • Define the necessary template function.
  • Define the method definition that compare and performs sort operation for the contents of the array using quick sort.
  • Define the  method “swapVars ()” with two arguments,
    • Assign the temporary variable and perform the necessary swap assignment statements as required.
  • Define the method “partition()” with three arguments,
    • Declare the necessary variables.
    • Calculate the “mid” value from the list of elements.
    • Call the function “swapVars ()” to perform necessary swap operations.
    • Use “for” loop to iterate and validate the values using “if” condition then perform the necessary swaps by calling the function “swapVars ()”.
    • Return the index of the pivot element.
  • Define the method “quicksort ()”,
    • Declare the variable named “pivotpt”.
    • Condition statement that compares the values present at the beginning and at the end.
    • Call the method “partition ()” to partition the list.
    • Call the method “quicksort ()” to sort the first and second sub lists.

Blurred answer
Students have asked these similar questions
Please original work select a topic related to architectures or infrastructures (Data Lakehouse Architecture). Discussing how you would implement your chosen topic in a data warehouse project Please cite in text references and add weblinks
Please original work What topic would be related to architectures or infrastructures. How you would implement your chosen topic in a data warehouse project. Please cite in text references and add weblinks
What is cloud computing and why do we use it? Give one of your friends with your answer.
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr