Computer Science: An Overview (12th Edition)
Computer Science: An Overview (12th Edition)
12th Edition
ISBN: 9780133760064
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
Question
Book Icon
Chapter 5.4, Problem 6QE
Program Plan Intro

Insertion sort algorithm:

The algorithm is basically designed to organize and sort the array or list of elements in specific manner, that enables the system and user to get the final sorted array or a list of elements.

Generally, it prepares a new array or list and then starts inserting elements in its appropriate position by following specific manner in this new list. This new list is known as sorted list.

Example:

  1. 1. Developing a phonebook contact list by sorting the names alphabetically.
  2. 2. Sorting a list of integers numerically, etc.

Selection sort:

It is a simple sorting algorithm which basically specifies the manner in which a list or array should be sorted. Generally, each time it finds the minimum elements from the unsorted array and then positions them in an appropriate form or ascending order.

Each time after finding the minimum or smallest element it swaps the element with the leftmost element.

Blurred answer
Students have asked these similar questions
slecetion sort (python) Selection sort is a sorting algorithm, like Bubble sort which you saw in the previous module. Selection sort works as follows: Selection sort divides the input list into two parts: a sublist of sorted items (left part) and a sublist of still unsorted items (right part). Initially, the sorted sublist is empty and the whole input consists of the unsorted sublist. To fill the sorted sublist, the algorithm computes the (index of) the minimum of the unsorted sublist and swaps the first unsorted element and the minimum element (if the minimum is already the first element, nothing happens). Afterward, the sorted sublist is one bigger. This continues until the unsorted sublist is empty and the entire input is sorted. Example: Sorted sublist Unsorted sublist Least element in unsorted list () (11, 25, 12, 22, 64) 11 (11) (25, 12, 22, 64) 12 (11, 12) (25, 22, 64) 22 (11, 12, 22) (25, 64) 25 (11, 12, 22, 25) (64) 64 (11, 12, 22, 25, 64) ()   Implement this…
Instead of reading in an entire list N1,N2,⋯N1​,N2,⋯​ all at once, some algorithms (depending on the task to be done) can read in only one element at a time and process that single element completely before inputting the next one. This can be a useful technique when the list is very big (e.g., billions of elements) and there might not be enough memory in the computer to store it in its entirety. Write an algorithm that reads in a sequence of values v≥0, one at a time, and computes the average of all the numbers. You should stop the computation when you input a value of V = −1. Do not include this negative value in your computations; it is not a piece of data but only a marker to identify the end of the list. Write a java program and please share the code / an example of the code working.
Write a version of the sequential search algorithm that can be used to search a sorted list. Write a program to test the sequential search algorithm. Use either the function bubbleSort or insertionSort to sort the list before the search. Your program should prompt the user to enter 10 digits and then prompt the user to enter a digit to search - if the list contains this digit, output its position to the console: x is found at position y If the digit is not contained in the list, output the following: x is not in the list

Chapter 5 Solutions

Computer Science: An Overview (12th Edition)

Ch. 5.3 - Prob. 4QECh. 5.4 - Modify the sequential search function in Figure...Ch. 5.4 - Prob. 2QECh. 5.4 - Some of the popular programming languages today...Ch. 5.4 - Suppose the insertion sort as presented in Figure...Ch. 5.4 - Prob. 5QECh. 5.4 - Prob. 6QECh. 5.4 - Prob. 7QECh. 5.5 - What names are interrogated by the binary search...Ch. 5.5 - Prob. 2QECh. 5.5 - What sequence of numbers would be printed by the...Ch. 5.5 - What is the termination condition in the recursive...Ch. 5.6 - Prob. 1QECh. 5.6 - Give an example of an algorithm in each of the...Ch. 5.6 - List the classes (n2), (log2n), (n), and (n3) in...Ch. 5.6 - Prob. 4QECh. 5.6 - Prob. 5QECh. 5.6 - Prob. 6QECh. 5.6 - Prob. 7QECh. 5.6 - Suppose that both a program and the hardware that...Ch. 5 - Prob. 1CRPCh. 5 - Prob. 2CRPCh. 5 - Prob. 3CRPCh. 5 - Select a subject with which you are familiar and...Ch. 5 - Does the following program represent an algorithm...Ch. 5 - Prob. 6CRPCh. 5 - Prob. 7CRPCh. 5 - Prob. 8CRPCh. 5 - What must be done to translate a posttest loop...Ch. 5 - Design an algorithm that when given an arrangement...Ch. 5 - Prob. 11CRPCh. 5 - Design an algorithm for determining the day of the...Ch. 5 - What is the difference between a formal...Ch. 5 - Prob. 14CRPCh. 5 - Prob. 15CRPCh. 5 - The following is a multiplication problem in...Ch. 5 - Prob. 17CRPCh. 5 - Four prospectors with only one lantern must walk...Ch. 5 - Starting with a large wine glass and a small wine...Ch. 5 - Two bees, named Romeo and Juliet, live in...Ch. 5 - What letters are interrogated by the binary search...Ch. 5 - The following algorithm is designed to print the...Ch. 5 - What sequence of numbers is printed by the...Ch. 5 - Prob. 24CRPCh. 5 - What letters are interrogated by the binary search...Ch. 5 - Prob. 26CRPCh. 5 - Identity the termination condition in each of the...Ch. 5 - Identity the body of the following loop structure...Ch. 5 - Prob. 29CRPCh. 5 - Design a recursive version of the Euclidean...Ch. 5 - Prob. 31CRPCh. 5 - Identify the important constituents of the control...Ch. 5 - Identify the termination condition in the...Ch. 5 - Call the function MysteryPrint (defined below)...Ch. 5 - Prob. 35CRPCh. 5 - Prob. 36CRPCh. 5 - Prob. 37CRPCh. 5 - The factorial of 0 is defined to be 1. The...Ch. 5 - a. Suppose you must sort a list of five names, and...Ch. 5 - The puzzle called the Towers of Hanoi consists of...Ch. 5 - Prob. 41CRPCh. 5 - Develop two algorithms, one based on a loop...Ch. 5 - Design an algorithm to find the square root of a...Ch. 5 - Prob. 44CRPCh. 5 - Prob. 45CRPCh. 5 - Design an algorithm that, given a list of five or...Ch. 5 - Prob. 47CRPCh. 5 - Prob. 48CRPCh. 5 - Prob. 49CRPCh. 5 - Prob. 50CRPCh. 5 - Prob. 51CRPCh. 5 - Does the loop in the following routine terminate?...Ch. 5 - Prob. 53CRPCh. 5 - Prob. 54CRPCh. 5 - The following program segment is designed to find...Ch. 5 - a. Identity the preconditions for the sequential...Ch. 5 - Prob. 57CRPCh. 5 - Prob. 1SICh. 5 - Prob. 2SICh. 5 - Prob. 3SICh. 5 - Prob. 4SICh. 5 - Prob. 5SICh. 5 - Is it ethical to design an algorithm for...Ch. 5 - Prob. 7SICh. 5 - Prob. 8SI
Knowledge Booster
Background pattern image
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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT