
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

Transcribed Image Text:num
01
6
output
This exercise uses sub-algorithms. Trace it for when input value is 6 and complete the trace tables. Also
note that there are two variables name num, one in the main algorithm and another in the sub-algorithm.
They are not related. Assume input is a positive integer. Write pre- post-conditions for each of these
algorithms (the main one and the sub-algorithm). Note that the prime sub-algorithm is similar to the
algorithm in Ex 1) but instead of reading input and producing outputs, it has a parameter num, and it
returns the result. Also note that the =true is in gray color, which means it can be ignored. Note that since
the sub-program is called several times, it's better that you use separate trace tables, one for each call, as
shown below.
start
num
i ← 2
i←i + 1
i
T
prime(i) = true
T
i≤ num
end
F
F
prime(num)
start
flag ← true
d-2
flag = true and
d≤num/2
num mod d=0
T
flag ←false
d+ d + 1
ret flag
F
num flag d
2
returned value
num flag
3
d
num flag d
4
returned value
returned value

Transcribed Image Text:Trace the following flowchart for when input values are 12, 3, -3, 6, 11, 3, -1, -2 and complete the trace
table. Also, write pre- post-conditions for this flowchart.
start
cnt1 (0
cnt2-0
i (1
i←i+1
num
num<0
T
cnt1 a cnt1 +1
i<1
i←i+1
num
is 4
cnt1=cnt2
"yes"
(end)
T
num>0
T
cnt2 cnt2 + 1
F
is 4
T
F
F
"no"
F
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 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
- Suppose that we reach a point in algorithm where we then to decide to execute one of set of steps if the variable x has a value greater than or equal to zero or another set of steps if x has a value less than 0. In pseudo-code, show how one would address this situation in an algorithm.arrow_forwardQUESTION 11 Algorithm one has time complexity f, that is O(n°) and algorithm two has time complixity f2 that is 0(10n°). Which algorithm is faster for large inputs? Algorithm one is faster. Algorithm two is faster. The two algorithms are equally fast. We can not tell from the information given.arrow_forwardFor each of the following algorithm in pseudo-code, indicate the time efficiency using BigTheta (Θ) notation. You need to 1) identify the basic operation, and 2) justify your results by doing summation or listing and solving the recurrence relation of T(n), which is the number of basic operations.It is your decision to make on the method you use to solve the recurrence. Question 1) for i = 3 to n dofor j = 1 to i doa[i][j]= 0; Question 2) Algorithm f(n): if n==1 return 1; return 2*f(n-1)+ n*n*n;arrow_forward
- Please provide a correct answer with a full explanation by yourself. Don't copy. Thank you.arrow_forward5arrow_forwardQuestion 1 Suppose a large group of people in a room were all born in the same year. Consider the following three algorithms, which are each intended to identify the people in the room who have the earliest birthday based on just the month and day. For example, a person born on February 10 is considered to have an earlier birthday than a person born on March 5. Which of the three algorithms will identify the correct people? I. All the people in the room stand up. All standing people form pairs where possible, leaving at most one person not part of a pair. For each pair, the person with the earlier birthday remains standing, while the other person in the pair sits down. If there is a tie, both people sit down. Any individual not part of a pair remains standing. Continue doing this until only one person remains standing. That person has the earliest birthday. II. All the people in the room stand up. All standing people form pairs with another standing person that they have not previously…arrow_forward
- Determine the expected case running time of the algorithm. Fully justify your solution. Determine the best case running time of the algorithm and state what condition must be true forit to occur. No justification is needed! Determine the worst case running time of the algorithm and state what condition must be true forit to occur. No justification is needed!arrow_forwardAlgorithmarrow_forwardA binary searching algorithm has logarithmic ?(log?) performance. It takes a second to find an item in a list of 10,000 entries. How long do you expect it to take to find an item in a list of 50,000,000 entries? How did you arrive at your answer?arrow_forward
- Construct a trace table to trace the action of the algorithm below for the input variables given. a := 53, d := 11 r:= a, q := 0 while (r 2 d) r:=r- d 9 := q + 1 end while iteration 1 2 3 a 53 d 11 53arrow_forwardAnalysis of Algorithm: The number of operations executed by algorithms A and B is 40n2 and 2n3, respectively. Determine a n0 such that A is better than B for n >= n0arrow_forwardNo plagarism please! Correct and detailed answer will be Upvoted else downvoted. Thank you!arrow_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