[algogeeks] Re: Search an element in a sorted and pivoted array

2012-08-29 Thread mohit
1.) Find the pivot point. to find pivot – for a sorted (in increasing order) and pivoted array, pivot element is the only only element for which next element to it is smaller than it. 2.) divide the array into two subarray and apply binary search. for calling binary search in two subarray - if

[algogeeks] Re: Search an element in a sorted and pivoted array

2012-08-28 Thread Dave
@Rahul: Please tell us what you mean by a pivoted array. Dave On Tuesday, August 28, 2012 12:56:03 PM UTC-5, rahul sharma wrote: plz provide me algo for this,thnx -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on

Re: [algogeeks] Re: search in O(logn)

2012-06-09 Thread partha sarathi Mohanty
smthng like this... *if*(arr[mid] arr[mid + 1]) return mid; if(arr[low] arr[mid]) return findPoint(arr, low, mid-1); else return findPoint(arr, mid + 1, high); On Sat, Jun 9, 2012 at 12:36 AM, Hassan Monfared hmonfa...@gmail.comwrote: Hi pharta : find the point where

[algogeeks] Re: search in O(logn)

2012-06-08 Thread Dave
@Hassan: This is not possible without additional conditions. E.g., you cannot find the 1 in the array {0,0,0,...,0,1,0,0,...,0} in less than O(n) time. But with the condition that the elements of the array are pairwise distinct, you can use a binary search to find k such that a[k-1] a[0]

Re: [algogeeks] Re: search in O(logn)

2012-06-08 Thread Hassan Monfared
Yes, Thanks Dave. for non-distinct items It's not possible. On Fri, Jun 8, 2012 at 6:44 PM, Dave dave_and_da...@juno.com wrote: @Hassan: This is not possible without additional conditions. E.g., you cannot find the 1 in the array {0,0,0,...,0,1,0,0,...,0} in less than O(n) time. But with

Re: [algogeeks] Re: search in O(logn)

2012-06-08 Thread partha sarathi Mohanty
It is easy.. find the point where it is rotated to get 14-1 O(log(n)) since 214 that means u have to find it in subarray [123].. do a binary search here o(long(n)) final 2*O(log(n))... On Fri, Jun 8, 2012 at 7:44 PM, Dave dave_and_da...@juno.com wrote: @Hassan: This is not possible without

Re: [algogeeks] binary search tree over btree

2012-04-05 Thread sanjiv yadav
In BST the height can be made as bad as u can but in case of btree the height can not be more than log n base 2 because for each internal node it is necessary to have at least 2 child and here all the leaf nodes must be at the same label. On Sun, Apr 1, 2012 at 8:34 PM, arun kumar

[algogeeks] binary search tree over btree

2012-04-01 Thread arun kumar
hi i just like to know when you will go for binary search tree over btree. advantage and disadvantage, application of both of them. thank you in advance Regards, Arun kumar -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

[algogeeks] Binary Search Tree Question

2012-02-09 Thread Rahul Menon
What does this function do? void function(Node **node){ if(*node!=NULL){ function((*node)-Left); Node *temp; temp = (*node)-Left; (*node)-Left= (*node)-Right; (*node)-Right = temp;

Re: [algogeeks] Binary Search Problem

2012-01-13 Thread gvk
These may be of interest as well: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5045582 https://webcache.googleusercontent.com/search?q=cache:onpOivQX668J:googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html+cd=1hl=enct=clnkclient=ubuntu On Sunday, January 8, 2012

[algogeeks] Binary Search Problem

2012-01-08 Thread Sanjay Rajpal
In binary search, mid = start + (end-start)/2 is used to avoid overflow, as said by a book. why can't we use mid = (start + end)/2, it says this statement may result in overflow ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra

Re: [algogeeks] Binary Search Problem

2012-01-08 Thread saurabh singh
not clear what you are trying to ask...can you quote exactly from the book? Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sun, Jan 8, 2012 at 4:34 PM, Sanjay Rajpal srn...@gmail.com wrote: In binary search, mid = start + (end-start)/2 is used to

Re: [algogeeks] Binary Search Problem

2012-01-08 Thread Sanjay Rajpal
actually book pages are images. My question is why second statement may result in overflow ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286, +91-9729683720 * On Sun,

Re: [algogeeks] Binary Search Problem

2012-01-08 Thread atul anand
@Sanjay: suppose Max_INT range is 300 now suppose end=300 and start =2 now using (start+end)/2 i.e *302*/2 but 302 goes out of range for and interger type as assumed... but if we use start + (end-start)/2 THEN 2 + (300-2)/2 , i.e 2+ *298*/2 here 298 300 hence it within int_Max range which

Re: [algogeeks] Binary Search Problem

2012-01-08 Thread Sanjay Rajpal
@Atul : got it. thanx :) * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Sun, Jan 8, 2012 at 3:27 AM, atul anand atul.87fri...@gmail.com wrote: @Sanjay: suppose

Re: [algogeeks] Binary Search Problem

2012-01-08 Thread sravanreddy001
@atul: +1, i too thought the same this comes handly esp, when the derived datatypes are used with a range limitations. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

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

2011-10-24 Thread Ankuj Gupta
What is the logic on choosing power of two as search indexes ? On Oct 24, 12:56 am, Ankur Garg ankurga...@gmail.com wrote: Use Binary Search start = 2^n-1 high =2^n where n=0,1 On Mon, Oct 24, 2011 at 12:28 AM, sunny agrawal sunny816.i...@gmail.comwrote: hint 1: try to find 2

[algogeeks] Re: Search an array of unknown length

2011-08-23 Thread vikas
nopes, you need to know where the hell it ends even if this is a string , it ends with convention of ending 0. in case it is stream , we know the data length. in case of array, above mentioned approach should work. sizeof(arr)/sizeof(arr[0]) if you are given only a pointer and no length, you

Re: [algogeeks] Re: Search an array of unknown length

2011-08-23 Thread sagar pareek
@saurabh u are getting sizeof(a)/sizeofa[0] =1 coz fiest one is pointer and second one is integer...both's size is 4 do it without passing http://www.ideone.com/8olTP On Tue, Aug 23, 2011 at 1:28 PM, vikas vikas.rastogi2...@gmail.com wrote: nopes, you need to know where the hell it ends

Re: [algogeeks] Re: Search an array of unknown length

2011-08-23 Thread saurabh singh
Well sir I am fully aware why this is hapening.Kindly reread what I wrote .*what if we are given only the address of the array.* I personaly feel anyone who asked the question never expected this to be the answer.(using sizeof). On Tue, Aug 23, 2011 at 2:42 PM, sagar pareek

Re: [algogeeks] Re: Search an array of unknown length

2011-08-23 Thread sagar pareek
hmm ok my mistake of reading On Tue, Aug 23, 2011 at 6:56 PM, saurabh singh saurab...@gmail.com wrote: Well sir I am fully aware why this is hapening.Kindly reread what I wrote .*what if we are given only the address of the array.* I personaly feel anyone who asked the question never

Re: [algogeeks] Re: Search an array of unknown length

2011-08-22 Thread saurabh singh
@dave or anyone??? response please On Sun, Aug 21, 2011 at 12:43 PM, saurabh singh saurab...@gmail.com wrote: kkk...not sure assume no number is greater than 1000(I mentioned There has to be some additional constraints to make the problem solvable) Now check 1st element if not the

[algogeeks] Re: Search an array of unknown length

2011-08-22 Thread asdqwe
If i am not wrong, the only possible solution can be len=sizeof(arr)/sizeof(arr[0]) i.e. find the length from the array itself. On Aug 22, 9:01 pm, saurabh singh saurab...@gmail.com wrote: @dave or anyone??? response please On Sun, Aug 21, 2011 at 12:43 PM, saurabh singh

Re: [algogeeks] Re: Search an array of unknown length

2011-08-22 Thread saurabh singh
That would take all the fun awaywhat if you are given only the address of the array?This wont work in that case On Mon, Aug 22, 2011 at 10:39 PM, asdqwe ayushgoel...@gmail.com wrote: If i am not wrong, the only possible solution can be len=sizeof(arr)/sizeof(arr[0]) i.e. find the length

Re: [algogeeks] Re: Search an array of unknown length

2011-08-22 Thread saurabh singh
Just a small code to back up my point... http://www.ideone.com/woRiT On Tue, Aug 23, 2011 at 7:33 AM, saurabh singh saurab...@gmail.com wrote: That would take all the fun awaywhat if you are given only the address of the array?This wont work in that case On Mon, Aug 22, 2011 at 10:39

Re: [algogeeks] Re: Search an array of unknown length

2011-08-21 Thread saurabh singh
kkk...not sure assume no number is greater than 1000(I mentioned There has to be some additional constraints to make the problem solvable) Now check 1st element if not the desired element keep multiplying with 2 the previous range till either one of these condition is satisfied *1.An exception

Re: [algogeeks] Re: Search an array of unknown length

2011-08-20 Thread saurabh singh
@dave may be its a bit offtopic,(and may be stupid) but if the numbers are in a small range (say 1 to 1000) isn't the probability that the absolute garbage value would be greater than the array elements(assuming garbage to be bits of random 0's and 1's)?Assuming we have not entered into some other

[algogeeks] Re: Search an array of unknown length

2011-08-19 Thread Dave
@Everyone: The problem says that the array is of UNKNOWN length, but all of the solutions presented assume that the array is of INFINITE length. Suppose, e.g., that the length is 987, but you don't know that. Then it will be meaningless to probe at 1, 10, 100, 1000, etc, or 1, 2, 4, ..., 512, 1024

Re: [algogeeks] Re: Search an array of unknown length

2011-08-19 Thread sagar pareek
Well sorry but i forget to mention exceptions in the solution. Here is the complete solution :- The key idea here is to simultaneously do a binary search for the end of the array as well as the key. We try to look for A[2k ] in the k-th step and catch exceptions for successive values of k till

Re: [algogeeks] Re: Search an array of unknown length

2011-08-19 Thread Sanjay Rajpal
Well in that case additive approach will work. Sanju :) -- 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] Re: Search an array of unknown length

2011-08-19 Thread Dave
@Sagar: So far so good, but you are not guaranteed to get an exception. Example, int a[987] is followed in memory by char b[1000], which is a dictionary. You won't detect an exception until you get to at least a[262144] (2 to the 18th). But you will pick up plenty of garbage which may throw

Re: [algogeeks] Re: Search an array of unknown length

2011-08-19 Thread sagar pareek
thanks for pointing it out On Sat, Aug 20, 2011 at 12:16 AM, Dave dave_and_da...@juno.com wrote: @Sagar: So far so good, but you are not guaranteed to get an exception. Example, int a[987] is followed in memory by char b[1000], which is a dictionary. You won't detect an exception until

[algogeeks] binary search

2011-07-31 Thread aditi garg
How to optimise binary search so dat it makes only one comparison instead of 2 dat it generally does?? -- 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

Re: [algogeeks] binary search

2011-07-31 Thread Anurag atri
int Modified_BinarySearch(int A[], int N, int value) { int low = 0; int high = N; while (low high) { int mid = (low + high)/2; if (A[mid] value) low = mid + 1; else

[algogeeks] binary search tree question!!!!

2011-07-28 Thread AMAN AGARWAL
Please tell the solution of this question Given a Binary Search Tree, write a program to print the kth smallest element without using any static/global variable. You can’t pass the value k to any function also -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to

Re: [algogeeks] Re: Search node in a binary tree

2011-07-13 Thread sameer.mut...@gmail.com
Guys i always have this doubt.Please tell me whether stack frames allocated for each recursive call will be cleared if we return in the middle of a recursive call? On Tue, Jul 12, 2011 at 10:22 PM, Don dondod...@gmail.com wrote: // Similar to other suggestions, but without tail recursion. ptr

Re: [algogeeks] Re: Search node in a binary tree

2011-07-13 Thread Anand Saha
On Wed, Jul 13, 2011 at 1:40 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: Guys i always have this doubt.Please tell me whether stack frames allocated for each recursive call will be cleared if we return in the middle of a recursive call? In normal condition, the return

[algogeeks] Re: Search node in a binary tree

2011-07-12 Thread Don
There is no reason to use recursion to search a binary tree. Don On Jul 12, 8:28 am, anonymous procrastination opamp1...@gmail.com wrote: Hello, Suppose you have to search a particular node in a binary tree. The code is quite simple. Pick up any traversal and see if any node matches the

[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

Re: [algogeeks] Re: Search node in a binary tree

2011-07-12 Thread Aniket Dutta
@bittu On 7/12/11, Aniket Dutta aniketdutt...@gmail.com wrote: what will happen if node is not found?. you are not checking it On 7/12/11, bittu shashank7andr...@gmail.com wrote: whats the problem with this bool search(root,node) { if(root==node) return 1; else

Re: [algogeeks] Re: Search node in a binary tree

2011-07-12 Thread Aniket Dutta
what will happen if node is not found?. you are not checking it On 7/12/11, bittu shashank7andr...@gmail.com wrote: whats the problem with this bool search(root,node) { if(root==node) return 1; else return search(root-left,node)||search(root-right,node); }

Re: [algogeeks] Re: Search node in a binary tree

2011-07-12 Thread ankit sambyal
@Aniket: Just add a condition at the begining: if(root == NULL) return 0; -- 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: Search node in a binary tree

2011-07-12 Thread Aniket Dutta
@yeah right On Tue, Jul 12, 2011 at 7:36 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Aniket: Just add a condition at the begining: if(root == NULL) return 0; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] Re: Search node in a binary tree

2011-07-12 Thread Aniket Dutta
@bittu On Tue, Jul 12, 2011 at 8:09 PM, Aniket Dutta aniketdutt...@gmail.comwrote: @yeah right On Tue, Jul 12, 2011 at 7:36 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Aniket: Just add a condition at the begining: if(root == NULL) return 0; -- You received this message

Re: [algogeeks] Re: Search node in a binary tree

2011-07-12 Thread Aniket Dutta
sorry @ankit On Tue, Jul 12, 2011 at 8:10 PM, Aniket Dutta aniketdutt...@gmail.comwrote: @bittu On Tue, Jul 12, 2011 at 8:09 PM, Aniket Dutta aniketdutt...@gmail.comwrote: @yeah right On Tue, Jul 12, 2011 at 7:36 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Aniket: Just add a

[algogeeks] Re: Search node in a binary tree

2011-07-12 Thread Don
// Similar to other suggestions, but without tail recursion. ptr search(ptr root, int value) { ptr result = 0; while(root !result) { result = (root-tag == value) ? root : search(root-left, value); root = root-right; } return result; } On Jul 12, 8:28 am,

Re: [algogeeks] Google Search by Image

2011-06-21 Thread Raghavan
An idea which strikes to mind is, 1.Initially to form a map based on the text and all related text to it.[text,images]map 2.Also make a bitwise manipulation of every image and relate the texts to it.[imagebitwise,texts] map 3.If a image is put forth for search, check the texts from

Re: [algogeeks] Google Search by Image

2011-06-21 Thread DK
There are specific algorithms for image matching. One of the more famous ones is to use Wavelet coefficients. Wavelet Coefficients are resolution independent ways of representing image content (The image data is mapped into a 0-1 2D space). You can perform a 2D difference analysis of the

[algogeeks] A* search

2011-05-13 Thread eric
Hi All, A* search with consistent heuristics is supposed to ensure that an optimal path to a repeated state is always the first path generated, but consider the following example: /---4---A(h=15)--30--\ S(h=18)G (h=0) \

Re: [algogeeks] binary search for Linked List?

2011-03-10 Thread priya mehta
use skip list:) On Thu, Mar 10, 2011 at 2:31 PM, ravi teja ravitejal...@gmail.com wrote: @Utkarsh : Yeah , that is when you can access any element in O(1) time and the elements are sorted.This happens in a sorted array where you get an overall complexisty of O(logn). -- You received

Re: [algogeeks] binary search for Linked List?

2011-03-10 Thread UTKARSH SRIVASTAV
what is skip list On Fri, Mar 11, 2011 at 5:58 AM, priya mehta priya.mehta...@gmail.comwrote: use skip list:) On Thu, Mar 10, 2011 at 2:31 PM, ravi teja ravitejal...@gmail.com wrote: @Utkarsh : Yeah , that is when you can access any element in O(1) time and the elements are sorted.This

Re: [algogeeks] binary search for Linked List?

2011-03-09 Thread UTKARSH SRIVASTAV
but as far as i know binary search takes O(logn)time tosearch an element On Tue, Mar 8, 2011 at 9:35 PM, ravi teja ravitejal...@gmail.com wrote: Yes , it is possible . But it does not make sense . The thing that matters while doing binary search for arrays is that we can access any

[algogeeks] binary search for Linked List?

2011-03-08 Thread Sudhir mishra
Is it possible to implement -- 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 more

Re: [algogeeks] binary search for Linked List?

2011-03-08 Thread ravi teja
Yes , it is possible . But it does not make sense . The thing that matters while doing binary search for arrays is that we can access any element in O(1) time . But , for a linked list it becomes an average of O(n) . And on average we have an O(nlogn) algorithm with highly confusing code and messy

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, for

Re: [algogeeks] top search queries

2011-01-31 Thread Srikar
First Approach, 0) the queries can be considered as an infinite stream. maintain a global count of the number of queries coming from the stream (used for calc the frequency %). 1) maintain a min-heap (has just top 100 queries by frequency) + hash table (where we store frequency for each word in

Re: [algogeeks] top search queries

2011-01-31 Thread juver++
@above in your second approach, in the worst case you need to traverse the heap in O(n) time. -- 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] 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

Re: [algogeeks] Strings search problem

2010-12-30 Thread 周翔
Distance is measured on number of words. what is your meaning ? can you explain it? 2010/12/29 Davin dkthar...@googlemail.com Given set of words, find an area of the text where these words are as close to each other as possible. Distance is measured on number of words. e.g. for words

[algogeeks] Strings search problem

2010-12-29 Thread Davin
Given set of words, find an area of the text where these words are as close to each other as possible. Distance is measured on number of words. e.g. for words [rat”, “jat”, “pat”] and text “rat stop the pat blah blah jat by pat jat tra la la” such area is “cat by mat bat” -- You received this

[algogeeks] binary search tree

2010-10-06 Thread addicted2abhishesh
WAP to create a binary search tree and search a node in it using linked list representation -- 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

Re: [algogeeks] binary search tree

2010-10-06 Thread gaurav gupta
I guess this list is not to get your home works done. Please use google before throwing anything and everything here. On Wed, Oct 6, 2010 at 1:57 PM, addicted2abhishesh abhishesh.srivast...@gmail.com wrote: WAP to create a binary search tree and search a node in it using linked list

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

2010-09-27 Thread prodigy
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. the one in the middle.  There are now 3 possibilities: 1) The middle element is the one you're looking for, so you're done. 2)

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

2010-09-27 Thread sourav
I feel the binary search approach as given by Saurabh Singh or like moving from top right row, doing binary search in the row 0, find the element being searched (say x) or one less than that (say y), followed by binary search in the column below 'y' and proceeding in this way can give a less than

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

2010-09-27 Thread Gene
Well, friend, we're both wrong. The algorithm will find 6 just fine. It will choose 3 as the middle element. Since 6 is bigger, it will throw away the subarray 1 2 2 3 and check the other 3 subarrays. When it checks 6 7 7 8 It will find the 6 on the first try. I just verified this by

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

2010-09-26 Thread Gene
If the array is m by n, pick the element a[m/2][n/2], i.e. the one in the middle. There are now 3 possibilities: 1) The middle element is the one you're looking for, so you're done. 2) The element you're looking for is smaller. In this case you can throw out about 1/4 of the array: everything

[algogeeks] Ternary Search Trees

2010-07-09 Thread amit
Hi , I was reading TST from this http://www.ahhf45.com/info/Data_Structures_and_Algorithms/resources/technical_artile/ternary_search_tree/terstree.htm But I could not understand its two applications i.e the nearest neighbourhood search and Pattern Matching Search... If anyone of you know about it

Re: [algogeeks]Numbers search in an array

2010-06-18 Thread Ashish Mishra
take one pointer to start n another to the end say a n b now if a +b X shift b towards left n so on On Fri, Jun 18, 2010 at 9:03 AM, sharad kumar aryansmit3...@gmail.comwrote: @arun:find out the difference x-arr[i] for all i=0..n hash it ...next search for a number with difference .u can

[algogeeks]Numbers search in an array

2010-06-17 Thread Arunkumar Sreenivasan
Hi, You are given a set of numbers and another number 'x'. You have to find if there exists any two numbers, whose sum is equal to 'x'. I have done this is o(n)log n. Need a more optimized solution. regards, Arun kumar S -- You received this message because you are subscribed to the Google

Re: [algogeeks]Numbers search in an array

2010-06-17 Thread Anurag Sharma
Its a repeated question. I would suggest you checking the archives of this groups for its solution. Anurag Sharma On Fri, Jun 18, 2010 at 8:05 AM, Arunkumar Sreenivasan thegame.a...@gmail.com wrote: Hi, You are given a set of numbers and another number 'x'. You have to find if there

[algogeeks] Re: Search in a sorted NxN matrix

2009-11-25 Thread Geoffrey Summerhayes
Not a bad start, it can eliminate areas. n n n n ?? ?? ?? ?? n n n n ?? ?? ?? ?? n n n n ?? ?? ?? ?? n n n n ?? ?? ?? ?? ?? ?? ?? ?? n n n n ?? ?? ?? ?? n n n n ?? ?? ?? ?? n n n n So it would involve searching in the two remaing blocks, recursively until you get an 1xN or Mx1 then a binary

[algogeeks] Re: Search in a sorted NxN matrix

2009-11-25 Thread Geoffrey Summerhayes
Hmmm. Same idea, much more analysis. I feel good, I spent a lot less time thinking about it. Splitting the search areas into squares is a great idea. -- Geoff On Nov 25, 8:43 am, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: A research article on this question.. Rohit Saraf Sophomore

Re: [algogeeks] Binairy Search Algoritm

2009-11-12 Thread chitta koushik
while(a.[mid].equals('city1') a[mid+1].equals('city2') ){ mid = low+high/2; if(a[mid]=='city1' a[mid+1]=='city1') low=mid; else if (a[mid]=='city2' a[mid+1]=='city2') high=mid; } On Thu, Nov 12, 2009 at 3:39 PM, Dennis tyra...@gmail.com

[algogeeks] Re: search your friend

2009-10-09 Thread Dave
Wouldn't it be better to replace step 5 with Travel 2^(n+1) distance on the fourth road. If you find your friend DONE else return back to the crossing ? After you have exhausted the first three roads to a distance 2^n, there is no point to going only 2^n on the fourth road and then returning

[algogeeks] Re: search your friend

2009-10-09 Thread anilkumarmyla
Anyway the solution is O(d) [:)] which is asked to be proved. --~--~-~--~~~---~--~~ 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

[algogeeks] Re: search your friend

2009-10-09 Thread ankur aggarwal
yes anil your approach is rite.. --~--~-~--~~~---~--~~ 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] Element search in a matrix

2007-11-13 Thread geekko
Given a matrix all whose columns and rows are individually sorted, how do you search a number in it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] prority search tree

2007-01-19 Thread mohamad momenian
Hi i want to construct a priority search tree but i don't know the algorithm for construct and implement it can anyone help me please? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post