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
2 answers

Linked-list representation of disjoint sets - omission in Intro to Algorithms text?

Having had success with my last CLRS question, here's another: In Introduction to Algorithms, Second Edition, p. 501-502, a linked-list representation of disjoint sets is described, wherein each list member the following three fields are…
kostmo
  • 6,222
  • 4
  • 40
  • 51
0
votes
2 answers

Implementing a randomized quick sort algorithm

CLRS tells us to exchange A[r] with A[i] where i is a random variable between p and r. However If I were to randomly pick up a variable as the pivot in the quicksort function and exchange the values what will be the time complexity now ? Will the…
Sam Ahuj
  • 17
  • 7
0
votes
2 answers

Heapsort algorithm CLRS

I was implementing a heapsort algorithm in C according to CLRS. However I am unable to get a sorted output. Can you please have a look and tell what is wrong with my code. Functions maxheap and buildmaxheap works. I am not able to figure what is…
Sam Ahuj
  • 17
  • 7
0
votes
0 answers

CLRS Solution 8.4 example of decision tree

Do you have an example of decision tree for this solution problem. I want to draw the decision tree use in response to question (for most understand). But I don't know how to draw this decision tree. By example I don't know what the leaf is used for…
ArDumez
  • 931
  • 6
  • 24
0
votes
0 answers

construction of state machine in string maching in book algorithm by CLRS

Below is text from Introduction to Algorithms by CLRS. Below is code snippet in string matching using finite state automata. Trnstion function is used to construct state table with pattern to be searched. Computing the transition function: The…
venkysmarty
  • 11,099
  • 25
  • 101
  • 184
0
votes
1 answer

How does Fibonacci heap delay work as long as possible?

I am reading CLRS and came across a line "Fibonacci heaps delay works as long as possible".But what does it actually mean by delaying works and how can that be related to performance.
KKGanguly
  • 323
  • 3
  • 13
0
votes
3 answers

A better solution for my approach to create procedure Rand(a,b), using procedure Rand(0,1)

I have been reading CLRS and encountered the problem to write a procedure Rand(a,b) which generates a random number between a to b uniformly at random, using a procedure Rand(0,1) which generates 0 or 1 with 50% probability. I have thought of the…
amiageek
  • 159
  • 10
0
votes
2 answers

Understanding the running time analysis from an exercise of CLRS

Here's the problem I am looking for an answer for: An array A[1...n] contains all the integers from 0 to n except one. It would be easy to determine the missing integer in O(n) time by using an auxiliary array B[0...n] to record which numbers appear…
amiageek
  • 159
  • 10
0
votes
1 answer

Successor and Predecessor worst-case running time in dynamic sets

What is the asymptotic worst-case running time for the following dynamic-set operations ? Successor(L,x) for unsorted singly & doubly linked lists Predecessor(L,x) for unsorted doubly linked list L: list , x: pointer to an entry (Actually this…
Arian
  • 7,397
  • 21
  • 89
  • 177
0
votes
1 answer

confusion about Floyd Warshall example on the Cormen's book

I have read and searched about Floyd Warshall algorithm and i think i understand it. But in the example which i read on the book "Introduction to the Algorithms (Thomas H. Cormen's Book)" i stacked at a point. I confused.Here is a picture which is…
oiyio
  • 5,219
  • 4
  • 42
  • 54
0
votes
2 answers

Suggested reading order and other questions

Based on recommendations from episode 57 of the StackOverflow Podcast, I have purchased "Structure and Interpretation of Computer Programs", "The C Programming Language", "Unix Programming Environment", and "Introduction to Algorithms". I'm wanting…
Jacob Winn
  • 495
  • 1
  • 5
  • 10
0
votes
3 answers

Given an efficient algorithm to solve a system of difference constraint when some of x must be integers

This is an exercise from CLRS 24.4-12,(not homework, I just try to solve the all the exercise in CLRS) Give an efficient algorithm to solve a system Ax ≤ b of difference constraints when all of the elements of b are real-valued and a specified…
meteorgan
  • 246
  • 3
  • 9
-1
votes
1 answer

Where is the error in my solution for T(n) = T(⌈n/2⌉)+1

I am currently working on the chapter 4 of the CLRS and trying to solve an exercice, I want to prove that the solution to T(n) = T(⌈n/2⌉)+1 is O(lg(n)) ( lg in base 2 ). In fact I already succeeded with basic algebric manipulation but I wanted to…
Ryan Talbi
  • 11
  • 4
-1
votes
1 answer

Why is a carry need in CLRS problem 2.1-4 adding two binary array?

CLRS is the book Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein. Problem: Consider the problem of adding two n-bit binary integers, stored in two n element arrays A and B. The sum of the two integers should be stored in…
Memory1
  • 67
  • 1
  • 1
  • 8
-1
votes
2 answers

Prove lower bound using decision tree comparison based model

How would you use a decision tree to prove that searching a sorted list of n elements has the lower bound Omega(log n) with the comparison based model?
Sazz
  • 57
  • 7
1 2 3
11
12