CLRS refers to the textbook "Introduction to Algorithms" by Thomas H. Cormen, Charles E. Leiserson, Ronald R. Rivest, and Clifford Stein. It is a standard textbook in algorithms and data structures.
Questions tagged [clrs]
170 questions
-1
votes
1 answer
For a hash table, how does one conclude that n=O(m), where n is the number of elements in the table and m is the number of slots?
On page 260 of CLRS, it says,
If the number of hash-table slots is at least proportional to the number of elements in the table, we have n = O(m) and, consequently, a = n/m = O(m)/m = O(1). Thus, searching takes constant time on average.
How does…

mango
- 1
-1
votes
1 answer
Can someone explain why this heapsort implementation doesn't work?
I've spent a few hours on this, but I am new to c++ object oriented programming so probably some function argument is not passed as it should be, but I cannot find it. For this code I get the following output: 1 2 7 10 3 2 4 15
#include…

Dusan J.
- 303
- 5
- 19
-1
votes
1 answer
Inserting nodes with equal keys in a B-tree
I am trying to insert 3 4s into an empty B-tree. t = 3. I tried some applets online but all thay do is insert 4 once and then just drop 4. Is it the way it has been implemented in CLRS as I did not completely understand their pseudocode.

user3386395
- 1
- 1
-3
votes
1 answer
The Sort method in STL cannot swap contents in a vector
I was trying to implement Kruskal's algorithm (implementation of Introduction to Algorithms CLRS) using C++. But when trying to sort the Edge (which is the class i created) set (which i have implemented as a vector) using std::sort , it doesnt…

Sheikh Abdul Manan
- 81
- 4
-5
votes
2 answers
What should be the algorithm of the below statement?
Can anyone tell me the algorithm for this question?
Q..We can express insertion sort as a recursive procedure as follows. In order to sort A[1..n], we recursively sort A[1..n−1] and then insert A[n] into the sorted array A[1..n−1]. Write a…

prabhupant
- 31
- 8