C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
error_outline
This textbook solution is under construction.
Students have asked these similar questions
Consider the following list: 63, 45, 32, 98, 46, 57, 28, 100 Using the sequential search as described in this chapter, how many comparisons are required to find whether the following items are in the list? (Recall that by comparisons we mean item comparisons, not index comparisons.) a. 90 b. 57 c. 63 d. 120
Consider the following list:45, 78, 23, 12, 63, 90, 38, 56, 88, 15Using a sequential search, how many comparisons are required to determine whether the following items are in the list or not? (Recall that comparisons mean item comparisons, not index comparisons.) a. 90 b. 14 c. 45 d. 23 e. 5
Question 1
Sort the list E, X, A, M, P, L, E in alphabetical order by selection sort (refer to photo)
How many swaps are there in sorting the list of question 1.1.?
Sort the list E, X, A, M, P, L, E in alphabetical order by bubble sort (refer to slide 10 of chapter 3)
How many swaps are there in sorting the list in question 1.3.?
Briefly show the differences between the selection sort and bubble sort algorithms (in terms of principle, complexity etc.).
Knowledge Booster
Similar questions
- Define the term " ordered sequential search " .arrow_forwardA 17 (a) Sort the sequence 32, 11, 45, 11, 50, 97, 24, 63, 50 using quicksort (assume the pivot is always the first item in the sublist being sorted). At every step circle everything that will be a pivot on the next step and box all previous pivots. Associate your solution by referring the code given below. While referring. please use the line numbers. template void recQuickSort (elemType list [], int first, int last) int pivot Location: if (first < last) { pivot Location partition (list, first, last); recQuickSort (list, first, pivot Location - 1); recQuickSort (list, pivot Location + 1, last):arrow_forward11:55 Tasks BQपाट Question 1 Assume the following list of keys: 18, 81, 15, 48, 25, 55, 17, 85, 11, 28, 35 Your answer: This list is to be sorted using INSERTION sort as discussed in the class. Show the resulting list after three passes of the sorting phase- that is, after three iterations of the outer for loop. Next Open in Safari 15, 18, 48, 81, 25, 55, 17, 85, 11, 28, 35 15, 18, 81, 48, 25, 55, 17, 85, 11, 28, 35 O11, 15, 18, 81, 48, 25, 55, 17, 85, 24, 28, 35 O 11, 15, 18, 48, 81, 25, 55, 17, 85, 24, 28, 35 O 11, 15, 18, 48, 81, 25, 55, 17, 85, 28, 35 Clear answer Home 1 2 3 4 Courses Tasks Pause test Calendar Messagesarrow_forward
- Q3. list using cach of the two sorting algorithms: mergesort sort and quicksort and prints as output the number of comparisons as well as the execution time for each of the two algorithms for N= 10000, 20000, 40000, 100000, 200000 and 400000. The quicksort should use the last element as the pivot for partition. Present your results in a table of the form shown below and plot the results in two separate charts, one chart for the number of comparisons (for both algorithms in the same chart) and one chart for the execution time (for both algorithms in the same chart). Write a Java program that generates randomly a list of N integers, sorts the generatedarrow_forwardIf the list has the following items 17 9 11 30 8 20 35 7 5 45 3 28 Apply the quick sort on the above list by using the pivot is always the left item and find 1.The split point in the second partition call.arrow_forwardFunction Name: odd_even_diagParameters: a 2D list (list of lists)Returns: list of lists Description: Given a 2-dimensional matrix (list of lists) with any size (n*n), modify it according to the following rules: Find the sum of the main diagonal. If the sum is an odd number, change all the values of the given matrix (except the main diagonal) to 0. If the sum is an even number, change all the values of the given matrix (except the main diagonal) to 1. Return the resulting matrix. Example 1:If argument is: [[1, 2], [4, 3]] odd_even_diag should return: [[1, 1], [1, 3]] because the sum 1 + 3 is even. Example 2:If argument is: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] odd_even_diag should return: [[1, 0, 0], [0, 5, 0], [0, 0, 9]] because the sum 1 + 5 + 9 is odd.arrow_forward
- Create a digit rearrangement function for each numerical item in a list based on ascending or descending order. Examples reorderDigits ([515, 341, 98, 44, 211], "asc") 134, 89, 44, 112] reorderDigits ([515, 341, 98, 44, 211], "desc") [551, 431, 98, 44, 211] reorderDigits ([63251, 78221], "asc") reorderDigits ([63251, 78221], "desc") 87221] [155, [12356, 12278] [65321,arrow_forwardInse Α' Α' Δ A & E Local backup on 7 index 0 The following algorithm performs an operation on a list of names. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 == 15 names m Ahmed Amin Arnold Bob Beatrice Brad Charlie Chloe Chelsey Elizabeth Gavin Jordan Quan Ursula Weasley Zara first Line Spacing: 1 0 1 last def algorithm (): global names searchName-input ("Enter name to search") 15 first=0 last-len (names) -1 while firstsearchName: last-mid-1 else: Character Spacing: 0 First Line Indent: 0 main () if first>last: def main (): Table1 a)Copy and complete the trace table to trace the flow of execution of algorithm in Figure2. The table contains the state of the variables immediately before the while loop is entered. names are specified in Table 1 and the searchName entered is 'Weasley'. (Assume that the result of integer division is rounded down (e.g. the result of 5//2 is 2) return False first-mid+1 found-algorithm () print (found) mid ♫ A names[mid] result X Exit ][ [arrow_forwardIf the list has the following items 17 9 11 30 8 20 35 7 5 45 3 28 Apply the quick sort on the above list by using the pivot is always the left item and if The list after a first partition call is 7 9 11 3 8 5 17 20 35 40 30 28 (17 is the pivot correct position) , find The split point in the second partition call?arrow_forward
- Complete a Selection sort on the following values: 2, 22, 12, 21, 3, 1 Each row is one full "pass"/"iteration" through the data:arrow_forwardstep Sort the sequence {1, 5, 7, 6, 8, 9} using the Bubble sort algorithm. Show the step. Do llege of Te of Technol& Technology even if Exam, ogy Exam, 202 AN ST 021S, NYC C NYC Colle same. YC College College of Tech ge of Techno of Technology% echnology Ex logy Exam, 20 xam ege of Tech inology Ex nnology Exam Exam, 20arrow_forwardGiven an unsorted list, explain how a sequential search works (Be specific)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education