Re: [algogeeks] Re: If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2011-06-23 Thread sourav roy
Can anybody mail me this. Thanks, Sourav On Thu, Jun 23, 2011 at 9:56 PM, Swathi chukka.swa...@gmail.com wrote: Can someone send it to me please... Thanks, Swathi On Thu, Jun 23, 2011 at 12:13 PM, pullasunil pullasu...@gmail.com wrote: Can you mail me the book for Algorithms

[algogeeks] Re: Binary Tree Amazon

2011-02-22 Thread sourav
My implementation tries to create a doubly linked list, each node of which will hold the value of sum of all nodes in a particular vertical.If there is no requirement for the final output to state vertical number against the sum (and indeed there is no such requirement in the question ), then my

[algogeeks] Re: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.

2011-01-08 Thread sourav
:07 am, yq Zhang zhangyunq...@gmail.com wrote: @sourav, As Juvier++ pointed out, it's an **amortized** O(n) algorithm. That's because each element can be at most popped twice. Thanks Yq On Mon, Jan 3, 2011 at 11:20 AM, sourav souravs...@gmail.com wrote: @yq Zhang, To pop if you

[algogeeks] Re: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.

2011-01-03 Thread sourav
are constant time. Thanks, Sourav On Jan 3, 9:44 pm, yq Zhang zhangyunq...@gmail.com wrote: Push into one stack. When pop first pop all from the first stack and push into the second stack. Then pop from the second stack  On Jan 3, 2011 7:42 AM, MOHIT mohit...@gmail.com wrote: if only two

[algogeeks] Happy Diwali!

2010-11-05 Thread sourav sain
Wish you and your family a Bright and Prosperous Diwali. Regards, Sourav [image: diwali-diyas.jpeg]?ui=2ik=4f1ebe5da5view=attth=12c1a980b57e423fattid=0.1disp=inlinerealattid=f_gg4neyjf0zw -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group

[algogeeks] Re: Smallest window of K[] in N[]. Best order solution

2010-10-25 Thread sourav
complexity, where you use a matrix of side (length of array 1)X(length of array 2) is known to me. I am looking for a better order solution. Thanks for your time. Sourav On Oct 23, 10:53 pm, nishaanth nishaant...@gmail.com wrote: It is nothing but a common subsequence problem...isnt it ? On Wed, Oct

[algogeeks] Google Question: Find kth largest of sum of elements in 2 array

2010-10-06 Thread sourav
you are given 2 arrays sorted in decreasing order of size m and n respectively. Input: a number k = m*n and = 1 Output: the kth largest sum(a+b) possible. where a (any element from array 1) b (any element from array 2) The Brute force approach will take O(n*n). can anyone find a better logic.

[algogeeks] Duplicate in an array

2010-10-05 Thread sourav
You are given an array of positive numbers in which one number is repeated. Rest all are present only once. Find the duplicate number in linear or sub linear time. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] Re: kmp

2010-09-29 Thread sourav
@Anuj You will find the implementation in the book Algorithms on Strings, Trees and Sequences: Computer Science and Computational Biology by Dan Gusfield Chapter 3 Exact Matching: A Deeper Look at Classical Methods Section 3.5.3 Sourav On Sep 18, 11:51 am, ANUJ KUMAR kumar.anuj...@gmail.com

[algogeeks] Re: do this: two numbers with min diff

2010-09-28 Thread sourav
based on the fact that min heap can be constructed from an array in linear time. Thanks, Sourav On Sep 27, 1:32 pm, rahul rahulr...@gmail.com wrote: If their is no constrain on assumptions. 1.Sort the array. 2. check the dif between 2 elements. { 99,35,45,33,88,9098,112,33455,678,3} sorted

[algogeeks] Re: ALgo help pls

2010-09-28 Thread sourav
a for loop into code above (given by @Dave) to find if majority element has 2n/3 occurance. Thanks, Sourav On Sep 22, 9:02 am, Navin Naidu navinmna...@gmail.com wrote: Use majority vote algorithm: http://userweb.cs.utexas.edu/~moore/best-ideas/mjrty/index.html On Wed, Sep 22, 2010 at 9:12 AM, pre

[algogeeks] Re: search a 2d sorted array in less than O(n)

2010-09-27 Thread sourav
O(n) solution. Please provide your comments in any Thanks Sourav On Sep 27, 11:09 am, prodigy 1abhishekshu...@gmail.com wrote: Actual complexity of above algorithm = O(n^1.6) On Sep 27, 8:19 am, Gene gene.ress...@gmail.com wrote: If the array is m by n, pick the element a[m/2][n/2], i.e

[algogeeks] Re: sum of primes

2010-09-27 Thread sourav
@Dave I cannot see any code at the links you have provided. I only see the prime numbers. am I missing something here..? Thanks, Sourav On Sep 23, 10:59 pm, Rishi Agrawal rishi.b.agra...@gmail.com wrote: Apart from 1, 2 and 3, all the prime numbers are either of the form (6*n - 1) or (6*n

[algogeeks] Re: finding largest and second largest elements

2010-09-27 Thread sourav
Very Nice Simple approach @Dave On Sep 24, 12:56 am, Dave dave_and_da...@juno.com wrote: Do a single-elimination tournament of the numbers, where the larger wins each game. This will take n/2 + n/4 + ... + 1 = n-1 comparisons. The second largest will be among the numbers that lost to the

[algogeeks] Re: BST in BT

2010-09-27 Thread sourav
most child) InsertNode(tree-left,temp); Do share your views. Thanks, Sourav On Sep 27, 7:58 am, prodigy 1abhishekshu...@gmail.com wrote:                    15                   /    \                8      25                       /    \                   20      22 On Sep 26, 10:45 am

[algogeeks] Re: On random number generation

2010-09-13 Thread sourav
All of them are correct. You need to verify that the probability of getting each of the numbers from 0 to 7 are same. In the example given by Gene, here is the explanation below: rand04()rand04()5*rand04() Sum Sum/3 0 0 0 0 0 1 0 0

[algogeeks] On random no. generation

2010-09-11 Thread sourav
You are given a random no. generator function rand04() that generates random numbers between 0 and 4 (i.e., 0,1,2,3,4) with equal probability. You have to design a random no. generator function rand07() that generates numbers between 0 to 7 (0,1,2,3,4,5,6,7) using rand04() such that rand07()

[algogeeks] Re: Amazon: sort array

2010-08-26 Thread sourav
this is O(n) will be of great help. Thanks in Advance. Sourav On Jul 3, 1:35 am, Abhishek Sharma jkabhishe...@gmail.com wrote: @Anand: good one On Sat, Jul 3, 2010 at 2:02 AM, Anand anandut2...@gmail.com wrote: This is an example of bitonic sequence if we reverse the bottom half of the array

[algogeeks] Sorting when n-√n numbers are already sorted

2010-08-26 Thread sourav
Let A[1..n] be an array such that the first (n − √n) elements are already sorted (though we know nothing about the remaining elements). Give an algorithm that sorts A in substantially better than (n log n) steps. This question is from chapter 4 : Algorithm Design Manual by S Skiena -- You

[algogeeks] Re: Sorting when n-√n numbers are alre ady sorted

2010-08-26 Thread sourav
@Rahul Agree with your approach. When you say merge the last root(n) elements with the starting elements, it means you are doing something like merge sort using an additional O(n) space. Correct me if I am wrong. This should give O(n) overall time complexity. How about an in - place approach?

[algogeeks] How strong is your quick sort fundamental?

2010-08-25 Thread sourav
The median of a set of n values is the \lceil n/2 \rceilth smallest value. 1. Suppose quicksort always pivoted on the median of the current sub-array. How many comparisons would Quicksort make then in the worst case? 2. Suppose quicksort were always to pivot on the n/3 th smallest value of

[algogeeks] Re: Generate all bit strings of length n

2010-08-13 Thread sourav
consider a link list l which can contain nodes representing the bits GenerateBitStrings(int length) { if (length == 0) { //print all values in link list l } Add 1 to l call GenerateBitString(length-1) Remove the 1 that was added. Add 0 to l call GenerateBitString(length-1)

[algogeeks] Complexity of Algorithms [√n and log ( n^2)]

2010-07-31 Thread sourav
f(n) = sqrt(n) [squate root of n] g(n) = log(^2) [log of (n square)] For the above pair of functions is f(n) = Ω(g(n))? i.e., is there some c 0, such that f(n) = g(n) for all n? Give proof in case answer is yes or no.

[algogeeks] Re: Complexity of Algorithms [√n and l og (n^2)]

2010-07-31 Thread sourav sain
A small correction. You need to prove if f(n) = O(g(n)). My Proff (under Note) is for f(n) = Ω(g(n)) On Sat, Jul 31, 2010 at 12:08 AM, sourav souravs...@gmail.com wrote: f(n) = sqrt(n) [squate root of n] g(n) = log(^2) [log of (n square)] For the above pair of functions is f(n) = Ω(g(n

[algogeeks] Merging Companies Problem

2010-07-31 Thread sourav
Suppose we start with n companies that eventually merge into one big company. How many different ways are there for them to merge? With three companies {a,b,c}, we need to find the number of ways that the three companies can become two companies, and for every one of those possibilities, the two

[algogeeks] Re: ALGORITHM

2010-07-29 Thread sourav
@Shiv Collision is itself a wel known issue in hashing and much need to be done to avoid collision. When you say your appraoch is hash the numbers, how do u make sure without knowing the nature of the numbers that you can hash them without bringing ing collision of inequal items of the array?

[algogeeks] On Complexity of Algorithm

2010-07-28 Thread sourav
A sorting algorithm takes 1 second to sort 1,000 items on your local machine. How long will it take to sort 10,000 items ... if you believe that the algorithm takes time roughly proportional to nlogn? [Show your calculations / logic to arive at an answer] -- You received this message because

[algogeeks] Re: ALGORITHM

2010-07-28 Thread sourav
@akshay Does the array contain numbers in the range 1 to n? On Jul 28, 8:16 pm, akshay akshayrastogi2...@gmail.com wrote: An array of unsorted numbers n is given with one no.repeated once ie n-1 distinct nos to find duplicate no. in o(n) complexity -- You received this message because you