Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
Transcribed Image Text:Again, we skip the proof of correctness of this algorithm.
(d) What is the worst-case running time of Find-Index-2(A[1 n])? What about its worst-case
expected running time? Remember to prove your answer formally.
Transcribed Image Text:Problem 2. Suppose we have an array A[1 : n] which consists of numbers {1,...,n} written in some
arbitrary order (this means that A is a permutation of the set {1,...,n}). Our goal in this problem is to
design a very fast randomized algorithm that can find an index i in this array such that A[i] mod 8 € {1,2},
i.e., the reminder of dividing A[i] by 8 is either 1 or 2. For simplicity, in the following, we assume that n
itself is a multiple of 8 and is at least 8 (so a correct answer always exist).
For instance, if n = 8 and the array is A = [8,7, 2,5, 4, 6,3, 1], we want to output either of indices 3 or 8.
(a) Suppose we sample an index i from {1,...,n} uniformly at random. What is the probability that i is
a correct answer, i.e., A[i] mod 8 E {1,2}?
(b) Suppose we sample m indices from {1,...,n} uniformly at random and with repetition. What is the
probability that none of these indices is a correct answer?
Now, consider the following simple algorithm for this problem:
Find-Index-1(A[1: n]):
• Let i = 1. While A[i] mod 8 ¢ {1,2}, sample i e {1,...,n} uniformly at random. Output i.
The proof of correctness of this algorithm is straightforward and we skip it in this question.
(c) What is the worse-case expected running time of Find-Index-1(A[1 : n])? Remember to prove your
answer formally.
The problem with Find-Index-1 is that in the worst-case (and not in expectation), it may actually never
terminate! For this reason, let us consider a simple modification to this algorithm as follows.
Find-Index-2(A[1 : n]):
• For j = 1 to n:
- Sample i e {1,...,n} uniformly at random and if A[i] mod 8 € {1,2}, output i and terminate;
otherwise, continue.
• If the for-loop never terminated, go over the array A one element at a time to find an index i with A[i]
mod 8 € {1,2} and output it as the answer.
Again, we skip the proof of correctness of this algorithm.
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
This is a popular solution
bartleby
Trending nowThis is a popular solution!
bartleby
Step by stepSolved in 2 steps
Knowledge Booster
Background pattern image
Similar questions
- Prove f(n) = n3 - (n2 log2 n) + 2n f(n) ∈ O(n3) by giving the constants (c, n0) and arguing that your constants hold as n goes to infinity by either "chaining up", "chaining down", carefully treating the inequality as an equality and doing some algebra, or even weak induction. Also, what is the minimum val4ue for c (in the definition of O() ) forj this problem and is it an exclusive or inclusive minimum/bound.arrow_forwardFormally prove or disprove the following claims, using any methodarrow_forwardWe mentioned that if we want to prove P ≠ NP, we only need to pick up any one NPC problem and prove that polynomial-time algorithm does not exist for the problem. If you want to prove P ≠ NP, select one NPC problem based on your preference and describe your idea of why polynomial-time algorithm does not exist for the problem. It does not have to be a formal proof, a description of your idea would be fine.arrow_forward
- Solving recurrences using the Substitution method. Give asymptotic upper and lower bounds for T(n) in each of the following recurrences. Solve using the substitution method. Assume that T(n) is constant n ≤ 2. Make your bounds as tight as possible and justify your answers. Hint: You may use the recursion trees or Master method to make an initial guess and prove it through induction a. T(n) = 2T(n-1) + 1 b. T(n) = 8T(n/2) + n^3arrow_forwardUse the Transform-and-Conquer algorithm design technique with Instance Simplification variant to design an O(nlogn) algorithm for the problem below. Show the pseudocode. Given a set S of n integers and another integer x, determine whether or not there exist two elements in S whose sum is exactly x.arrow_forwardThe runtime complexity, T(n), of the three following recurrence relation solved by Master's Theorem) are T(n) = 6T(n/3) + n2 logn T(n) = 64T(n/8)- n2 log n T(n) = 4T(n/2) + n/logn (The solution for the three relations are respectively given by) A: (nlogn), 9(n2), (n2 logn) B: 9(n2), (n2 logn), (n log n) C: (n2logn), Master's Theorem does not apply, 9(n2) D: 0(n2), Master's Theorem does not apply, 9(n2 log n) E: 0(n2 logn), 9(n2), Master's Theorem does not apply F: 9(n2), (n2 logn), Master's Theorem does not applyarrow_forward
- Give asymptotically tight upper and lower bounds for T (n) in each of the followingalgorithmic recurrences. Justify your answers.E. ?(?) = 3?((?/3) - 2) + ?/2 (Hint: think about how you can use an assumptionabout the importance of the -2 to apply the Masters Theorem)arrow_forwardImplement Algorithm to Knuth Version of Schreier-Sims procedure A j( g ); Input: ( S, T, F ) up to date of order j; g E -i-fJ]; Output~ ( S, T, F ) up to date of order j and g ~ S;arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY