Practice Set for Recurrence Relations
Last Updated :
23 May, 2025
A recurrence relation is an equation that expresses each term of a sequence as a function of its preceding terms. In other words, it defines a sequence where each term depends on one or more of its previous terms. Recurrence relations commonly arise in divide-and-conquer algorithms, dynamic programming, and combinatorial problems.
Below are practice problems with solutions on recurrence relation.
Problem 1:
Solve the following recurrence relation?
7T(n/2)+3n2+2
Options:
(a) O(n2.8)
(b) O(n3)
(c) θ(n2.8)
(d) θ(n3)
Correct answers: (a), (b), and (c)
Explanation:
- a = 7, b = 2, f(n) = 3n2 + 2
- c = 2 for f(n) = O(nc)
- logba = log27 ≈ 2.81 > 2
- By Master Theorem case 1, T(n) = θ(n2.81)
- This implies O(n2.8) and O(n3) as well.
Problem 2:
Sort the following functions in decreasing order of their asymptotic (big-O) complexity:
- f1(n)=n√n
- f2(n)=2n
- f3(n)=(1.000001)n
- f4(n)=n10⋅2n/2
Options:
(a) f2 > f4 > f1 > f3
(b) f2 > f4 > f3 > f1
(c) f1 > f2 > f3 > f4
(d) f2 > f1 > f4 > f3
Correct answer: (b) f2 > f4 > f3 > f1
Explanation:
- f2 > f4 because 2n = 2n/2⋅2n/2 and f4 = n10⋅2n/2
- f4 > f3 because f4=n10⋅(1.414)n and 1.414n grows faster than 1.000001n
- f3 > f1 since log f3=nlog(1.000001) grows faster than logf1 = √nlogn
Problem 3:
Given: f(n)=22n, which of the following correctly represents f(n)?
Options:
(a) O(2n)
(b) Ω(2n)
(c) Θ(2n)
(d) None of these
Correct answer: (b) Ω(2n)
Explanation:
- 22n = (2n)2
- f(n) grows faster than 2n
- f(n) ≥ c⋅2nf(n) some c, so Ω(2n) holds.
- O(2n) and Θ(2n) do not hold because f(n) grows faster.
Problem 4:
Master’s theorem can be applied on which of the following recurrence relations?
Options:
(a) T(n) = 2T(n/2) + 2n
(b) T(n) = 2T(n/3) + sin(n)
(c) T(n) = T(n − 2) + 2n2 + 1
(d) None of these
Correct answer: (d) None of these
Explanation:
- Master theorem applies to recurrences of form T(n) = aT(n/b) + f(n) where f(n) is polynomial or monotonic.
- (a) is invalid because f(n) = 2n is exponential, not polynomial.
- (b) is invalid because sin(n) is not monotonic.
- (c) is a decreasing function recurrence (not dividing), so Master theorem does not apply here in the usual form.
Problem 5:
Given: T(n) = 3T(n/2 +47) + 2n2 + 10n − 1/2
What is the order of T(n)?
Options:
(a) O(n2)
(b) O(n3/2)
(c) O(nlogn)
(d) None of these
Correct answer: (a) O(n2)
Explanation:
- For large n, n/2 + 47 ≈ n/2
- So, T(n) ≈ 3T(n/2) + O(n2)
- By Master theorem: a = 3, b = 2, f(n) = O(n2)
- log23 ≈ 1.58 < 2, so case 3 applies.
- T(n) = O(n2)
Read in detail about Recurrence Relation here.
Similar Reads
DSA Tutorial - Learn Data Structures and Algorithms DSA (Data Structures and Algorithms) is the study of organizing data efficiently using data structures like arrays, stacks, and trees, paired with step-by-step procedures (or algorithms) to solve problems effectively. Data structures manage how data is stored and accessed, while algorithms focus on
7 min read
SQL Commands | DDL, DQL, DML, DCL and TCL Commands SQL commands are crucial for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will e
7 min read
Data Structures Tutorial Data structures are the fundamental building blocks of computer programming. They define how data is organized, stored, and manipulated within a program. Understanding data structures is very important for developing efficient and effective algorithms. What is Data Structure?A data structure is a st
2 min read
Merge Sort - Data Structure and Algorithms Tutorials Merge sort is a popular sorting algorithm known for its efficiency and stability. It follows the divide-and-conquer approach. It works by recursively dividing the input array into two halves, recursively sorting the two halves and finally merging them back together to obtain the sorted array. Merge
12 min read
Quick Sort QuickSort is a sorting algorithm based on the Divide and Conquer that picks an element as a pivot and partitions the given array around the picked pivot by placing the pivot in its correct position in the sorted array. It works on the principle of divide and conquer, breaking down the problem into s
12 min read
DBMS Tutorial â Learn Database Management System Database Management System (DBMS) is a software used to manage data from a database. A database is a structured collection of data that is stored in an electronic device. The data can be text, video, image or any other format.A relational database stores data in the form of tables and a NoSQL databa
7 min read
Bubble Sort Algorithm Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order. This algorithm is not suitable for large data sets as its average and worst-case time complexity are quite high.We sort the array using multiple passes. After the fir
8 min read
Binary Search Algorithm - Iterative and Recursive Implementation Binary Search Algorithm is a searching algorithm used in a sorted array by repeatedly dividing the search interval in half. The idea of binary search is to use the information that the array is sorted and reduce the time complexity to O(log N). Binary Search AlgorithmConditions to apply Binary Searc
15 min read
Breadth First Search or BFS for a Graph Given a undirected graph represented by an adjacency list adj, where each adj[i] represents the list of vertices connected to vertex i. Perform a Breadth First Search (BFS) traversal starting from vertex 0, visiting vertices from left to right according to the adjacency list, and return a list conta
15+ min read
Introduction of ER Model The Entity-Relationship Model (ER Model) is a conceptual model for designing a databases. This model represents the logical structure of a database, including entities, their attributes and relationships between them. Entity: An objects that is stored as data such as Student, Course or Company.Attri
10 min read