1.
What is the minimum number of locations a binary search algorithm will have to examine when looking for a particular value in a sorted array of 200 elements? (2 points)
|
1 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
200 |
2.
In general, which of the following sorting algorithms is the MOST efficient? (2 points)
|
Bubble sort |
|
|
Insertion sort |
|
|
Heap sort |
|
|
Merge sort |
|
|
Selection sort |
3.
Which of the following are quadratic-sorting algorithms? (2 points)
I. insertion sort
II. selection sort
III. merge sort
|
I only |
|
|
II only |
|
|
III only |
|
|
I and II only |
|
|
I, II, and III |
4.
What is the minimum number of locations a sequential search algorithm will have to examine when looking for a particular value in an array of 200 elements? (2 points)
|
1 |
|
|
7 |
|
|
8 |
|
|
100 |
|
|
200 |
5.
Which sorting algorithm is LEAST efficient when performed on an array in which the values are already in the desired sorted order? (2 points)
|
Binary sort |
|
|
Insertion sort |
|
|
Merge sort |
|
|
Selection sort |
|
|
It is not possible to know which will be slowest. |
6.
What is the maximum number of locations a binary search algorithm would have to examine when looking for a particular value in a sorted array of 300 elements? (2 points)
|
1 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
300 |
7.
As you work through this course, your instructor is here to
facilitate it and encourage your success. It is important to
reflect on what you have learned, so please take a moment to answer
these two questions.
+What did you enjoy about this section of the course?
+What part of this assignment was difficult?
I am not sure about some of the problems
I can check what I still need to work on
8.
What is the maximum number of locations a sequential search algorithm will have to examine when looking for a particular value in an array of 50 elements? (2 points)
|
50 |
|
|
25 |
|
|
12 |
|
|
6 |
|
|
1 |
9.
Which of the following sorting algorithms is described by this text? "Find the smallest item in the array and swap it with the item currently in index 0. Then, find the smallest remaining item, and swap it with the value at index 1. Continue this process until all items are placed into the array in the correct order." (3 points)
|
Insertion sort |
|
|
Heap sort |
|
|
Merge sort |
|
|
Quick sort |
|
|
Selection sort |
10.
An array of integers is to be sorted from smallest to largest using an insertion sort. Assume the array originally contains the following elements:
24 13 3 9 17 20
What will it look like after the third pass through the loop? (3 points)
|
3 9 13 24 17 20 |
|
|
3 9 13 17 24 20 |
|
|
3 9 13 17 20 24 |
|
|
9 13 24 3 20 17 |
|
|
9 13 24 3 17 20 |
11.
An array of integers is to be sorted from largest to smallest using a selection sort. Assume the array originally contains the following elements:
10 8 23 19 21 16
What will it look like after the third pass through the loop? (3 points)
|
23 21 19 10 8 16 |
|
|
23 21 10 19 8 16 |
|
|
23 21 19 16 10 8 |
|
|
23 21 19 16 8 10 |
|
|
23 8 10 19 21 16 |
12.
What is required to implement a sequential search? (2 points)
|
Hash table |
|
|
Pivot value |
|
|
Recursive method |
|
|
Sorted data |
|
|
None of the above is required. |
1. What is the minimum number of locations a binary search algorithm will have to examine when looking for a particular value in a sorted array of 200 elements? (2 points) Answer is 8, because 2^8 = 256 is the smallest number greater than 200 which is of 2 power. 2. In general, which of the following sorting algorithms is the MOST efficient? (2 points) Merge sort => O(nLogN) 3. Which of the following are quadratic-sorting algorithms? (2 points) I. insertion sort II. selection sort III. merge sort II only are quadratic with worst case complexity as O(N^2) 4. What is the minimum number of locations a sequential search algorithm will have to examine when looking for a particular value in an array of 200 elements? (2 points) 1 => As algorithm can find the element at first place itself.
Answering 4 starting question as per HomeworkLib policy. Request you to post remaining questions in separate thread, Thanks!
1. What is the minimum number of locations a binary search algorithm will have to examine...
QUESTION 3 Suppose that you have been running an unknown sorting algorithm. Out of curiosity, you once stopped the algorithm when it was part-way done and examined the partially sorted array. You discovered that the last K elements of the array were sorted into ascending order, but the remainder of the array was not ordered in any obvious manner. Based on this, you guess that the sorting algorithm was (select all that apply): heapsort insertion sort mergesort quicksort Shell's sort...
1. Which is the best sorting algorithm for larger arrays if all the items can not fit in main memory? selection sort insertion sort quicksort Merge sort 2. Which sorting algorithm sorts items without comparing them? quick sort radix sort merge sort Insertion sort 3 What is the average running time for quicksort? O(n2) O(logn) O(nlogn) O(n) O(n2logn) 4. Examine the steps of the following algorithm and write the name of the algorithm described in the blank provided: Recursively divide...
1. What is the worst case time complexity of insertion into a binary search tree with n elements? You should use the most accurate asymptotic notation for your answer. 2. A binary search tree is given in the following. Draw the resulting binary search tree (to the right of the given tree) after deleting the node with key value 8. 10 3. You have a sorted array B with n elements, where n is very large. Array C is obtained...
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...
Course: CIS-5, Intro to Programming
1. Which algorithm is also called the sequential search? binary search linear search bubble sort selective sort 2 Which search algorithm requires that the elements be pre-sorted? linear search bubble sort binary search We were unable to transcribe this image
Write a C function that implements the Liner Search algorithm instead of Binary Search. However, this linear search algorithm returns the indices of the longest sorted subset of numbers in an array of integers of size n. The longest sorted subset of numbers must satisfy three conditions. First, the subset consists of unique numbers (no duplicate); second, all the numbers in this subset is divisible by m, the minimum size of the subset is two elements. In the main method...
Question 28 A binary search starts by comparing the search item to the first item in the list. True False 1 points Question 29 The insertion sort algorithm sorts a list by repeatedly inserting an element in its proper place into a sorted sublist. True False 1 points Question 30 An interface is a class that contains only the method headings and each method heading is terminated with a semicolon. True False 1 points Question 31 Clicking on a JCheckBox...
Sorting: (40 points) a. We studied several sorting algorithms. Every sorting algorithm has their own special reason where it can only use. Can you explain carefully in which situation the following algorithms would be best sorting algorithm to use in an application. (10 points) i. Insertion sort ii. Selection sort iii. Merge sort iv. Quick sort b. You are given a string of elements as below, Canopus, Mimosa, Betelgeuse, Deneb, Stars, Pollux, Antares, Sirius, Hader i. Your task is to...
a. We studied several sorting algorithms. Every sorting algorithm has their own special reason where it can only use. Can you explain carefully in which situation the following algorithms would be best sorting algorithm to use in an application. (10 points) i. Insertion sort ii. Selection sort iii. Merge sort iv. Quick sort b. You are given a string of elements as below, Canopus, Mimosa, Betelgeuse, Deneb, Stars, Pollux, Antares, Sirius, Hader i. Your task is to insert the above...
Question 27 (Mandatory) (1 point) Which sorting algorithm uses the following pseudocode: For each new, unsorted value v in an array, search backward through already sorted values in the array. Move values until a proper position is found for v. Place v in its correct position. Bogo Sort Selection Sort Insertion Sort Ascending Sort Bubble Sort