(b) Write the properties of Red-black trees. Explain why red-black trees require less rotations than AVL trees

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Algorithms

Write whether the following statements are true or false. If true, prove why
it is true. If false, give a counter example or proof. Assumen is an integer
that is greater than 0.
(а) 11"
(b) Given that the time to execute an algorithm with n elements is T (n),
where T(n) = 3T(n/2) + n², then the complexity of the algorithm is
O(n²)
(c) The computational complexity of the code given below is O(n³/2). The
value of k = vn
1.
6 is divisible by 5 for all values of n > 1
int sum (int n)
{ int sum=0;
for (int i=0; i<n;i=i+k)
{
for(int j=0; j<i;j++)
{ sum=sum+1; }
}
return sum; }
(d) The number of red internal nodes in a red-black tree will always be
less than the number of black internal nodes
(e) Given a set of n numbers with range of values for 1 to n?. Sorting
using counting sort will be faster than sorting using merge sort.
Transcribed Image Text:Write whether the following statements are true or false. If true, prove why it is true. If false, give a counter example or proof. Assumen is an integer that is greater than 0. (а) 11" (b) Given that the time to execute an algorithm with n elements is T (n), where T(n) = 3T(n/2) + n², then the complexity of the algorithm is O(n²) (c) The computational complexity of the code given below is O(n³/2). The value of k = vn 1. 6 is divisible by 5 for all values of n > 1 int sum (int n) { int sum=0; for (int i=0; i<n;i=i+k) { for(int j=0; j<i;j++) { sum=sum+1; } } return sum; } (d) The number of red internal nodes in a red-black tree will always be less than the number of black internal nodes (e) Given a set of n numbers with range of values for 1 to n?. Sorting using counting sort will be faster than sorting using merge sort.
Sorting and Red-Black Trees
(a) Consider a sequence of sorted numbers, for example 1, 2, 3, 6, 7, 8, 9.
We rotate this sequence k times from left to right. For example for
k = 1, the sequence will be 2, 3, 6, 7, 8, 9, 1, for k = 3 the sequence will
be 6, 7,8, 9, 1, 2, 3.
Given a sequence of n numbers that has been sorted k times, develop
a O(n) algorithm to find the value of k. Note that the lowest number
need not necessarily be 1. You can assume that all numbers are unique.
Explain the steps of your algorithm
Prove that the complexity is O(n)
iii. Using the cxample 6, 7, 8, 9, 2, 3, 1, show that your algorithm
2.
i.
ii.
finds the k=3
(b) Write the properties of Red-black trees. Explain why red-black trees
require less rotations than AVL trees
(c) Show all the steps of creating a red-black tree for the following set of
numbers; { 3,5,6,2,1,4}
Transcribed Image Text:Sorting and Red-Black Trees (a) Consider a sequence of sorted numbers, for example 1, 2, 3, 6, 7, 8, 9. We rotate this sequence k times from left to right. For example for k = 1, the sequence will be 2, 3, 6, 7, 8, 9, 1, for k = 3 the sequence will be 6, 7,8, 9, 1, 2, 3. Given a sequence of n numbers that has been sorted k times, develop a O(n) algorithm to find the value of k. Note that the lowest number need not necessarily be 1. You can assume that all numbers are unique. Explain the steps of your algorithm Prove that the complexity is O(n) iii. Using the cxample 6, 7, 8, 9, 2, 3, 1, show that your algorithm 2. i. ii. finds the k=3 (b) Write the properties of Red-black trees. Explain why red-black trees require less rotations than AVL trees (c) Show all the steps of creating a red-black tree for the following set of numbers; { 3,5,6,2,1,4}
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Introduction to computer system
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education