Question

COP2220 23. Which of the following statements about sequential search is true Summer 2017-Final-0//17 Page s ol 11 a. The list must be a sorted list b. It works only on a list of integers c. When the search target is not in the list, every elemment must be testea d. The search typically starts at the middle of the list and searches on esher e. None of the above. middle of the list and searches on either side of the middle Your answer 24. Consider searching for taget value of 44 in the serted iot given below using binary search The frst edement to be compared to the target 22 35|44 | 67 | 72|85|92|99 The first element to be compared to the target is a. 10 b. 99 c. 72 d. 67 e. 44 Your answer 25. Consider searching for a target value of 75 in the sorted list given below using, binary search 0 | 22 | 35 | 44 |67|72|85 92199 The last element to be compared to the target is a. 10 b. 99 c. 72 d. 67 e. 44 Your answer What would be the contents of an array order after two passes of insertion sort, if the initial array contents are as shown below? 26. 22 91 57 26 38 10 63 a. 10 22 57 26 38 91 63 b. 10 22 26 3857 63 91 c 22 38 57 10 26 63 91 d. 22 10 26 38 57 63 91 ) 123S7 2 1037 6 91 Your answer e 22 57 91 26 38 10 63 Dr. Asaitha School of Computing The University of North Florida
0 0
Add a comment Improve this question Transcribed image text
Answer #1

23) Which of the following statement about sequential search is true?

Correct option: c. When the search target is not in the list, every element must be tested.

Explanation: Sequential search finds a target value in the given list. It starts its checking sequentially from the starting element of the list and checks each of the elements until a match is found or until all the elements of the list have been checked. For this method, list need not to be a sorted one. Sequential search is a method which is not specific to a particular data type. Hence it can work upon any list whether the elements are integer or float or double or string etc. So it is now clear that options a, b, d and e are incorrect. Option c is the correct one.

24) Target value 44. Given list: 10, 22, 35, 44, 67, 72, 85, 92, 99; Method of searching: Binary search; The first element to be compared to the target is:

Correct option: d. 67.

Explanation: Binary search method works upon a sorted list by repeatedly dividing the search interval in half. So for the first iteration the search interval would be the full list. The given list has 9 elements starting from index 1 through 9. So this method would divide the list into two half finding the middle index, here for 1st iteration the middle index would be (1+9)/2 = 5. Now the target element would be compared with the value of the middle index. Hence the first element to be compared to the target is element in the 5th index of the list; which is 67. So, options a, b, c and e are incorrect. Option d is the correct option.

25) Target value 75. Given list: 10, 22, 35, 44, 67, 72, 85, 92, 99; Method of searching: Binary search; The last element to be compared to the target is:

Correct option: c. 72.

Explanation: Binary search method works upon a sorted list by repeatedly dividing the search interval in half.

So for the 1st iteration the search interval would be the full list. The given list has 9 elements starting from index 1 through 9. So this method would divide the list into two half finding the middle index, here for 1st iteration the middle index would be (1+9)/2 = 5. Now the target element would be compared with the value at the index 5; which is 67.Now 67 is less than the target value 75 so the left half of the middle index is discarded; now the search interval has become only the right half of the middle index. At this point the element will be searched from index 6 through index 9.

For 2nd iteration middle index would be (6+9)/2 = 7.5 i.e. 7. Now the target element would be compared with the value at the index 7; which is 85. Now 85 is greater than the target value 75 so the right half of the middle index is discarded; now the search interval has become only the left half of the middle index. At this point the element will be searched from index 6 through index 6.

For 3rd iteration middle index would be (6+6)/2 = 6. Now the target element would be compared with the value at the index 6; which is 72. Now 72 is less than the target value 75 so the left half of the middle index should be discarded; but as the lower and higher index is same for this iteration so process would be stopped here (no elements are there to create the next search interval). Hence the last element to be compared to the target is: 72. So options a, b, d and e are incorrect. Correct option is c.

26) Initial array contents are: 22, 91, 57, 26, 38, 10, 63; method of sorting: Insertion sort; contents of array after 2 passes would be:

Correct option: e. 22, 57, 91, 26, 38, 10, 63.

Explanation: In this sorting method, in each pass an element is picked and inserted at the appropriate position in ascending or descending order. In pass 1: element at index 1 is inserted in a proper order so that 0th and 1st elements are sorted. In pass 2: element at index 2 is inserted in a proper order so that 0th, 1st and 2nd elements are sorted. In this way n-1 passes are carried out to sort the whole array with n elements.

After 1st pass the contents of the given array would be: 22, 91, 57, 26, 38, 10, 63.

After 2nd pass the contents of the given array would be: 22, 57, 91, 26, 38, 10, 63.

Hence options a, b, c and d are incorrect. Correct option is e.

/*If this helps you, please let me know by giving a positive thumbs up. In case you have any queries, do let me know. I will revert back to you. Thank you!!*/

Add a comment
Know the answer?
Add Answer to:
Which of the following statements about sequential search is true? a. The list must be a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Sorting and Searching 1. Mark the following statements as true or false. a. A sequential...

    C++ Sorting and Searching 1. Mark the following statements as true or false. a. A sequential search of a list assumes that the list elements are sorted in ascending order. b. A binary search of a list assumes that the list is sorted. 2. Consider the following list: 63 45 32 98 46 57 28 100 Using a sequential search, how many comparisons are required to determine whether the following items are in the list or not? (Recall that comparisons...

  • Searching/sorting tasks and efficiency analysis - Binary Search Search for the character S using the binary...

    Searching/sorting tasks and efficiency analysis - Binary Search Search for the character S using the binary search algorithm on the following array of characters: A E G K M O R S Z. For each iteration of binary search use a table similar to the table below to list: (a) the left index and (b) the right index of the array that denote the region of the array that is still being searched, (c) the middle point of the array,...

  • I need it in JAVA Write a program that randomly populates an array of size 100,...

    I need it in JAVA Write a program that randomly populates an array of size 100, sorts it, and then finds the median. The random numbers must be from 0-99 and all integer values. Also since there is an even set of numbers the median is found by taking the mean of the two middle numbers (In other words the 50th and 51st). You have to code your own sorting method. You may not use a built in java sorter....

  • The ExceptionLab class provided: – Creates an array of 100 elements and fills it with random...

    The ExceptionLab class provided: – Creates an array of 100 elements and fills it with random numbers from 1 to 100. – It asks the user for an index value between 0 and 99. – Prints the element at that position. – If a number > 99 is entered by the user, the class will abort with an ArrayIndexOutOfBoundsException • Modify the ExceptionLab: – Add a try-catch clause which intercepts the ArrayIndexOutOfBounds and prints the message: Index value cannot be...

  • Complete function long_list_printer.print_list(). When it's finished, it should be able to print this list, a =...

    Complete function long_list_printer.print_list(). When it's finished, it should be able to print this list, a = [ [93, 80, 99, 72, 86, 84, 85, 41, 69, 31], [15, 37, 58, 59, 98, 40, 63, 84, 87, 15], [48, 50, 43, 68, 69, 43, 46, 83, 11, 50], [52, 49, 87, 77, 39, 21, 84, 13, 27, 82], [64, 49, 12, 42, 24, 54, 43, 69, 62, 44], [54, 90, 67, 43, 72, 17, 22, 83, 28, 68], [18, 12, 10,...

  • Consider the below matrixA, which you can copy and paste directly into Matlab.

    Problem #1: Consider the below matrix A, which you can copy and paste directly into Matlab. The matrix contains 3 columns. The first column consists of Test #1 marks, the second column is Test # 2 marks, and the third column is final exam marks for a large linear algebra course. Each row represents a particular student.A = [36 45 75 81 59 73 77 73 73 65 72 78 65 55 83 73 57 78 84 31 60 83...

  • I need to develop the 7 functions below into the main program that's given on top...

    I need to develop the 7 functions below into the main program that's given on top Write a C program to create array, with random numbers and perform operations show below. Il Project 3 (53-20). 1 Projects CS5,00 This file contains the function Programcution Dagine and one include <timo // Defining some constants definer_SIZE 20 define LOVE LIMIT 1 eine UPR UNIT define TALSE eine Tut 1 wold randomizery (int[], int, Int, int) wold pinay in. St, Int); En find...

  • Java The following questions ask about tracing a binary search. To trace the binary search, list...

    Java The following questions ask about tracing a binary search. To trace the binary search, list the value of first, last, and mid for each pass through the loop or method. Use one of these methods for your trace. public static int binarySearchIterative(int[] numbers, int target) { boolean found = false; int first = 0; int last = numbers.length - 1; while (first <= last && !found) { int mid = (first + last) / 2; if (numbers[mid] == target)...

  • Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges...

    Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...

  • C++ Time the sequential search and the binary search methods several times each for randomly generated...

    C++ Time the sequential search and the binary search methods several times each for randomly generated values, then record the results in a table. Do not time individual searches, but groups of them. For example, time 100 searches together or 1,000 searches together. Compare the running times of these two search methods that are obtained during the experiment. Regarding the efficiency of both search methods, what conclusion can be reached from this experiment? Both the table and your conclusions should...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT