Re: [algogeeks] Re: sort in minimum cost

2011-04-26 Thread snehal jain
@above you cant increment On Tue, Apr 26, 2011 at 3:48 PM, Naveen Agrawal nav.coo...@gmail.comwrote: @snehal jain 4 9 8 7 8 o/p 4 7 7 7 8 cost 3 by decrementing 9 n 8 Yes, now question is clear but your last example is incorrect. 4 9 8 7 8 o/p 4 8 8 8 8 cost 2 = decrementing (9 to 8

[algogeeks] sort in minimum cost

2011-04-25 Thread snehal jain
Given n elements, sort the elements. Here, only one operation is permitted decreaseValue.. Note that you cannot swap the values.. output should be a sorted list.. if input is 4 5 2 1 3 output is 3 3 3.. There can be many answers.. Give the optimum solution with minimum cost. where as cost is the

Re: [algogeeks] Cracking the IT interview: jump start your career with confidence

2011-04-25 Thread snehal jain
++me On Mon, Apr 25, 2011 at 1:14 PM, hary rathor harry.rat...@gmail.com wrote: ++Me -- 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

Re: [algogeeks] Re: sort in minimum cost

2011-04-25 Thread snehal jain
few eg input 4 7 12 3 1 output 4 7 12 cost: 4 by removing 3 n 1 eg 2 6 3 5 7 12 4 o/p 3 3 5 7 12 cost 7 by decrementing 6 by 3 and removing 4 eg 3 4 9 8 7 8 o/p 4 7 7 7 8 cost 3 by decrementing 9 n 8 i hope its clear now.. On Mon, Apr 25, 2011 at 9:16 PM, hary rathor harry.rat...@gmail.com

[algogeeks] minimizes the average completion-time

2011-04-01 Thread snehal jain
Suppose you are given a collection of n tasks that need to be scheduled. With each task, you are given its duration. Specifically, task i takes ti units of time to execute. Suppose with each task we also have a release time ri, and that a task may not be started before its release time.

[algogeeks] finds a pair of close numbers

2011-04-01 Thread snehal jain
For a set S of n real numbers, a pair of elements x, y belong to S, where x y, are said to be close if y – x = ( max(S) – min(S) ) / (n-1) Suppose you are given an unsorted array A[1 : n] of distinct real numbers. Design an algorithm that finds a pair of close numbers in A in O(n) time. my

Re: [algogeeks] minimizes the average completion-time

2011-04-01 Thread snehal jain
research problem and there's plenty of papers on this if you google. On 1 April 2011 13:14, snehal jain learner@gmail.com wrote: Suppose you are given a collection of n tasks that need to be scheduled. With each task, you are given its duration. Specifically, task i takes ti units of time

Re: [algogeeks] Re: generate ques set

2011-03-25 Thread snehal jain
the question again with clear requirements. you have to define what will be the minimized number. minimized to me is eliminated when it can go to 0. On Mar 24, 12:20 pm, snehal jain learner@gmail.com wrote: m*kN . so Mx intersection My is not necessarily empty. so i think your

[algogeeks] compress memory

2011-03-25 Thread snehal jain
Give an algorithm to compress a memory. To be more clear if you are given a memory of some stored data here and there and some empty and null memory in between, how will you fragment and compress your memory? -- You received this message because you are subscribed to the Google Groups Algorithm

[algogeeks] generate ques set

2011-03-24 Thread snehal jain
A question set is given to you and you have to generate (question numbers are in an array) generate different set of question paper for k students. in other words From a total of n questions you have to give m questions to each of the k students such that both the number of repeated questions and

[algogeeks] Design friend of friend function for FB

2011-03-24 Thread snehal jain
Suppose there are 2 persons A and B on FB . A should be able to view the pictures of B only if either A is friend of B or A and B have at least one common friend . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] suggest data structure

2011-03-24 Thread snehal jain
Design a data structure to represent the movement of a knight on a chess board. -- 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

Re: [algogeeks] Re: generate ques set

2011-03-24 Thread snehal jain
, snehal jain learner@gmail.com wrote: A question set is given to you and you have to generate (question numbers are in an array) generate different set of question paper for k students. in other words From a total of n questions you have to give m questions to each of the k students

[algogeeks] subgraph

2011-03-24 Thread snehal jain
You have to create a graph in most efficient way from relationship of nodes read from txt file. text file contains information like: node_id weight node_id node_id weight node_id ….. // which means two nodes are connected with some weight. (undirected) There are around 600K such information for

Re: [algogeeks] predominant colour

2011-03-24 Thread snehal jain
please explain On Thu, Mar 24, 2011 at 10:55 PM, balaji a peshwa.bal...@gmail.com wrote: i think its red On Thu, Mar 24, 2011 at 10:44 PM, snehal jain learner@gmail.comwrote: You are given a blue segment S of length n. There are n points p_i (0 = i n) distributed uniformly at random

[algogeeks] map process to machine

2011-03-22 Thread snehal jain
Given a list of machines where each machine has a hard disk limit and memory capacity and given a list of processes where each process requires certain hard disk space and memory, write an efficient algorithm to match processes to machines. (You may assume process to server mapping is 1:1). --

[algogeeks] friend's finder

2011-03-22 Thread snehal jain
If you want to search for a friend on Facebook, what are the possible strategies that you could use. You are a programmer and can also access Facebook’s Social Graph API. Make your own assumptions. How could you make it a ‘Friend Finder’ app? -- You received this message because you are

Re: [algogeeks] friend's finder

2011-03-22 Thread snehal jain
give the most optimized algo which you can give.. On Tue, Mar 22, 2011 at 6:51 PM, Carl Barton odysseus.ulys...@gmail.comwrote: Are their any requirements on performance? On 22 March 2011 13:05, snehal jain learner@gmail.com wrote: If you want to search for a friend on Facebook, what

[algogeeks] sort partially sorted linked list

2011-03-02 Thread snehal jain
The LL is in alternating ascending and descendin orders. Sort the list efficiently egs: 1-2-3-12-11-2-10-6-NULL -- 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

[algogeeks] c doubt

2011-02-12 Thread snehal jain
does the check x==x+1 always return false for integer x? -- 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] rectangles

2011-02-11 Thread snehal jain
Describe an algorithm that takes an unsorted array of axis‐aligned rectangles and returns any pair of rectangles that overlaps, if there is such a pair. Axis‐aligned means that all the rectangle sides are either parallel or perpendicular to the x‐ and y‐axis. You can assume that each rectangle

[algogeeks] no. of passwords

2011-02-09 Thread snehal jain
how many passwords can be made if 1. there should be atleast 3 capital letters 2. atleast 3 small letters 3. atleast 2 numbers 0-9 4 the password should has length=10 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] no. of passwords

2011-02-09 Thread snehal jain
agrawal sunny816.i...@gmail.comwrote: is it 26C3 * 26C3 * 10C2 * 62C2 * 10! On Wed, Feb 9, 2011 at 7:16 PM, snehal jain learner@gmail.comwrote: how many passwords can be made if 1. there should be atleast 3 capital letters 2. atleast 3 small letters 3. atleast 2 numbers 0-9 4

Re: [algogeeks] no. of passwords

2011-02-09 Thread snehal jain
to consider that so it should be (26^3)*(26^3)*(10^2)*(62^2)*(10!) ?? On Wed, Feb 9, 2011 at 10:20 PM, snehal jain learner@gmail.comwrote: letters and no. can be same... so the ans shd be different On Wed, Feb 9, 2011 at 8:14 PM, Tushar Bindal tushicom...@gmail.comwrote: Are all

[algogeeks] height determination

2011-02-07 Thread snehal jain
You are given a no. of identical balls and a building with N floors. you know that there is an integer X N such that ball will break if it is dropped from any floor X or higher but it will remain intact if dropped from a floor below X. Given K balls and N floors, what is the minimum no. of ball

[algogeeks] missing element limited resource

2011-02-07 Thread snehal jain
given file containing roughly 300 million social security nos. ( 9 digit nos.) find a 9 digit no. that is not in the file. you have unlimited drive space but only 2 megabytes of RAM at your disposal. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Re: Minimum positive-sum subarray

2011-02-03 Thread snehal jain
@ above and the answer to your test case is not 7 its 4 only.. as we have to find min sum...i think u r confusing between max sum and min sum.. On Thu, Feb 3, 2011 at 10:15 PM, snehal jain learner@gmail.com wrote: oh sorry.. i saved the complete ans in my draft and posted half ( as i got

Re: [algogeeks] Re: Minimum positive-sum subarray

2011-02-03 Thread snehal jain
to find min sub array by just switching the comparison operator :) On Fri, Feb 4, 2011 at 12:14 AM, snehal jain learner@gmail.comwrote: @ Above u r finding maximum sum subarray whereas question is asking for minimum On Thu, Feb 3, 2011 at 11:34 PM, Rajiv Podar rajeevpo...@gmail.comwrote

Re: [algogeeks] Re: google questions

2011-02-02 Thread snehal jain
@ above you approach trie needs lot of optimization.. this will take up lot of space...trie is suitable in case where we want to reduce search complexity and its space complexity is very bad.. so hashing should be better here as compared to trie.. i think shashank's solution is better... On

Re: [algogeeks] Re: Minimum positive-sum subarray

2011-02-02 Thread snehal jain
@ above its nt any homework question.. i found it a good question... aftr spending a lot of time i came up with following solution Given Input Array A form the prefix sum array P of A. i.e P[i] = A[1] + A[2] + … + A[i] Now create another array Q of pairs (Value, Index) such that Q[i].Value =

[algogeeks] minimum no. of clicks

2011-02-01 Thread snehal jain
You are given an array A of length N. You have to destroy it, given that you have the power to remove any continuous chunk of same numbers with 1 click. Thus the order in which you remove chunk matters. For example given {1, 2, 3, 1} normally it will take you 4 clicks to remove but if you first

[algogeeks] google questions

2011-01-31 Thread snehal jain
1. how do u find 10 most repeating words on a large file containing words in most efficient way 2. Given a text file, implement a solution to find out if a pattern similar to wild cards can be detected. fort example find if a*b*cd*, or *win or *def* exists in the text. -- You received this

Re: [algogeeks] top search queries

2011-01-31 Thread snehal jain
please give your ideas for this On Fri, Jan 21, 2011 at 2:28 PM, snehal jain learner@gmail.com wrote: Magy! receives a huge amount of queries everyday. They don’t want to store all of them, since many of the queries are unique (submitted just one time by just one user). Anyway

[algogeeks] n segments

2011-01-31 Thread snehal jain
You are given n segments. In turn, you take each one of them and join it with one among those already selected, creating either a loop or a longer segment. How many loops there are in average, at every instant of time? -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: Minimum positive-sum subarray

2011-01-31 Thread snehal jain
; } if(cur min cur0) { x2=i; min=cur; } } return min; } please correct me if the logic is incorrect.. On Sun, Jan 30, 2011 at 12:22 PM, snehal jain learner@gmail.com wrote: @nishanth oh ya right.. On Sun, Jan 30, 2011 at 11:27 AM, nishaanth nishaant

Re: [algogeeks] Maximize the Time to see TV

2011-01-31 Thread snehal jain
or provide some link On Mon, Jan 31, 2011 at 10:44 PM, snehal jain learner@gmail.com wrote: @ juver++ can you please share your approach On Mon, Jan 31, 2011 at 8:43 PM, Divya Jain sweetdivya@gmail.comwrote: @ above ur code fails for following example channel 1 : prog1 8:00-9

Re: [algogeeks] Re: wooden log problem

2011-01-31 Thread snehal jain
vectorvectorint cuts(int n, vectorint A) { int min; int numcuts = A.size(); vectorvectorint Cuts(vectorint V(0,n), n); vectorvectorint Result(vectorint V(0,n), n); for(int i=0;inumcuts;i++) { Cuts[A[i]][A[i]]=0; Cuts[A[i]][A[i+1]]=0; } for(int

[algogeeks] design a data structure

2011-01-30 Thread snehal jain
Design a data structure that supports the following two operations on a set S of integers: a. Insert(x; S), which inserts element x into set S, and b. DeleteLargerHalf(S), which deletes the largest ceil(|S|/2) elements from S. Show how to implement this data structure so both operations take O(1)

Re: [algogeeks] Re: design a data structure

2011-01-30 Thread snehal jain
@juvir++ how is the deletion O(1) ? On Sun, Jan 30, 2011 at 4:14 PM, juver++ avpostni...@gmail.com wrote: 1. Add element to the end of the array. 2. Find median of the array, and partion the array into two sets, the second one (where element = median) is removed. At each operation 2,

Re: [algogeeks] Re: Divide the array into groups

2011-01-30 Thread snehal jain
! On Jan 30, 11:13 am, snehal jain learner@gmail.com wrote: @nishanth divide into groups ( not necessarily 2) in as many group as possible.. such that elements in each group is consecutive another example to clearify A= { 9,7, 13, 11,6,12,8,10,3, 4, 2, 16,14,17,13,15) ans

Re: [algogeeks] Minimum positive-sum subarray

2011-01-29 Thread snehal jain
anyone here? On Fri, Jan 21, 2011 at 2:35 PM, snehal jain learner@gmail.com wrote: In this variation of the Maximum-Sum Subarray Problem, you are given a one-dimensional array A[1 : n] of positive or negative numbers, and you are asked to find a subarray A[i : j] such that the sum of its

Re: [algogeeks] Divide the array into groups

2011-01-29 Thread snehal jain
) .. anyone with better ideas? On Fri, Jan 21, 2011 at 1:20 PM, snehal jain learner@gmail.com wrote: Divide a list of numbers into groups of consecutive numbers but their original order should be preserved. Example: 8,2,4,7,1,0,3,6 Two groups: 2,4,1,0,3 8,7,6 Better than O(n^2

Re: [algogeeks] Divide the array into groups

2011-01-29 Thread snehal jain
, nishaanth nishaant...@gmail.com wrote: @snehal..i guess you are missing something in the question...divide it into 2 groups such that (there should be some other condition or criterion). On Sun, Jan 30, 2011 at 11:29 AM, snehal jain learner@gmail.comwrote: my approach sort in nlogn

Re: [algogeeks] Re: Minimum positive-sum subarray

2011-01-29 Thread snehal jain
AM, snehal jain learner@gmail.comwrote: a friend of mine was asked this question in google interview.. according to me the min element in the array is the answer provided that its not zero.. as 1 element can also be a subarray. but that would solve the problem in O(n) only.. ( this is what

[algogeeks] and or tree

2011-01-27 Thread snehal jain
given a complete binary tree (either a node is a leaf node or has two children) every leaf node has value 0 or 1. every internal node has value as the AND gate or OR gate. you are given with the tree and a value V. you have to output the minimum number of flips (AND to OR or OR to AND) if the

[algogeeks] distinct substring

2011-01-25 Thread snehal jain
given a string find the number of distinct substrings of the string. ex: input- output- 4(a, aa, aaa, ) input-abcd output-10(a, b, c, d, ab, bc, cd, abc, bcd, abcd) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] 2 d matrix

2011-01-25 Thread snehal jain
you have a matrix containing integers (no range provided). The matrix is randomly populated with integers. We need to devise an algorithm where by we find a row number which matches exactly with a column within the matrix. We need to return the row number and the column number for the match. The

[algogeeks] find a way

2011-01-22 Thread snehal jain
Suppose you want to travel from city A to city B by car, following a fixed route. Your car can travel m miles on a full tank of gas, and you have a map of the n gas stations on the route between A and B that gives the number of miles between each station. Design an algorithm to find a way to get

[algogeeks] young tableaus

2011-01-22 Thread snehal jain
. Given n distinct elements, how many Young tableaus can you make? i think the ans is 1!*2!*3!...sqrt(n)!*...*3!*2!*1! plz correct me if i am wrong.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Distance in a dictionary

2011-01-21 Thread snehal jain
You have a dictionary of N words each of 3 chars. Given 2 words you have to find the optimum path between the 2 words. The optimum path contains the words in the dictionary each word at a distance of 1 from the previous word. for eg source = cat , target = sun path is cat - bat - but - bun - sun

[algogeeks] Find the path in two nodes of a binary search tree

2011-01-21 Thread snehal jain
Suppose you have a tree. A binary tree (for something like simplicity :p). You are traversing it (using infix, postfix or prefix) to search for a node. You find your required node. You just realized that you need to know the path from this node back to the root node (and/or vice versa). Given the

Re: [algogeeks] power of 3

2011-01-21 Thread snehal jain
@ above m nt getting binary search and fast exponentiation .. please elaborate. On Fri, Jan 21, 2011 at 2:07 PM, juver++ avpostni...@gmail.com wrote: The most well done solution is to store possible powers of 3 in a table (this table will be small), and then try to find number M. -- You

Re: [algogeeks] Re: pairwise sum

2011-01-21 Thread snehal jain
@ above cn u please explain your logic. On Fri, Jan 21, 2011 at 2:02 PM, juver++ avpostni...@gmail.com wrote: Here is solution from Igor Naverniouk(Google): http://shygypsy.com/tools/pairsums.cpp -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

[algogeeks] top search queries

2011-01-21 Thread snehal jain
Magy! receives a huge amount of queries everyday. They don’t want to store all of them, since many of the queries are unique (submitted just one time by just one user). Anyway, for caching reason they want to understand what are the queries whose frequency exceed s=0.1%. How do you solve the

[algogeeks] Finding elements near the median

2011-01-21 Thread snehal jain
Given an unsorted array A of n distinct numbers and an integer k where 1 = k = n, design an algorithm that finds the k numbers in A that are closest in value to the median of A in O(n) time. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] Minimum positive-sum subarray

2011-01-21 Thread snehal jain
In this variation of the Maximum-Sum Subarray Problem, you are given a one-dimensional array A[1 : n] of positive or negative numbers, and you are asked to find a subarray A[i : j] such that the sum of its elements is (1) strictly greater than zero, and (2) minimum. In other words, you want to

[algogeeks] merging 2 search trees

2011-01-21 Thread snehal jain
You are given two height balanced binary search trees T and T’, storing m and n elements respectively. Every element of tree T is smaller than every element of tree T’. Every node u also stores height of the subtree rooted at it. Using this extra information how can you merge the two trees in time

[algogeeks] array

2011-01-21 Thread snehal jain
Given an array of integers where some numbers repeat 1 time, some numbers repeat 2 times and only one number repeats 3 times, how do you find the number that repeat 3 times. please give if you have solution other than hashing and sorting.. -- You received this message because you are subscribed

Re: [algogeeks] power of 3

2011-01-21 Thread snehal jain
@juvir++ it was mentioned in question not to use log or power. isnt there any approach using bitwise operators On Fri, Jan 21, 2011 at 5:24 PM, Manmeet Singh mans.aus...@gmail.comwrote: this will be O(log(n) * log(n)) solution On Fri, Jan 21, 2011 at 4:29 PM, abhijith reddy

Re: [algogeeks] power of 3

2011-01-21 Thread snehal jain
@manmeet how? On Fri, Jan 21, 2011 at 7:36 PM, Manmeet Singh mans.aus...@gmail.comwrote: @juver++ : the above is a user defined function. but its possible to the problem using bit wise operators. On Fri, Jan 21, 2011 at 7:29 PM, juver++ avpostni...@gmail.com wrote: @above it's a

[algogeeks] sorted array inplace merge

2011-01-21 Thread snehal jain
Given an integer array of which both first half and second half are sorted. Write a function to merge the two parts to create one single sorted array in place [do not use any extra space]. e.g. If input array is [1,3,6,8,-5,-2,3,8] It should be converted to: [-5,-2,1,3,3,6,8,8] i have thought of

[algogeeks] Maximize the Time to see TV

2011-01-20 Thread snehal jain
There is a TV avid person. HE wants to spend his max time on TV. There are N channels with different program of different length and diff times. WAP so that the person cam spend his max time watching TV. Precondition: If that person watches a program, he watches it completely. Ex: Channel1: prog1

[algogeeks] pairwise sum

2011-01-20 Thread snehal jain
If pairwise sums of ‘n’ numbers are given in non-decreasing order identify the individual numbers. If the sum is corrupted print -1 Example: i/p: 4 4 5 7 10 12 13 o/p: 1 3 4 9 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] zig zag

2011-01-20 Thread snehal jain
A sequence of numbers is called a zig-zag sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a zig-zag sequence. For

[algogeeks] power of 3

2011-01-20 Thread snehal jain
Given M, find if M = 3^x for some positive integer x efficiently. DO NOT think of log, pow etc -- 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] Divide the array into groups

2011-01-20 Thread snehal jain
Divide a list of numbers into groups of consecutive numbers but their original order should be preserved. Example: 8,2,4,7,1,0,3,6 Two groups: 2,4,1,0,3 8,7,6 Better than O(n^2) is expected. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] master thm

2011-01-16 Thread snehal jain
The running time of an algorithm is represented by the following recurrence relation: if n = 3 then T(n) = n else T(n) = T(n/3) + cn Which one of the following represents the time complexity of the algorithm? acc to me O(n) is the answer? but on the site it was O(nlogn).. so plz

[algogeeks] google written

2011-01-14 Thread snehal jain
Write the code to find lexicographic minimum in a circular array, e.g. for the array BCABDADAB, the lexicographic mininum is ABBCABDAD. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] [amazon] data transfer

2011-01-13 Thread snehal jain
there are two systems and transfer a data of 1TB. The hardware is best possible available. Tell the conditions which will optimize the data transfer. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: Find The Looping Node

2011-01-13 Thread snehal jain
@ above your code is only detecting loop.. my code is detecting loop and then removing loop as well On Thu, Jan 13, 2011 at 5:04 PM, bittu shashank7andr...@gmail.com wrote: @snehal ..although ur approach ir good but u make d problem little complex,also missed out little checking, it can be

[algogeeks] probability

2011-01-13 Thread snehal jain
An unbalanced dice (with 6 faces, numbered from 1 to 6) is thrown. The probability that the face value is odd is 90% of the probability that the face value is even. The probability of getting any even numbered face is the same. If the probability that the face is even given that it is greater than

[algogeeks] google paper/...plz help..its urgent

2011-01-12 Thread snehal jain
1. Quick-sort is run on two inputs shown below to sort in ascending order (i) 1,2,3, ….,n (ii) n, n - 1, n - 2, …., 2, 1 Let C1 and C2 be the number of comparisons made for the inputs (i) and (ii) respectively. Then, a) C1 C2 b) C1 C2 c) C1 = C2 d) We cannot say anything for arbitrary n 2. Which

[algogeeks] google mcqs

2011-01-12 Thread snehal jain
A 4-stage pipeline has the stage delays as 150, 120, 160 and 140 ns (nano seconds) respectively. Registers that are used between the stages have a delay of 5 ns each. Assuming constant clocking rate, the total time taken to process 1000 data items on this pipeline will approximately be a. 120 us

Re: [algogeeks] google mcqs

2011-01-12 Thread snehal jain
, Jan 12, 2011 at 3:15 PM, snehal jain learner@gmail.com wrote: A 4-stage pipeline has the stage delays as 150, 120, 160 and 140 ns (nano seconds) respectively. Registers that are used between the stages have a delay of 5 ns each. Assuming constant clocking rate, the total time taken

[algogeeks] twin pair

2011-01-11 Thread snehal jain
you will be given an input no. n u have to output nth twin pair.. for eg input 1 output(3,5) input 5 output (29,31) twin pair is a pair in which prime no. differ by 2.. (3,5) , (5,7) (11,13), (17,19) (29,31) -- You received this message because you are subscribed to the Google Groups Algorithm

[algogeeks] amazon c questn

2011-01-11 Thread snehal jain
what is the wrong in the program? main() { char *p,*q; p=(char *)malloc(25); q=(char *)malloc(25); strcpy(p,amazon); strcpy(q,hyd); strcat(p,q); printf(%sp); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

[algogeeks] kth largest in tree

2011-01-11 Thread snehal jain
how to find kth largest in bst. u cnt use static/global variable and u cnt pass value of k to any function. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from

Re: [algogeeks] amazon c questn

2011-01-11 Thread snehal jain
sorry that was typing error.. anything else wrong except that? as it seems correct to me... On Tue, Jan 11, 2011 at 10:31 PM, Arpit Sood soodfi...@gmail.com wrote: its correct, only a comma is missing in printf line: printf(%s,p); On Tue, Jan 11, 2011 at 10:14 PM, snehal jain learner

Re: [algogeeks] Serialization in BT

2011-01-08 Thread snehal jain
store inorder and preoder traversal of tree in arrays.. On Sat, Jan 8, 2011 at 5:49 PM, bittu shashank7andr...@gmail.com wrote: Design an algorithm and write code to serialize a binary tree. Regards SHahsank -- You received this message because you are subscribed to the Google Groups

[algogeeks] binary

2011-01-08 Thread snehal jain
Given a (decimal - e.g.3.72) number that is passed in as a string, print the binary rep¬resentation.If the number can not be represented accurately in binary, print “ERROR -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] Re: difference x

2010-12-23 Thread snehal jain
bhupendra's solution is right.. On Thu, Dec 23, 2010 at 1:04 PM, jai gupta sayhelloto...@gmail.com wrote: make another array(B) from (A) with all elements negated now find one element from B and one from A whose sum is x or -x. This can ofcourse be done in O(n). -- You received this

Re: [algogeeks] Re: Array Ranking Problem

2010-12-23 Thread snehal jain
hint : use dp On Thu, Dec 23, 2010 at 8:30 PM, Davin dkthar...@googlemail.com wrote: Marks for Questions(1,6): {10,15,20,25,10,20} Time for Each Questions(1,6) : { 2, 4,3,4, 2,4} Passing Marks : 40 Out of 100 Find Questions with minimum time to pass the exam? On Dec 23, 7:04 pm, juver++

[algogeeks] difference x

2010-12-22 Thread snehal jain
How will you find the pair from an sorted array whose difference is x -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: difference x

2010-12-22 Thread snehal jain
@saurabh u might be a genius bt for ur kind information this is the group for learners... this group is a place where people come to learn new tricks, put their ideas and ask doubts.. so it would have been better if u had put your response rather than discouraging anyone from asking doubts..

Re: [algogeeks] Find The Looping Node

2010-12-22 Thread snehal jain
@ above well this a ver old and easy problem.. but unlike u, criticizing others wen u knw the solution i wud rather post my solution.. int removeCycle(list head) { struct listnode * slow, *fast,*slow; slow=fast=head; do { if(!fast || ! fast-next) rteurn -1;

Re: [algogeeks] Re: difference x

2010-12-22 Thread snehal jain
, snehal jain learner@gmail.com wrote: @saurabh u might be a genius bt for ur kind information this is the group for learners... this group is a place where people come to learn new tricks, put their ideas and ask doubts.. so it would have been better if u had put your response

Re: [algogeeks] Re: difference x

2010-12-22 Thread snehal jain
@ saurabh its fine.. nd can u plz tell ur soln to this prob.. i hv figured out an O(n) solution.. bt b4 dat i wanna knw ur solution.. On Wed, Dec 22, 2010 at 10:31 PM, rajat ahuja catch.rajatah...@gmail.comwrote: nyone like to post solution of ths problem, On Wed, Dec 22,

[algogeeks] smallest cycle

2010-12-21 Thread snehal jain
The question is to find the length of the smallest cycle in a bipartite graph G=(V,E) (V - vertices, E - edges). Required time complexity: O(|V|^2) A given graph is bipartite iff it has no odd length cycles. -- You received this message because you are subscribed to the Google Groups

[algogeeks] shortest distance

2010-12-21 Thread snehal jain
Given a chessboard in which it is not known how the black and white boxes are arranged but it is sure that there will 32 black squares and 32 white squares. You have to find the least possible distance between any two squares of same colour. -- You received this message because you are

[algogeeks] Find the element with more than n/k occurrences

2010-12-21 Thread snehal jain
You are given an (unsorted) set of n integers. Given some k (1 k = n), you are required to find and return the element of the set that has more than n/k occurrences. Return None otherwise. Required (best known) time complexity: O(n log k) I thought of something... Lets scan each element one by

[algogeeks] Maximum points on a straight line

2010-12-21 Thread snehal jain
You are given a set of 'n' points on a two dimensional plane. Now, draw a straight line such that it can pass through maximum number of points. Return the maximum number of points. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

[algogeeks] random function

2010-12-21 Thread snehal jain
How do you write your own random function? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com.

[algogeeks] array partition

2010-12-21 Thread snehal jain
There is an array, how will you partition that into two parts so that the sum of both the sub set is minimum -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from

[algogeeks] sort

2010-12-21 Thread snehal jain
Given an array having 16000 unique integers, each lying within the range 12, how do u sort it. U can load only 1000 numbers at a time in memory -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] median

2010-12-21 Thread snehal jain
You have n machines contains n integer. How will you find the median of n^2 element. Only 2n number can be loaded in the memory -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To

[algogeeks] palindrome

2010-12-21 Thread snehal jain
Algorithms to check if binary representation of a number is palindrome or not -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

[algogeeks] 1s and 0s

2010-12-21 Thread snehal jain
I want to see if all the ones in a number appear on the right side of the number and all zeros appear on the left, how can I do this most efficiently? (i.e. 0111 is true but 100010 is false) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.

[algogeeks] number

2010-12-21 Thread snehal jain
If you are given a number as a parameter, write a function that would put commas after every third digit from the right -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To

[algogeeks] complete tree

2010-12-21 Thread snehal jain
If there are two structs, TreeNode and Tree. TreeNode contains 3 elements, data, lChild and rChile. Tree contains 2 elements, int size and TreeNode *root. The tree is a complete tree. So how to find a O(logN) approach to insert a new node -- You received this message because you are subscribed

[algogeeks] sorting is done based on string sorting

2010-12-21 Thread snehal jain
How to output the number in a sorted way in which The sorting is done based on string sorting and not on numerical (Eg:121 comes before 2 because the Most Significant Digit is 1 in 121 which is less than 2) disp(int low, int high); disp(5, 1113); Required Output is: 10 100 1000 11 12 . . 19 101

  1   2   >