answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
frez
2 months ago
5

You are a police officer trying to crack a case. You want to check whether an important file is in the evidence room. Files have

IDs that are positive integers and the evidence room contains n files in sorted order of their IDs. Unfortunately, you do not have direct access to the evidence room; the only one who has access is Randy, who is corrupt and wants to make things hard for you. In the following we assume that x is the file ID you are looking for.
1. You know that the evidence room is organized as a sorted list of n elements. If Randy was not corrupt you would probably do binary search by asking him to give you the median file of the list. Unfortunately, you can only give Randy two indices l, u and he returns to you a file with index chosen uniformly at random from the range {l, . . . , u}. That is you can call

RANDY(l, u) = (i, ai), where i is a uniformly random integer chosen from l, . . . , u inclusive and ai is the ID of the corresponding file.

You solve the problem by doing something similar to binary search. You start by calling RANDY(1, n). Let’s assume that Randy returns (i, ai). You compare x to ai .

a.If x = ai you found the file you were looking for.
b.If x < ai you call RANDY(1, i − 1)
c.If x > ai you call RANDY(i + 1, n).

You continue recursively until you have either found the file or conclude that the file is not present in the evidence room. Show that the above algorithm accesses O(log n) files in expectation before it terminates.

2. With his trick in the previous question Randy was not able to slow you down very much1 . Now he decides to disallow "range" queries as above and only allows either sequential access to the files or access to a uniformly random file from the entire set. In particular, you now have two ways of accessing the list:

a.By looking at a uniformly random element of the list. That is by calling RANDY() = ai , where i is chosen uniformly at random from 1, . . . , n, inclusive.
Observe that you only receive the file ID, not the index of the file.

b.By asking Randy to give you the file directly following one he returned to you in some previous call. For example if you first call RANDY() and get back ai you are allowed to call NEXT(ai) and get back ai+1. Note that the list wraps around, so that NEXT(an) returns a1. If you haven’t already obtained ai in some previous call you may not call NEXT(ai).

To facilitate analyzing this setting, think of the files as being organized in the form of a circular sorted linked list where every file points to the one with the next higher ID.

(a) As a warm up, let us analyze the following setting. You are given a circle of unit circumference. You pick k points on the circle independently and uniformly at random and snip the circle at those points, obtaining k different arcs. Determine the expected length of any single arc. (Hint: Note that the length of each arc is identically distributed, so each has the same expectation. What is the sum of their expectations?)

(b) Develop a randomized algorithm for finding the file with ID x that makes at most O( √ n) calls to the functions NEXT() and RANDY() in expectation and always returns the correct answer. Analyze the running time of the algorithm. A proof of correctness is not necessary. (Hint: Your algorithm will perform some random accesses and some amount of linear search. Use part (a) to analyze the number of steps in the linear search)
Computers and Technology
2 answers:
Rzqust [1K]2 months ago
4 0

Answer:

Answer:

RANDY operates randomly, therefore any file in the specified index range follows this recurrence relation:

T(n) = T(n-i) + O(1)

With the probability being 1/n where i is between 1 and n. The n in T(n) signifies the measurement of the index range which becomes (n-i) on the next iteration.

<pbecause i="" can="" range="" from="" to="" n="" with="" a="" probability="" of="" this="" results="" in="" the="" average="" time="" complexity="" as:="">

T(n) =

After solving for T(n) = T(n/2) + O(1)

It resolves to T(n) = O(log n)

Consequently, the time complexity for this algorithm is O(log n).

It is essential to recognize that this value indicates the average time complexity due to its randomized design. Conversely, in the worst-case scenario, the index range may reduce by just 1, leading to a time complexity of O(n) since T(n) in the worst case equals T(n-1) + O(1).

Explanation:

</pbecause>
Harlamova29_29 [1K]2 months ago
3 0

Answer:

Since RANDY operates randomly, any file within the specified index range will have the recurrence relation as follows:

T(n) = T(n-i) + O(1)

Here, the probability is 1/n, where i can vary between 1 and n. The variable n in T(n) denotes the size of the index range, which will subsequently reduce to (n-i) in the following iteration.

Given that i is probabilistically distributed from 1 to n, the average case time complexity can then be expressed as:

T(n) = \sum_{i=1}^{n}\frac{1}{n}T(n-i) + O(1) = T(n/2)+O(1)

Next, solving T(n) = T(n/2) + O(1)

yields T(n) = O(log n).

Thus, the complexity of this algorithm is O(log n).

It should be noted that this represents the average time complexity due to the algorithm's randomized nature. In the worst-case scenario, the index range may only decrease by 1, resulting in a time complexity of O(n) since the worst-case scenario would be T(n) = T(n-1) + O(1).

You might be interested in
Asia pacific and Japanese sales team from cloud kicks have requested separate report folders for each region.The VP of sales nee
amid [951]

Answer:

B) Establish completely new regional folders and transfer the reports into the relevant region folder with viewer access.

Explanation:

Here are the options available

A) Create grouped folders while retaining the sharing settings of the top region folder, limiting the sharing settings for the grouped folders by region.

B) Establish entirely new regional folders and transfer the reports to their specific region folder while offering viewer access.

C) Generate all new regional folders and move the reports to the respective region folder by allowing subscribe access.

D) Create subfolders while keeping the sharing settings of the main region folder and limiting the settings for each region's subfolders.

To accommodate the required reports in one location while ensuring visibility for each folder, the consultant should advise creating entirely new regional folders, followed by moving the reports to their designated folders while leveraging the viewer access feature, enabling the VP to access them anytime.

Thus, the accurate selection is B.

3 0
1 month ago
Which of the following statements is true regarding input and output?
zubka84 [1067]
Input refers to the unprocessed data fed into a computer.
3 0
3 months ago
Read 2 more answers
Initialize the list short_names with strings 'Gus', 'Bob', and 'Zoe'. Sample output for the givenprogram:Gus Bob Zoeshort_names
maria [1035]

Answer:

short_names = ['Gus', 'Bob','Zoe']

Explanation:

In Python, a list is a data structure that permits the storage of various types of variables. Each element in a list has an indexed position, which must be an integer, and items can be accessed using their index. The syntax for creating and initializing a list is:

list_name = [item1, item2,item3]

  1. The name of the list (which must adhere to variable naming conventions)
  2. A pair of square brackets
  3. Items in the list must be separated by commas.

The Python code provided below demonstrates how to implement the solution to the stated problem:

short_names = ['Gus', 'Bob','Zoe']

print(short_names[0])

print(short_names[1])

print(short_names[2])

The output is:

Gus

Bob

Zoe

6 0
2 months ago
A wireless network does not benefit like a wired network does, when it comes to collision reduction. Which device reduces collis
Rzqust [1037]

Response:

Switch

Clarification:

A network switch is a piece of networking equipment, also referred to as a network bridging device, that links multiple devices within a network, allowing for data transmission between a source and a destination via packet switching.

To mitigate or minimize collisions in a network, modern wired networks utilize network switches where each device is attached to its individual port on the switch. This configuration turns the switch into a collision domain for half duplex connections, while in the case of full duplex links, the risk of collisions is entirely removed.

3 0
2 months ago
Other questions:
  • 9) If you are working on the part of 5-15 minutes, time-stamping (every 30 seconds) should start at: a) [00:05:00] b) [00:00:00]
    9·1 answer
  • Suppose that a scheduling algorithm (at the level of short-term CPU scheduling) favors those processes that have used the least
    10·1 answer
  • Your revenue is $22,000. Your Cost of Goods is 16,250. Your gross profit is _____________, fill in the blank,.
    14·1 answer
  • Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 3
    15·1 answer
  • A client has macular degeneration resulting in moderate visual impairment. The client works as a data entry clerk and wants to c
    15·1 answer
  • Fill the validateForm function to check that the phone number contains a number (use the isNaN function) and that the user name
    10·1 answer
  • A 2-dimensional 3x3 array of ints, has been created and assigned to tictactoe. Write an expression whose value is true if the el
    10·1 answer
  • 5) [4 points] Suppose you have a simple computer that is capable of storing only the months of the year. The number of bits avai
    12·1 answer
  • When using preventative insecticides which holiday period should trigger an application?
    15·2 answers
  • Write a program that gets a list of integers from input, and outputs non-negative integers in ascending order (lowest to highest
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!