Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Consider the following recurrence
Algorithm 1 REVERSE
1. function REVERSE(A)
2. if |A| = 1 then
3. return A
4. else
5. Let B and C be the first and second half of A
6. return concatenate REVERSE(C) and REVERSE(B)
7. end if
8. end function
Let T(n) be the running time of the algorithm on an instance of size n. Write down the recurrence relation for T(n) and solve it
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Algorithm Binary Search Input: L = a1, a2, ... , an list of distinct integers; x integer Output: p integer i = 1; j = n; found = F; p = 0; while i ≤ j and found = F m = ⌊i+j2⌋; if am = x then found = T and p = m else if am < x then i = m + 1 else j = m - 1; return p; When performing Algorithm Binary Search with input L = 1,3,5,7,9,11,13 and x = 9, how many times is x compared to an element ai of the list L?arrow_forwardMake AST Nodes: IfNode, WhileNode, RepeatNode. All will have BooleanCompare for a condition and a collection of StatementNode. ForNode will have a Node for from and a node for to. This will have to be of type Node because it could be any expression. For example: for a from 1+1 to c-6 Make parsing functions for each. Java won't let you create methods called if(), etc. parseIf() is an example of a way around that; use whatever you like but use good sense in your names. Next let's look at function calls. Each function has a name and a collection of parameters. A parameter can be a VAR variable or something that came from booleanCompare (IntegerNode, VariableReferenceNode, etc). It would be reasonable to make 2 objects - ParameterVariableNode and ParameterExpressionNode. But for this very simple and well-defined case, we can do something simple: ParameterNode has a VariableReferenceNode (for VAR IDENTIFIER) and a Node for the case where the parameter is not a VAR. One more thing -…arrow_forwardWhy does binary search take less time than linear search, and what variables lead to this reduction? It would be helpful if you explained your actions.arrow_forward
- the drop down bar is the selection you have to choose from for each answerarrow_forward6. Which of the following code snippet performs linear search recursively?arrow_forwardConsider the following recursive algorithm Algorithm Q(n)// Input: a positive integer nif n == 1 return 1else return Q(n-1)+2*n-1 1) Set up a recurrence relation for this function’s value and solve it to determine what this algorithm computes. 2) Setup a recurrence relation for the number of multiplication made by this algorithm and solve it to find the total number of multiplications that are executed.arrow_forward
- 1. Determine the running time of the following algorithm. Write summations to represent loops and solve using bounding. Be sure to show work on both the upper bound and lower bound, justify the split, and check that the bounds differ by only a constant factor. Use asymptotic notation to write the answer. Func1(n) 1 2 3 4 5 6 7 8 9 10 11 S← 0; for i ←n to n² do for j← 1 to i do for k9n to 10n² do for mi to k end end end return (s); end s+s + i- j + k −m;arrow_forward15. Code to Recurrence Relation What is the recurrence relation of the runtime of the following algorithm: T(n) represents the time it takes to complete func called with the parameter n value n. def func(n): if n == 0: return print(n) func(n//2) func(n//3) Pick ONE option T(n) = T(n-1) + T(n-2) + C; T(1) = C T(n) = T(n-2) + T(n-3) + C; T(1) = C T(n) = T(n/2) + T(n/3) + C; T(1) = C T(n) = T(n-5) + C; T(1) = C Clear Selection 81arrow_forwardQuestion 2: Recurrences (a) Below is the pseudo-code for two algorithms: Practicel (A,s,f) and Practice2(A,s,f), which take as input a sorted array A, indexed from s to f. The algorithms make a call to Bsearch(A,s,f,k) which we saw in class. Determine the worst-case runtime recurrece for each algorithm: T1(n) and T2(n). Show that T(n) is O((log n)²) and T2(n) is O(n log n). Practicel (A,s,f) if s< f ql = L(s+ f)/2] if BSearch(A,s,ql,1) = true Practice2(A,s,f) if s < f if BSearch(A,s+1,f,1) = true return true return true else else return Practice2(A, s, f-1) return Practicel(A, ql+1, f) else else return false return falsearrow_forward
- The recursive algorithm below takes as input an array A of distinct integers, indexed between s andf, and an integer k. The algorithm returns the index of the integer k in the array A, or ?1 if the integerk is not contained within A. Complete the missing portion of the algorithm in such a way that you makethree recursive calls to subarrays of approximately one third the size of A.• Write and justify a recurrence for the runtime T(n) of the above algorithm.• Use the recursion tree to show that the algorithm runs in time O(n).FindK(A,s,f,k)if s < fif f = s + 1if k = A[s] return sif k = A[f] return felseq1 = b(2s + f)=3cq2 = b(q1 + 1 + f)=2c... to be continued.else... to be continued.arrow_forwardPlease show and explain so I can nderstand.arrow_forwardA* search is optimal with an admissible search heuristic Select one: True Falsearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education