Question: Consider an array ( assigned to you below ) that has a sequence of negative integers followed by a sequence of positive integers ( that
Consider an array assigned to you below that has a sequence of negative integers followed by a sequence of positive integers that could include as well The array is guaranteed to have at least an occurrence of a negative integer and at least an occurrence of a positive integer. tabletableArrayindex
Assume the size of the array is known ahead of time. Also, the array need not be sorted.
a Design a Theta logn binary search algorithm to count the number of occurrences of negative integers and positive integers in an array of size ncomprising of a sequence of negative integers followed by a sequence of positive integers Write the pseudo code of your algorithm as well as clear specify the invariants properties of the left index LI and the right index RI and explain how they are moved in each iteration. Also, explain when does your algorithm terminate and what does it determine by then.
b Show the execution of your algorithm on the array assigned to you.
Note that you should run only ONE instance of binary search on the array and be able to determine the number of occurrences of negative integers and number of positive integers as well.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
