Question

State True or False. i) Binary search is used for searching in a sorted array. AND...

State True or False. i) Binary search is used for searching in a sorted array. AND ii) The time complexity of binary search is O(log n). A) True, False B) False, True C) False, False D) True, True Explain

Homework Answers

Answer #1

D) TRUE,TRUE.

i) Binary search searcha sorted array by repeatedly dividing the search interval in half .If the value of the search key is less than the item in the middle of the interval ,narrow the interval to the lower half.Otherwise, narrow it to th eupper half.Repeat the steps and check untill the value is found or the interval becomes empty.

ii) The time Complexity of Binary search is O(log n)

.

-------------------------------------------------thank You----------------------------------------------------------------------------------

Know the answer?
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
Similar Questions
how to pass in an object from an array of objects in a binary search on...
how to pass in an object from an array of objects in a binary search on swift? I have the following:    func binarySearchPrefix(array: [String], target: String) -> Bool {                var left = 0         var right = array.count - 1                while (left <= right) {             let mid = (left + right) / 2             let value = array[mid]             if (value.hasPrefix(target)) {                 return true             }             if (value < target) {                ...
1. Given an n-element array A, Algorithm X executes an O(n)-time computation for each even number...
1. Given an n-element array A, Algorithm X executes an O(n)-time computation for each even number in A and an O(log n)-time computation for each odd number in A. What is the best-case running time of Algorithm X? What is the worst-case running time of Algorithm X? 2. Given an array, A, of n integers, give an O(n)-time algorithm that finds the longest subarray of A such that all the numbers in that subarray are in sorted order. Your algorithm...
Using Big O notation, indicate the time requirement of each of the following tasks in the...
Using Big O notation, indicate the time requirement of each of the following tasks in the worst case. Computing the sum of the first n even integers by using a for loop            [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)          Displaying all n integers in an array            [ Choose ] O(1) O(2n) O(n*log n ) O(2^n) O(log n) O(n^2) O(n) O(2) O(n^3)          Displaying all n integers in a sorted linked chain            [ Choose...
Write the following program in MIPS: a) declare an array A of the following numbers: 3,...
Write the following program in MIPS: a) declare an array A of the following numbers: 3, 5, 8, 10, 12, 2, 76, 43, 90, 44 b) declare a variable called size which stores the number of element in array A, that is 10. c) write a subroutine to search for a number stored in an array and return true or false. In C++ the subroutine is as follows: search(array, size, number_To_Search) e.g. search(A, 10, 12) The subroutine should return 0...
In heapsort we view an array as a binary tree using the following mapping: a[0] is...
In heapsort we view an array as a binary tree using the following mapping: a[0] is the root of the entire tree and for element a[i], its left child is a[2i+1] and its right child is a[2i+2]. Answer the following questions for an array of size n. ( Answers in some cases may be in terms of n.) a) What is the index of the parent a[i] for any i > 0? b) What is the biggest index for which...
True or false; for each of the statements below, state whether they are true or false....
True or false; for each of the statements below, state whether they are true or false. If false, give an explanation or example that illustrates why it's false. (a) The matrix A = [1 0] is not invertible.                               [1 -2] (b) Let B be a matrix. The rowspaces row (B), row (REF(B)) and row (RREF(B)) are all equivalent. (c) Let C be a 5 x 7 matrix with nullity 3. The rank of C is 2. (d) Let D...
1.A stack implemented with an array has what performance? Select one: a. O(n3) b. O(n log...
1.A stack implemented with an array has what performance? Select one: a. O(n3) b. O(n log n) c. O(n) d. O(n2) 2. A stack uses the first in first out insertion and deletion method. Select one: True False 3. Match the following stack operations with their meaning. object pop(); boolean isEmpty(); push (object); integer size(); object top(); meanings are: - returns the number of elements stored -just removes the last inserted elements - returns the last inserted elements without removing...
Data Structures using C++ Searching a Linked List Here are the declarations for a simple unsorted...
Data Structures using C++ Searching a Linked List Here are the declarations for a simple unsorted linked list of ints that ends in a null pointer. //=============================================================== class Cell { friend class UList; private: int data; Cell* next; Cell( int dt, Cell* nx=nullptr ) : data(dt), next(nx) {} }; //=============================================================== class UList { private: Cell* head = nullptr;    // stationary head pointer. Cell* scan = nullptr;          // for walking down the List. Cell* follow = nullptr; public: void find( int...
i) What would be stored in the 4-digit binary codes if the clock display time was:17:29...
i) What would be stored in the 4-digit binary codes if the clock display time was:17:29 (7) (c) Using two’s complement binary arithmetic, find the sum of (i) 48 and – 19 (ii) ( 6)  ( 13) and (iii) Convert (b) (i)Convert 87.25 in decimal to Binary and show it value in Octal and Hex. n
State whether true or false and explain: (a) The Keynesian consumption function predicts that the average...
State whether true or false and explain: (a) The Keynesian consumption function predicts that the average propensity to consume rises as income increases. (b) Labour-market reforms that reduce frictions in search and matching will lower the natural rate of unemployment.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT