Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 17, Problem 2SA
Program Plan Intro
Sequential search:
- The sequential search
algorithm is the process to find an item in an array. - It compares each value and searching starts at the beginning of the array.
- In the searching process, the algorithm compares each item in an array and finds an item.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Data Structure & Algorithm:
Here is an array with exactly 15 elements:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15Suppose that we are doing a serial search for an element. Circle any elements that will be found by examining two or fewer numbers from the array.
Interpolation search By using interpolation search algorithm check if the given element exists in the integer one dimensional array return the index of it ( data structure in java)
السؤال
sequential search:
what is the running time of the best case to search if all the elements of an array are equal ?
الاجابات
O(1)
O(n)
O(n^2)
n log n
Chapter 17 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Ch. 17.1 - Prob. 17.1CPCh. 17.1 - Prob. 17.2CPCh. 17.1 - Prob. 17.3CPCh. 17.1 - Prob. 17.4CPCh. 17.2 - Prob. 17.5CPCh. 17.2 - Prob. 17.6CPCh. 17.2 - Prob. 17.7CPCh. 17.2 - If a sequential search is performed on an array,...Ch. 17.3 - Prob. 17.9CPCh. 17.3 - Prob. 17.10CP
Ch. 17.3 - Prob. 17.11CPCh. 17.3 - Prob. 17.12CPCh. 17.3 - Prob. 17.13CPCh. 17.3 - Prob. 17.14CPCh. 17.3 - Let a[ ] and b[ ] be two integer arrays of size n....Ch. 17.3 - Prob. 17.16CPCh. 17.3 - Prob. 17.17CPCh. 17.3 - Prob. 17.18CPCh. 17 - Prob. 1MCCh. 17 - Prob. 2MCCh. 17 - Prob. 3MCCh. 17 - Prob. 4MCCh. 17 - Prob. 5MCCh. 17 - Prob. 6MCCh. 17 - Prob. 7MCCh. 17 - Prob. 8MCCh. 17 - Prob. 9MCCh. 17 - Prob. 10MCCh. 17 - True or False: If data is sorted in ascending...Ch. 17 - True or False: If data is sorted in descending...Ch. 17 - Prob. 13TFCh. 17 - Prob. 14TFCh. 17 - Assume this code is using the IntBinarySearcher...Ch. 17 - Prob. 1AWCh. 17 - Prob. 1SACh. 17 - Prob. 2SACh. 17 - Prob. 3SACh. 17 - Prob. 4SACh. 17 - Prob. 5SACh. 17 - Prob. 6SACh. 17 - Prob. 7SACh. 17 - Prob. 8SACh. 17 - Prob. 1PCCh. 17 - Sorting Objects with the Quicksort Algorithm The...Ch. 17 - Prob. 3PCCh. 17 - Charge Account Validation Create a class with a...Ch. 17 - Charge Account Validation Modification Modify the...Ch. 17 - Search Benchmarks Write an application that has an...Ch. 17 - Prob. 8PCCh. 17 - Efficient Computation of Fibonacci Numbers Modify...
Knowledge Booster
Similar questions
- Given a 4-element array with distinct values: {x1,x2,x3,x4} , what is the minimum number of comparisons you need to sort this array?arrow_forwardIn the square two dimensional array, the condition to navigate to (reach) the upper triangle elements of the primary diagonal * :is Note: (i) represents row index, (j) represents column index, and SIZE represents the array length i>j O isj O i+jSize-1 Oarrow_forwardQuestion 8 Sort the following numbers using an "in place" version of a selection sort. This means that you should have only one array throughout and all elements should be present at all times. Show each "pass" of the algorithm. 34, 25, 11, 44, 21, 8, 4, 28, 16, 31arrow_forward
- OGiven an array arr[] of N non-negative integers representing the height of blocks. If width of each block is 1, compute how much water can be trapped between the blocks during the rainy season. Example 1: Input: N = 6 arr[] = {3,0,0,2,0,4} Output: 10.arrow_forwardList all the steps used to search for 18 in the sequence 1, 2, 4, 8, 10, 12, 18, 20, 22. Be sure to show EVERY step. A. linear search B. binary search Use the following array and indices in your answer: Array: 1 2 4 8 10 12 18 20 22 Index: 1 2 3 4 5 6 7 8 9arrow_forwardThe binary search algorithm that follows may be used to search an array when the elements are in order. This algorithm is analogous to the following approach to finding a name in a telephone book. a. Open the book in the middle and look at the middle name on the page. b. b. If the middle name isn't the one, you're looking for, decide whether it comes before or after the name you want. c. Take the appropriate half of the section of the book you were looking in and repeat these steps until you land on the name. 1. Let the bottom be the subscript of the initial array element. 2. Let the top be the subscript of the last array element. 3. Let found be false. 4. Repeat as long as the bottom isn't greater than the top and the target has not been found. 5. Let middle be the subscript of the element halfway between bottom and top. 6. If the element in the middle is the target 7. Set found to true and index to middle. else if the element in the middle is larger than the target 8. Let the top be…arrow_forward
- Which technique does sum_array use to access the elements in array a int sum_array(int a[], int n) { int sum = 0; for (int i 0; iarrow_forwardJava programming To use Binary search algorithm on an array, the array must be:arrow_forwardC programming languagearrow_forwardArray implementation of List ADT Display the array elements from Left to Right and Right to left. Input: Enter the size of array MAX Enter number of elements N Enter the element to be inserted. Output: Display the Array For example: Test Input 1 2 10 W3 123 10 5 11 12 13 14 15 Result Forward: 1 2 3 Backward:3 2 1 Forward: 11 12 13 14 15 Backward:15 14 13 12 11arrow_forwardCreate a program that can find the mode of a sorted dynamic array and print it. If there is more than one mode found print them in ascending order. Example of array: {20, 30, 30, 50, 70 , 80, 80, 90, 100}. no sorting necessaryarrow_forward// function to generate all subsequences of given arrayfunction generate_subseq(arr): // length of arr n = len(arr) // total subsequences for array of length n m = 2**n // to store all subsequences seqs = [] // running a loop for m times for i in range(1, m): // creating an array of zeros of length n a = [0]*n num = i // to use as an index for 'a' j = n-1 // run this loop till num > 0 while num > 0: if num is odd: a[j] = 1 // divide num by 2 num = num/2 // subtract 1 from 'j' j -= 1 // to store current subsequence seq = [] // iterating for n times for i in range(n): // add ith index value to 'seq' if a[i] == 1: seq.append(arr[i]) // add 'seq' to 'seqs' seqs.append(seq) // return seqs return seqs // given listsS1 = ['B','C','D','A','A','C','D']S2 = ['A','C','D','B','A','C']…arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage