Natural Approach, 11th Edition by
Paul J. Deitel
Complete Chapter Solutions Manual
are included (Ch 1 to 21)
** Immediate Download
** Swift Response
** All Chapters included
,Table of Contents are given below
1.Intro: Test-Driving Popular, Free C++ Software
2.Intro to C++ 20 Programming
3.Control Statements: Part 1
4.Control Statements: Part 2
5.Functions and an Intro to Function Templates
6.arrays, vectors, Ranges and Functional-Style Programming
7.(Downplaying) Pointers in Modern C++
8.strings, string_views, Text files, CSV Files and Regex
9.Custom Classes
10.OOP: Inheritance and Runtime Polymorphism
11.Operator Overloading, Copy/Move Semantics, Smart Pointers and RAII
12.Exceptions and a Look Forward to Contracts
13.Standard Library Containers and Iterators
14.Standard Library Algorithms and C++ 20 Ranges and Views
15.Templates, C++ 20 Concepts and Metaprogramming
16.C++ 20 Modules: Large-Scale Development
17.Parallel Algorithms and Concurrency: A High-Level View
18.C++ 20 Coroutines
19.Stream I/O and C++ 20 Text Formatting
20.Other Topics and a Look Toward C++ 23 and C++ 26
21.Computer Science Thinking: Searching, Sorting and Big O
,Solutions Manual organized in reverse order, with the last chapter displayed first, to ensure that all
chapters are included in this document. (Complete Chapters included Ch21-1)
Computer Science Thinking:
Searching, Sorting and Big O 21
Objectives
In this chapter, you’ll:
◼ Use Big O notation to express
the efficiency of searching and
sorting algorithms and to
compare their performance.
◼ Search for a given value in an
array using linear search and
binary search.
◼ Sort an array using insertion
sort, selection sort and the
recursive merge sort
algorithms.
◼ Understand the nature of
algorithms of constant, linear
and quadratic runtime.
, 2 Chapter 21 Computer Science Thinking: Searching, Sorting and Big O
Instructor note: This file contains the solutions to the short answer questions only. The
solutions to the code exercises are located in the ch21solutions folder.
Exercises
21.1 Fill in the blanks in each of the following statements:
a) A selection sort application would take approximately times as long
to run on a 128-element array as on a 32-element array.
Answer: 16, because an O(n2) algorithm takes 16 times as long to sort four times
as much information.
b) The efficiency of merge sort is .
Answer: O(n log n).
21.2 What key aspect of both the binary search and the merge sort accounts for the log-
arithmic portion of their respective Big Os?
Answer: Both of these algorithms incorporate “halving”—somehow reducing
something by half. The binary search eliminates from consideration half of the
array after each comparison. The merge sort splits the array in half each time it’s
called.
21.3 In what sense is the insertion sort superior to the merge sort? In what sense is the
merge sort superior to the insertion sort?
Answer: The insertion sort is easier to understand and to implement than the
merge sort. The merge sort is far more efficient (O(n log n)) than the insertion
sort (O(n2)).
21.4 In the text, we say that after the merge sort splits the array into two sub-arrays, it
then sorts these two sub-arrays and merges them. Why might someone be puzzled by
our statement that “it then sorts these two sub-arrays”?
Answer: In a sense, it does not really sort these two sub-arrays. It simply keeps
splitting the original array in half until it provides a one-element sub-array,
which is, of course, sorted. It then builds up the original two sub-arrays by
merging these one-element arrays to form larger sub-arrays, which are then
merged, and so on.
© Copyright 1992-2023 by Pearson Education, Inc. All Rights Reserved.