Re: [algogeeks] Search an element in an Infinite array

2011-10-25 Thread Bittu Sarkar
f the sequence is 1,1,1,1,1,1,1,1...infinity? > We need to know the max in order the algorithm is terminating.. > > On Tue, Oct 25, 2011 at 11:32 AM, Bittu Sarkar wrote: > >> @Saurabh There is no biggest number in an infinite array [?] >> >> &g

Re: [algogeeks] Search an element in an Infinite array

2011-10-24 Thread Bittu Sarkar
;> { >> lb = ub; >> ub = (ub*k) / a[ub]; >> } >> >> after end of this loop we'll have a lower bound and upper which should >> provide a narrow scope. >> >> Feedback welcome :-), >> - Ravindra >> >> On Mon, Oct 24, 2011

Re: [algogeeks] adobe question help

2011-10-24 Thread Bittu Sarkar
roup, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Bittu Sarkar 5th Year Dual Degree Student Department of Computer Science & Engineering Indian Institute of Technology Kharagpur

Re: [algogeeks] Search an element in an Infinite array

2011-10-24 Thread Bittu Sarkar
ub] < k) > { > lb = ub; > ub = (ub*k) / a[ub]; > } > > after end of this loop we'll have a lower bound and upper which should > provide a narrow scope. > > Feedback welcome :-), > - Ravindra > > On Mon, Oct 24, 2011 at 7:09 PM, Bittu Sarkar

Re: [algogeeks] Search an element in an Infinite array

2011-10-24 Thread Bittu Sarkar
;> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.c

Re: [algogeeks] Re: Directi Questions - needed answers

2011-10-14 Thread Bittu Sarkar
is message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more optio

Re: [algogeeks] Amazon Question - Find Pythagorean triplet in an unsorted array

2011-10-14 Thread Bittu Sarkar
>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> Regards, >> Rahul Patil >> >> -- >> You received this message because you are subscribed to the Goo

[algogeeks] Re: Ever growing sorted linked list

2011-07-20 Thread bittu
can be done in O(n) find tow nodes from starting position find two nodes p,q such that p < k & k < q as linked list is sorted we have to keep going on in right direction complexity will no less then O(N) as its linked list there is no notion of binary search sorted linked list think out why ? only

[algogeeks] Re: plz explain if the solution is possible with less than 2n-3 comparisons??

2011-07-13 Thread bittu
@shiv here we go to find 2nd best player in array Tournament tree is a form of min (max) heap which is a complete binary tree. Every external node represents a player and internal node represents winner. In a tournament tree every internal node contains winner and every leaf node contains one play

[algogeeks] Re: Improve upon O(m^2)

2011-07-13 Thread bittu
@dumanshu check it Algo is simply start putting elemnt in bigger array by comparing then from last logic is same as merge part of merg sort :) void merge(int[] a, int[] b, int n, int m) { int k = m + n - 1; // Index of last location of array b int i = n - 1; // Index of last element in arra

[algogeeks] Re: Adding w/o +

2011-07-13 Thread bittu
Check the last post of this http://groups.google.com/group/algogeeks/browse_thread/thread/95a593375c62c31d/bf5fab1c88f4b491?lnk=raot#bf5fab1c88f4b491 Thanks Shashank Mani Computer Science Birla Institute of Technology Mesra -- You received this message because you are subscribed to the Google

[algogeeks] Re: Search node in a binary tree

2011-07-13 Thread bittu
@Aniket sorry for delay i was too busy ..but some guys already explained the same u asking for ? Thanks Shashank CSE BIT Mesra -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com.

[algogeeks] Re: How to store largest N values efficiently

2011-07-12 Thread bittu
John You Can Use MinHeap here is the algo 1) Build a Min Heap MH of the first k elements (arr[0] to arr[k-1]) of the given array. O(k) 2) For each element, after the kth element (arr[k] to arr[n-1]), compare it with root of MH. a) If the element is greater than the root then make it root and call

[algogeeks] Re: linked list doubt

2011-07-12 Thread bittu
now try how u will remove the loop from linked list Shashank CSE BIT Mesra -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algog

[algogeeks] Re: remove duplicate chars in a string without using extra memory

2011-07-12 Thread bittu
whats the problem ? if no extra memory allowed then can't be done in better then O(nlogn)sorting time & O(1) space else it will take O(N) time & O(N) Space sorting will change the order but using bitmap or bitarray order will be preserved Thanks Shashank CSE,BIT Mesra -- You received this mes

[algogeeks] Re: remove duplicate chars in a string without using extra memory

2011-07-12 Thread bittu
whats the probelm if no extra memory allowed then can't be done in better then O(nlogn)sorting time & O(1) space else it will take O(N) time & O(N) Space sorting will change the order but using bitmap or bitarray order will be preserved Thanks Shashank CSE,BIT Mesra -- You received this messa

[algogeeks] Re: sbtration

2011-07-12 Thread bittu
Lets Try For Decimal Integer Number how we add them 1 Add 759 + 674, but “forget” to carry I then get 323 2 Add 759 + 674 but only do the carrying, rather than the addition of each digit I then get 1110 3 Add the result of the first two operations (recursively, using the same process de- scribed

[algogeeks] Re: Image based Problem (Google)

2011-07-12 Thread bittu
too store this whole image we need 2^70==10^21 bytes size of disk. assuming each pixel take 1 byte . always go metadata for large entities .here metadata includes type(e.g jpeg,bmp,gif etc),size,name,pointer to log file entry etc. Shashank CSE,BIT Mesra -- You received this message because you a

[algogeeks] Re: Search node in a binary tree

2011-07-12 Thread bittu
whats the problem with this bool search(root,node) { if(root==node) return 1; else return search(root->left,node)||search(root->right,node); } TC O(N) notify me via mail if anything wrong.? Thanks Shashank CSE,BIT Mesra -- You received this message because you are

[algogeeks] Re: Bipartite Matching?

2011-07-07 Thread bittu
@nishit whats the problem with Bipartite Matching ist perfect example of Bipartite Graph isn't it ?? as have to just divide the set of vertex in to two disjoint set such that no two people who are friends will be in same team & that what Bipartite Matching says ?? although graph coloring will also

[algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-07-01 Thread bittu
@Dave I Think So We Can Construct In the same we construct singly linked list ton BST . Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group

[algogeeks] Re: Amazon - Longest palindrome in a string in O(n)

2011-07-01 Thread bittu
sorry for typo that is O(N^2) Thanks Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.

[algogeeks] Re: Amazon - Longest palindrome in a string in O(n)

2011-07-01 Thread bittu
i have posted some time back but that is O(N) , need to code suffix tree will do that asap i get the time. Thanks Shashank CSE BIT Mesra -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegr

[algogeeks] Re: MS

2011-06-30 Thread bittu
lets take the example {1,2, 10, 2, 3, 5, 1, 1,2,3,5,2} clearly min distance is 1 between a=2 & b=5 take variables current=-1 & min=INT_Max so we start from last element say its index is last which is array size -1 & check it with a & b if its equal to any of these then check current !=- && a[curren

[algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-29 Thread bittu
Algorithm: 1.Convert BST into sorted DLL which Will Take O(N) Time(Check previous Posts Already Coded) you can see here "cslibrary.stanford.edu/109" 2.take find sum into DLL two pointer start,end which points to starting & end position of DLL. 3. start from start->data & end->data , keep checking u

[algogeeks] Re: Queue using a stack

2011-06-29 Thread bittu
@ashish Dude you can Have a Look http://shashank7s.blogspot.com/2011/04/wap-to-implement-queue-using-stack.html do notify me if we can optimize the solution..:) Thanks Shashank "I Don't Do Code to Code But I Do Code to Build Product" Computer Science & Engineering Birla Institute of Technology,M

[algogeeks] Re: Amazon telephonic question

2011-06-29 Thread bittu
@juver++ correct @ankit you can see here 1st Approach . You can implement this by having each node in the stack keep track of the minimum beneath itself. Then, to find the min, you just look at what the top element thinks is the min.When you push an element onto the stack, the element is given th

[algogeeks] Re: Yahoo Question

2011-06-29 Thread bittu
1.Use Haddop & Map Reduce Framework .Obviously We Need Distributed Algo we will make one computer as master & assign the job to all slave computer to do the crawling the web depending upon the geographic area ( m thinking real time problem).to crawled the maximum pages in least time we need

[algogeeks] Re: Amazon - max substring

2011-06-29 Thread bittu
use suffix array time will be O(N) e.g. in case of banana answer will be ana you can find more info here http://shashank7s.blogspot.com/2011/06/longest-repeated-substring-eg-maximum.html Thanks Shashank "I Don't Do Code to Code But I Do Code to Build Product" Computer Science & Engineering Bi

[algogeeks] Re: MS Q

2011-06-19 Thread bittu
@harshal every thing seems to be correct m not sure if things will mess up but can we do it in 1 pass ..?? Shashank CSE,BIT Mesra Cracking The Code "shashank7s.blogspot.com" -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this

[algogeeks] Re: MS Q

2011-06-19 Thread bittu
@ross i think u mean s[i]==g[b[i]] or s[i]==g[i] then hit++ isn't it u r not using guess at all as u r comparing character with digit correct me if m wrong Shashank CSE,BIT Mesra -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to

[algogeeks] Re: Finding shortest path in 4-ary tree

2011-06-15 Thread bittu
I think BFS will do That isn't it.?? lets say we have starting node v & wants to find shortest path e.g leaf at lowest height say this node u so when you will do BFS each level will represent the shortest path between two nodes. shortest path=min dist(V,U) DS Used Queue Time Complexity O(N) Co

[algogeeks] Re: Sorting an array - using the foll functions

2011-06-15 Thread bittu
@ ross yes its pancake sorting,although i have code using insertion sort O(N^2) , we can use quick sort to achieve O(nlogn) click here http://shashank7s.blogspot.com/2011/03/pancake-sorting.html Feel Free to Comment Thanks Shashank CSE,BIT Mesra -- You received this message because you are subs

[algogeeks] Find shortest substring that is only occurring once. in Given String

2011-06-14 Thread bittu
I found one interesting question Given a string s , return the shortest substring that is only occurring once. Examples: s="aabbabbaab" gives either "bab" or "baa" s="" gives "" My Approaches Generate All Possible SubStrings O(N^2) puts all substrings into hashtable & keep incrementing c

[algogeeks] Re: solve the series

2011-06-10 Thread bittu
@sunny. ..lol..dude..20 June is My Bro's B'day & 18th Nov is of My mom ...:P Shashank Computer Science & Engg. Birla Institute of Technology, Mesra -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogee

[algogeeks] Re: Google Question

2011-06-04 Thread bittu
i also thought its relative to database but ultimately it also depends on the data structure & Algorithms used by database to implement the particularly query. The simpler implementation of this service is to store, in a database table, a data pair (id, url) where your id has the autoincrement opt

[algogeeks] Re: Google Question

2011-06-04 Thread bittu
well i can speak much on these question.as these algorithms are part of web crawler ..but do u mean we have to detect the duplicate files, by file having same size are duplicates..?? also same question raised by me few days back "Detecting Duplicate Documents" but no one seems to interested u can

[algogeeks] Re: Google Question

2011-06-04 Thread bittu
@Nate...Both TinyUrl & Bit.ly Fails in case of our web address is less then length of their(tinyurl/bit.ly) names.. example if u will try http://www.a.com/a (num of chars 18) in tinyurl.com it will convert http://tinyurl.com/cl3nc4 which 25 chars long & surly greater then original url length so th

[algogeeks] Re: Array Merge Problem

2011-06-03 Thread bittu
@sravanreddy...logical bugs if A is size of n & B is size m from your example assuming n>"The Best Way To Escape From The problem is To Solve It" CSE,BIT Mesra -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send emai

[algogeeks] Re: Facebook

2011-06-03 Thread bittu
First of all i would like to describe the what an event it is.. so In computing an event is an action that is usually initiated outside the scope of a program and that is handled by a piece of code inside the program. I Would Like to Add Some Points & modify the above algo so that it can be coded

[algogeeks] Finding Two Nodes in Binary Tree With maximum Distance Between Them

2011-06-01 Thread bittu
@piyush well i missed the line" find two nodes line" so just coded finding the diameter of tree..& so why in hurray i posted the solution but i found its slightly changed from diameter of BT..anyways let me give approach to solve this problem find the height of left & right sub tree fro each node

[algogeeks] Re: Odd Even Sort array

2011-05-28 Thread bittu
@subramania jeeva ..can we have example with explanation as algorithmic approach is fine..!!! Thanks Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe fr

[algogeeks] Re: spoj--two squares problem

2011-05-27 Thread bittu
@ashish you forget one condition that c=x^2+y^2 iff c= 1 mod(4) e.g. c %4==1 & also x!=y see above link its great & simple. Thanks to Fermat & Euler Thanks Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, s

[algogeeks] Re: Palindrome

2011-05-27 Thread bittu
you its similar kind of problems Already Solve few days back please check Previous threads. Small Modification needed in previous solution .except cost not calculated but all possible palindrome have been generated so hope you can try that & that will help .(Although its slightly Different Question

[algogeeks] Re: suitable data structure

2011-05-27 Thread bittu
@himnashu..Obvious Trie(Data Structure) is best in this case i will suggest you to study Trie deeply & try it.. if you need more clarification, let me know Thanks Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this g

[algogeeks] Re: AMAZON Q

2011-05-24 Thread bittu
@piyuesh..i posted the naive because geeks are so confused about this quest. i have seen some geeks saying terrible time complexity of it. so above approach will make 1st of all every1clear optimization 2ndary step... As i have told earlier its similar to find nth Fibonacci number can be done in

[algogeeks] Re: AMAZON Q

2011-05-24 Thread bittu
@aakash...so above algo is fine & working fine i forget to put else stmt after if otherwise unnecessary comparison so you can add if(finalhttp://groups.google.com/group/algogeeks?hl=en.

[algogeeks] Re: AMAZON Q

2011-05-24 Thread bittu
@all geeks I have already posted it 2-3 forums..here let me post it again its O(n) but the basic idea is clear if got the problem stmt correct then we have to find out the largest Fibonacci number that is small then given number n so say if n=10 then should be 8 for n=13 i=8 n=14 i=13 similarly f

[algogeeks] Re: Find closest point

2011-05-24 Thread bittu
Hi don ..We can Approach Like this this..See we can assume earth as a Sphere & there n points lies on that sphere so if any points lie on that it must satisfy equation of sphere. okk.. then find the distance of all the points from the center of sphere & find the distance of location form center .

[algogeeks] Re: Application of Data Structure In Moview]

2011-05-23 Thread bittu
I think Hash-map With Separate Chaining Will be Best Where Key Will be Name of country & value will be pointer to linked list that will hold all the scene Shooted in that country so hope it pretty clear that as we shooting scene randomly so whenever new scene Shooted put into bucket of Hash-map if

[algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-23 Thread bittu
I don't know u will be happy with this or not but let me explain in simplest way PS: i haven't used division operator anywhere but i also i haven't done using Bit Logic which is efficient then this one but below code work & simplest way to understand This One is the Simply Logical. This will wor

[algogeeks] Re: GOOGLE Q

2011-05-23 Thread bittu
Study Trie & Then Apply It..It Will Work PS: We already have dictionary congaing all the possible words if its not given then we can make the dictionary & then we can find out the all possible anagram of word in constant time O(K) where K is length of each anagram of word W. Hope i m correct Th

[algogeeks] Application of Data Structure In Moview]

2011-05-21 Thread bittu
Which data structure is the most efficient to store and access movie shots. Say, when a movie song is shot, it may include 5 scenes from Switzerland,8 from malaysia, 6 from india etc. and these various scenes shot will be sequenced in the movie song in a random order. Example: When the movie song

[algogeeks] Re: PUZZLE

2011-05-21 Thread bittu
@all you can find the better explanation here , hope it will help http://ashutosh7s.blogspot.com/2011/02/camel-and-banana.html feel free to comment if anything wrong Thanks Shashank Mani>> "Best Way to Escape From Problem is to Solve It" CSE,BIT Mesra -- You received this message because you

[algogeeks] Re: Inversion Count

2011-05-14 Thread bittu
@all i have posted the solution of same problem few times back , search in group thread i used BST & using that inversion count can be calculated in O(nlogn) if you found any error on that then let me know Thanks Shashank CSE,BIT Mesra -- You received this message because you are subscribed to

[algogeeks] Re: Run for a google years

2011-05-13 Thread bittu
@Dave... I think 1 Googol Year is =10^100 not 10^116.5 ?? why u have used so then we have to write the single line program that googol years of time ?? & we have processor that can execute the instruction in 10^9 per second so the time required by googol year in second which is equals to time t

[algogeeks] Re: GOOGLE INTERVIEW QUESTION

2011-05-11 Thread bittu
@all geeks ..check out the algo & solution with detailed explanation here http://shashank7s.blogspot.com/2011/03/wap-to-find-all-possible-palindromes-in.html let me know if it will fail for any test cases Thanks & Regards Shashank Mani >> " The Best Way To Escape From The problem is Solve It" C

[algogeeks] Re: Efficient Way to Detect Duplicate Document

2011-05-09 Thread bittu
@all.here is what i mean Duplicate document detection( taken from IBM Research) Duplicate document detection is a technique that is used to prevent search results from containing multiple documents with the same or nearly the same content. Search quality might be degraded if multiple copies o

[algogeeks] Re: Amazon Interview Question

2011-05-09 Thread bittu
see here & let me know if anything wrong..?? http://shashank7s.blogspot.com/2011/05/wap-to-find-minimum-difference-between.html Thanks & Regrads Shashank >> " the Best Way to Escape From The problem is to Solve it" Computer Science & Engg. BIT Mesra -- You received this message because you ar

[algogeeks] Efficient Way to Detect Duplicate Document

2011-05-03 Thread bittu
suppose You have a billion urls, where each is a huge page. How do you detect the duplicate documents? on what criteria you will detect it, what algorithm , approach , whats will be the complexity of each approach as it has many application in computer science ...i would like to have some good dis

[algogeeks] Re: Need the algorithm or idea

2011-05-03 Thread bittu
in hurryi will suggest you to study TRIE in Detail as Much as you can..Then you will not only get the idea but also you will able to implement & see practical uses of Trie in computer Science Thanks & Regards Shashank Mani -- You received this message because you are subscribed to the Goog

[algogeeks] Re: Do you Think Allocating memory to 2D Array is easy ???

2011-04-30 Thread bittu
although its right .& basic , funny way to allocate the memory , but i was looking fro sum better way to do the same .. Thanks Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googleg

[algogeeks] Do you Think Allocating memory to 2D Array is easy ???

2011-04-29 Thread bittu
Basically we have to implement function which allocates memory to a two dimensional array. we have to Minimize the number of calls to malloc and make sure that the memory is accessible by the notation arr[i][j]. .important part of the question is we have to implement the it using single call to

[algogeeks] Re: Problem regarding MySql server Installation

2011-04-29 Thread bittu
As i remeber you can do this on command prompt type i am assuming u have installed & configured mysql "mysql -u username -p password" i think u shoud have google it Thanks & Regards Shashank Mani>> " The Best Way to escape Fromm problem is Solve It" CSE,BIT Mesra -- You received this message

[algogeeks] Re: Problem regarding MySql server Installation

2011-04-29 Thread bittu
i forget to say that every tool has its own site for documentation & help check it it out http://dev.mysql.com/doc/refman/5.5/en/default-privileges.html Thanks Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group,

[algogeeks] JigSaw Puzzle

2011-04-25 Thread bittu
1 .Design The JizSaw Puzzle Object Oriented Design(OOD) 2 Design the data structures and explain an algorithm to solve the puzzle. No Code Needed, A Good Discussion & Algorithmic, Complexity Discussion is Sufficient Thanks Shashank -- You received this message because you are subscribed to th

[algogeeks] Re: number of inversions

2011-04-24 Thread bittu
HI i found that it Can Be Done Using BST in O(nlogn) see the explaination & then code , let me know if m wrong or anything mising also tryvto dry run yourself /* Explanation we are constructing BST from the array elements and maintaining a count on each node. The idea here is every parent node m

[algogeeks] Interesting...For Geeks ...Dictionary Question

2011-04-13 Thread bittu
Given a dictionary of millions of words, give an algorithm to find the largest possible rectangle of letters such that every row forms a word (reading left to right) and every column forms a word (reading top to bottom). Thanks & Regards Shashank Mani CSE,BIT mesra -- You received this message

[algogeeks] HI object oriented designing ebook with case study Needed

2011-04-05 Thread bittu
If Any1 has OOD ebook & case study put the link here & any good resources across the web or send directly to "shashank7andr...@gmail.com" if you can Thanks & Regards Shashank Mani Computer Science & Engineering BIT Mesra -- You received this message because you are subscribed to the Google Gro

[algogeeks] Re: Algo to identify loose ends of each cable in minimum time.

2011-04-05 Thread bittu
its the The Graham-Knowlton Problem in their paper this proble4ms i published is published goole it you will get answer & explanation Thanks & Regards Shashank Mani CSE, BIT Mesra -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to t

[algogeeks] Re: Facebook Interview Question....Heavy Number

2011-04-05 Thread bittu
@all , Nikhi Jindal ,.as i already told that O(n^2) Solution is Obvious ..but .it wont work for 1Biillion as a time limit exceeds , memory Error occur, so its not a good solution ..I think There is DP Solution Exist For Thats We Need to Figure it Out to resolve this problem @anand what r u trying

[algogeeks] Facebook Interview Question....Heavy Number

2011-04-04 Thread bittu
Hi Geeks, One of The My Friend had This Question in His Technical Round of Facebook, I m going to share with you.lest see how geek approach this...Plz don't make this post spam..by discussing whats ur friend name, wich colge, etc etc..just share your approach, think & solve the question, even Goog

[algogeeks] Re: Microcontroller LED project

2011-04-03 Thread bittu
In Hurray but after seeing ur post,i can tell you, you make code in Assembly Lang. , u can use 8085 Microprocessor & 51 micro-controller its very simple to code to display using assembly80 using 8085 ,i have done may programs in collage using 8085 assembly & don't remember now,,hope it will help

[algogeeks] Re: finds a pair of close numbers

2011-04-02 Thread bittu
Hi , Use Hashing for That , for sum =12 & arr[]={2,4,3,6,5,8,7}; store in to hashtable & for each index=0 in loop find sum-arr[index] so fro sum =12 if we do index=1 a[1]=4 & sum-a[1]=8 so stop it we have done..hope make d perfect code. time Complxity o(n) space size of hashtable Let me me if an

[algogeeks] Re: Ties The Rope With Minimum Cost ..Interesting For Geeks

2011-03-29 Thread bittu
@utkarsh i was just about to put Huffman algo ..yes it is optimized answer to solve the problem @all basicaly we have to minimize the cost of intermediate path ,final o/p will obvious be the same Try Huffman algo 1st read what it is..dan u will able to figure out soln of this problem Hope i am

[algogeeks] Application of Data Structure & System Design

2011-03-29 Thread bittu
Pretend you work for a phone company. At your company, you have a satellite that routes phone calls. We want to bill customers by the maximum number of simultaneous phone calls they make in a single day. ( clarifying questions with the following information: assume no calls last more than 24 hours

[algogeeks] Application of Data Structure & System Design

2011-03-29 Thread bittu
Pretend you work for a phone company. At your company, you have a satellite that routes phone calls. We want to bill customers by the maximum number of simultaneous phone calls they make in a single day. (After asking clarifying questions I received the following information: assume no calls last m

[algogeeks] Re: Check out One More Interesting & Challenging Question...Longest Consecutive Elements Sequence.

2011-03-28 Thread bittu
its (not aplicable). sorting nlogn i said time O(n) & O(1) space i think we can use BST , put all elements in BST O(n) then do inorder to find longest sub sequence still O(n) ..no no no its Ol(ogn) suggest another way to solve it Thanks Shashank -- You received this message because you a

[algogeeks] Check out One More Interesting & Challenging Question...Longest Consecutive Elements Sequence.

2011-03-28 Thread bittu
Given an unsorted array, find the longest consecutive elements sequence. Challenge ...Time Complexity O(n) & Space o(1) Ex: 5 7 3 4 9 10 1 15 12 Ans: will be 3 4 5 (longest with 3 elements) another Example 5,12,3,13,10,9,4,6,23,8,7. The answer should be 3,4,5,6,7,8,9,10. Thanks Shashank --

[algogeeks] Re: Median of Binary Tree

2011-03-28 Thread bittu
@all try to understand the question as usual we have to do it in min. time & space complexity ..in mean Time O(n) & space o(1) At-most just tell em after doing in-order traversal where u will store the elements either in array or in set isn'tit it will take O(n) extra space why not looks fro O(1)

[algogeeks] Ties The Rope With Minimum Cost ..Interesting For Geeks

2011-03-27 Thread bittu
you are given n ropes,maybe of different length. the cost of tying two ropes is the sum of their lengths.Find a way to tie these ropes together so that the cost is minimum. Thanks Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To

[algogeeks] Re: Median of Binary Tree

2011-03-27 Thread bittu
@all wake up geeks Thanks Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For

[algogeeks] Median of Dynamic Stream

2011-03-27 Thread bittu
Numbers are randomly generated and passed to a method. Write a program to find and maintain the median value as new values are generated. Thanks Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to

[algogeeks] Re: compress memory

2011-03-25 Thread bittu
we have to use shuffling algo here i means compaction is technique used for this. google it you will find lot info on this topic hit: os use diff. algo.like best fit, worst fit, next fit,first fit for this , its the part of dynamic partition let me know if you have any difficulty i can post gud in

[algogeeks] Re: generate ques set

2011-03-25 Thread bittu
i think its like the generating the the number with equal probability in given range thats it.if i understood the question correctly so a shuffle algorithm will do that in o(n) like Knuth Shuffle will do it so its like shuffling deck of card with equal probability public static void shuffle(int[

[algogeeks] Merge K Sorted Array In to Single Array

2011-03-25 Thread bittu
Given k sorted arrays each of length n, construct a single merged and sorted array.focus on running time and space complexity my soln. 1st basic soln..simple merge sort all whet we does in merging 2 sorted array it too complex for big K 2nd i have approach using min-heap as well but not able to f

[algogeeks] Median of Binary Tree

2011-03-24 Thread bittu
HI Geeks You Have Given Binary Tree , We need to Find The Median of Binary Tree it BT not BST I have some approach with BST ..lest discuss with you as how you can figure out exactness of the solution for this question Thanks Shashank -- You received this message because you are subscribed to t

[algogeeks] Re: Application of OOD(Object Oriented Design) & System Design -Design Clock Room..??

2011-03-24 Thread bittu
i have only this, one of the my friend asked from me., i post the q here so that we can look different approach Thanks Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com

[algogeeks] An Interesting Question Calculate nth Power of Integer

2011-03-23 Thread bittu
How you will print the 100th power of a single digit( which is of type int). How do you maintain that big number in memory? Lets C The Approach Thank & Regards Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group,

[algogeeks] Application of OOD(Object Oriented Design) & System Design -Design Clock Room..??

2011-03-23 Thread bittu
Design a system to manage clock room ( used at railway station). Like what data structure, how ? U need to give O(1) time solution + small space complexity. Thanks Shashank Mani -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to t

[algogeeks] Application of Prime Number . An Interesting For Geeks

2011-03-23 Thread bittu
yesterday one of the my friends asked this Q to me prove with correctness that "Every even integer greater than 2 can be expressed as the sum of two primes" e.g 4 = 2 + 2 6 = 3 + 3 10 = 7 + 3 or 5 + 5 14 = 3 + 11 or 7 + 7 Explain & Derive The Time ,Space Complexity of Algor

[algogeeks] Re: friend's finder

2011-03-22 Thread bittu
in Hurry but giving approach 1st find the machine suing distributed algorithms from 1000s of server of such big sites i mean we have to 1st find the machine acco. to geographic location of user it gives us machine index say m_index; 2nd then in particular machine apply lookup function i mean then

[algogeeks] Re: Compositions of a number

2011-03-21 Thread bittu
@Ganesha it has been several times here i m re-posting again here have look at it , You can also find it several places by goggling it basically we have to Print all combination of points that can compose a given number Examples: For n = 1, the program should print following: 1 For n = 2, the pr

[algogeeks] Re: prime number using Sieve of Eratosthenes

2011-03-21 Thread bittu
@allWhy Not Try Carziest Thing in This Question Q.1st Prrove Timpe Complexity of Sieve of Eratosthenes is O(Log(Log(n))) ..isn't Making U Stuck..?? Q.2nd We Need to Drease the same Number of element sieved more then one time e.g 6,12 & all the multiples of 2,3 ..then again all the mul

[algogeeks] Re: power of 2

2011-03-21 Thread bittu
hope it will do that unsigned int Log2n(unsigned int n) { return (n > 1)? 1 + Log2n(n/2): 0; } Thank & Regards Shashank Mani -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.c

[algogeeks] Re: Robot Moving on The Maze..Need All possible Path

2011-03-19 Thread bittu
@karans..dude..dude..dude.. 1st thing dat..a s/w engg. can't live without copy & paste..every1 does the samething so nothing new in this. . 2nd is that..whatever one is doing it should help others & understood- able.. okkk..karan..:lol well i don't like spamming but m j

[algogeeks] Application N-ary Tree..Important Question As Well

2011-03-18 Thread bittu
Given an n-ary tree of resources arranged hierarchically. A process needs to lock a resource node in order to use it. But a node cannot be locked if any of its descendant or ancestor is locked. You are supposed to: -> write the structure of node -> write codes for * Islock()- returns true if

[algogeeks] Re: Google puzzles

2011-03-17 Thread bittu
Hi here is the basic approach as we know in a week atmost 7 days ..so start with hit and trial Total 36 medals were awarded and the contest was for 6 days. On day 1: Medals awarded = (1 + 35/7) = 6 : Remaining 30 medals On day 2: Medals awarded = (2 + 28/7) = 6 : Remaining 24 medals On day 3: Me

[algogeeks] A Billion Number Question

2011-03-16 Thread bittu
Given an input file with four billion integers, provide an algorithm to generate an integer which is not contained in the file. Assume you have 1 GB of memory. 2nd Part What if you have only 10 MB of memory? Thank Shashank -- You received this message because you are subscribed to the Google Gr

[algogeeks] A Puzzling Puzzle

2011-03-16 Thread bittu
There is a lake, of square shape. There are four temples on each corner. There is a flower tree next to, say temple no 1. The pond has this magic power, if a flower is dip into the water it doubles the quantity. There is a warning note from the priest, saying "No flower should be wasted". So the p

  1   2   3   4   >