Starting Out With C++: Early Objects (10th Edition)
Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
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
Coding language: C++. (Try to avoid linked lists if possible please). Add comments. Thanks. • Each functionality component must be implemented as a separate function, though the function does not need to be declared and defined separately • No global variables are allowed • No separate.hor.hpp are allowed • You may not use any of the hash tables, or hashing functions provided by the STL or Boost library to implement your hash table • Appropriate, informative messages must be provided for prompts and outputs You must implement a hash table using the Double Hashing collision strategy and the mid-square base 10 hashing function with an R of 2. Your collision strategy must be implemented as a separate function, though it may be implemented inside your insert/search/delete functions, and should halt an insert / search/delete functions, and should halt an insert/search/delete after table size number of collisions. Your hash function must be implemented as a separate function. Your hash table…
C language. Function write the arraylist_sort function This generic function sorts an array list using the given compare function. l An array list compare Pointer to the function which compares two elements If you cannot write down a generic function which works for all types, write down a function which sorts resturants. If you cannot use function pointers, you can write down multiple functions which sort using different criteria.
Topical Information Use C++. The purpose of this project is to test your ability to use templates, dynamic memory (mixed with classes), operator overloading, and libraries effectively in program design. Program Information Create a template class for a dynamic 1D array. You can model your class off of our String class or the dynamic list class. Changes from String class: You won't need an end-of-string element in the array. The element type is now templated. Translation will no longer be necessary. operators - and -= 'might' now make sense (erase element(s)?). ... Show how useful your template array class is by creating arrays of short integers doubles String class objects (static) Point class objects pointers to Point class objects (each allocated on the heap) — all in one test application. Make sure your test application is a good/thorough test of your class. (Your test application might utilize the applyand accumulatefunctions from lecture to facilitate testing. Also note how a…
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++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr