Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
5th Edition
ISBN: 9780134801155
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 9, Problem 9MC
Program Description Answer
Sequential search
Hence, the correct answer is option “A”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
f an array is sorted in this order, the values are stored from highest to lowest.a. asymptoticb. logarithmicc. ascendingd. descending
Linear search can be used on:a. Unsorted arrays.b. Sorted arrays.c. Integer arrays.d. Any of the above.
AIM: Write a program to do Linear Search using a given Search Key in an un-
sorted Linear Array 'A' which has N values in it.
Description:
The linear search compares each element of the array with the search key until the
search key is found. To determine that a value is not in the array, the program must
compare the search key to every element in the array 'A'. It is also called "Sequential
Search" because it traverses the data sequentially to locate the element.
Algorithm: (Linear Search)
LINEAR
SEARCH (A, N, SKEY)
Here A is a Linear Array with N elements and SKEY is a given item
of information to search. This algorithm finds the location of SKEY in
A and if successful, it returns its location otherwise it returns -1 for
unsuccessful.
1.
Repeat step-2 for K = 0 to N-1
2. if(A [K] = SKEY) return K [Successful Search]
[End of loop of step-1 ]
3. return -1 [Un-Successful]
4. End.
Chapter 9 Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Ch. 9.3 - Which of the sorting algorithms discussed makes...Ch. 9.3 - Prob. 9.2CPCh. 9.3 - Prob. 9.3CPCh. 9.4 - Prob. 9.4CPCh. 9.4 - On average, with an array of 1,000 elements, how...Ch. 9.4 - Prob. 9.6CPCh. 9 - Prob. 1MCCh. 9 - Prob. 2MCCh. 9 - Prob. 3MCCh. 9 - Prob. 4MC
Ch. 9 - Prob. 5MCCh. 9 - Prob. 6MCCh. 9 - Prob. 7MCCh. 9 - Prob. 8MCCh. 9 - Prob. 9MCCh. 9 - Prob. 10MCCh. 9 - Prob. 1TFCh. 9 - Prob. 2TFCh. 9 - Prob. 3TFCh. 9 - Prob. 4TFCh. 9 - Prob. 5TFCh. 9 - Prob. 1AWCh. 9 - Prob. 2AWCh. 9 - Prob. 3AWCh. 9 - What algorithm does the following pseudocode...Ch. 9 - Prob. 1SACh. 9 - Prob. 2SACh. 9 - Prob. 3SACh. 9 - Prob. 4SACh. 9 - Prob. 5SACh. 9 - Why is the selection sort more efficient than the...Ch. 9 - Prob. 7SACh. 9 - Prob. 8SACh. 9 - Assume the following main module is in a program...Ch. 9 - Prob. 1PECh. 9 - Sorted Names Design a program that allows the user...Ch. 9 - Rainfall Program Modification Recall that...Ch. 9 - Name Search Modify the Sorted Names program that...Ch. 9 - Charge Account Validation Recall that Programming...Ch. 9 - Prob. 7PECh. 9 - Sorting Benchmarks Modify the modules presented in...
Knowledge Booster
Similar questions
- The elements of an array are guaranteed to be contiguous in memory.A. True B. Falsearrow_forwardSorting is a basic issue with arrays in which the goal is to find the target element in the array. Choose from the following options: Falsearrow_forwardEasy C++ program please answer fast Maximum Subarray Sum Rabbit Jerry downloads the list of N (2 ≤ N ≤ 105 ) stock prices of RABJ and stores them into a circular buffer/array in a clockwise manner (i.e., the first stock price follows the N-th stock price on the circular buffer) starting from index position 0. It is worth pointing out that the stock prices can be negative numbers in the rabbit stock market. He is curious about the maximum subarray sum over this circular buffer. Certainly, the maximum subarray can possibly straddle over both index positions 0 and N-1. Output the maximum subarray sum. The maximum subarray must contain at least one element. INPUT FORMAT (input arrives from the terminal / stdin): First line contains N. The next line contains N space-separated integers denoting the input sequence. The price ranges from -1,000,000 to 1,000,000. OUTPUT FORMAT (print output to the terminal / stdout): A single line containing the maximum subarray sum. Note that the output can…arrow_forward
- How does a selection sort work for an array?arrow_forwardthe type of al element in an array must be same. a. true b. falsearrow_forwardAnswer in C++ Programming Language. C++, Array Write a program that will ask the user to enter a set of numbers and outputs all the subsets of that set. The size of the array is 5. Ask the user if he wants to repeat the program by pressing y/Y.arrow_forward
- The array index can be any integer less than the array size… TRUE OR FALSEarrow_forwardUsing C languagearrow_forwardMatrix Addition• Write an addition function that accepts two 2D numpy arrays, andreturns the sum of the two (if they are the same size). This functionshould test that the arrays are the same size before performing theaddition. If the arrays are not the same size, the function shouldreturn -1. solve in pythonarrow_forward
- Matrix Multiplication• Write a multiplication function that accepts two 2D numpy arrays,and returns the product of the two. This function should test that thearrays are compatible (recall that the number of columns in the firstmatrix must equal the number of rows in the second matrix). Thisfunction should test the array sizes before attempting themultiplication. If the arrays are not compatible, the function shouldreturn -1. solve in pythonarrow_forwardstruct grade { char id[10]; int mark; }; Using the student structure given above, create an array of size 5 students. Then write a complete C program to sort the students array based on the students rank. Use the following sorting techniques in your code. Don’t forget to print initial array and final (sorted) array. a. Insertion sort b. Merge sort c. Quick sortarrow_forwarddo in c++arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage