Questions tagged [clrs]

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.

170 questions
0
votes
1 answer

CLRS solution seems meaningless as one line make me skeptical

Problem: Show that RANDOMIZED-SELECT never makes a recursive call to a 0-length array. Hint: Don't assume that the input array is empty, i.e., p>r. Rather, show that if an empty (sub-)array is ever generated by RANDOMIZED-PARTITION, then a…
Encipher
  • 1,370
  • 1
  • 14
  • 31
0
votes
0 answers

What exactly is the constant in regards to algorithms from CLRS?

Afternoon guys and gals, First and foremost, I hope all is well. I have been reviewing CLRS 3rd edition and was wondering exactly what is the constant value in regards to algorithm. (a.k.a where is it visualized/manifested in the code) For instance,…
0
votes
0 answers

Analyzing dynamic programming solutions to different maximum subarray problems

I was trying out some dynamic programming problems. I came across the following problems: 1. Maximum (consecutive) subset-sum Finding the maximum sum of any consecutive set of elements in the given input array. One possible solution is as…
Mahesha999
  • 22,693
  • 29
  • 116
  • 189
0
votes
1 answer

How does Kruskal and Prim change when edge weights are in the range of 1 to |V| or some constant W?

I'm reading CLRS Algorithms Edition 3 and I have two problems for my homework (I'm not asking for answers, I promise!). They are essentially the same question, just applied to Kruskal or to Prim. They are as follows: Suppose that all edge weights…
0
votes
1 answer

The interpretation of expected time bound for searches in a hash table

As CLRS book,page 260 stated, I wouldn't have any problem if the author says the bound is eventually or even What kind of theories shall we apply to simplify the original result, i.e, cancelling the factor 1/n of a. Since n is one of inputs of…
absuu
  • 340
  • 1
  • 11
0
votes
1 answer

What's wrong with this merge sort code I have done from the CLRS?

Wrong output! I have tried each and every condition but failed to get the real result I tried to accomplish this from the clrs book pseudo-code but I failed. I am trying to write merge sort using iterators to implement myself pseudo-code in c…
mcop
  • 3
  • 2
0
votes
2 answers

Can't find a way to modify cormen's mergeSort algorithm into a 3 way merge

I have an assignment about modifying Cormen's merge sort algorithm into a 3 way merge. My instructor does not like outside book materials, so I am strictly abiding by cormen's algorithm. Now, I have tried to do that, but how ever it shows something…
0
votes
2 answers

MergeSort: Is my problem from incorrect indeces or instance variables with recursion

I'm currently reading CLRS while also trying to learn C++. As you can imagine everything is going great! I've been stuck on understanding MergeSort but over the last couple days have made good progress and feel like my code is almost there. P.S.…
Liebmann5
  • 11
  • 2
0
votes
1 answer

Does time complexity differ of the implementation of algorithms in different programming languages?

Are not algorithms supposed to have the same time complexity across any programming language, then why do we consider such programming language differences in time complexity such as pass by value or pass by reference in the arguments when finding…
0
votes
1 answer

Why are not the way parameters/arguments passed considered for the time complexity of an algorithm?

Is it not true that depending on the language that way the parameters/arguments are passed will have a different time complexity. Then why is this not factored in or considered in the algorithms or programs that books measure time complexity of?…
0
votes
1 answer

Error in implementing a Red black Tree using a sentinel object, in Java

So, I am trying to implement insertion for a red black tree, using sentinels as described in the "Introduction to Algorithms". I've created a Generic class for a red black node, which has type parameter as its data attribute and the other…
0
votes
2 answers

Implementing the pseudocode using matrix:

I need to implement the following code however in a matrix form. I need to get the source vertex and randomly generate the connected graph. However, the pseudo-code is in the list form and I am not sure if I converted it to the matrix form…
Misu
  • 69
  • 1
  • 6
0
votes
1 answer

what is meaning n average compared from array with length x in QuickSort

in this formula and continue this question I think if we assume n equal 3 so we have array like A={4,5,7} and with the formula, we get 8 from n=3 and this means is 8 average compare for array with length 3 and this so weird! what is exactly…
Michael
  • 51
  • 1
  • 8
0
votes
1 answer

what is meaning expected value(math) and what reason behind it in quickSort?

I need help interpreting the formulas from the Quicksort algorithm description in the Clrs book, page 157 My questions are overlayed in the page screenshot. This formula is about QiuckSort Algorithm. what is behind(logic) E[X] ... I mean what is…
Michael
  • 51
  • 1
  • 8
0
votes
1 answer

The Randomized algorithm Parody

I was reading CLRS and I was stuck at question 5.1-2. Describe an implementation of the procedure RANDOM(a,b) that only makes calls to RANDOM(0,1).What is the expected running time of your procedure, as a function of a and b? The solution written…