[algogeeks] Sites for Interview Questions

2011-01-18 Thread Yellow Sapphire
Hi,

Can someone suggest good books/websites/blogs for interview related
questions.


thanks--
YS

-- 
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 options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Number problem

2010-09-25 Thread Yellow Sapphire
My code failed because it was reversing the digits and thus 0 was getting
added in the front which resulted in nothing.

If allowed we can use a char array else will have to find a solution which
does not reverse the digits of the number.

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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

2010-09-23 Thread Yellow Sapphire
I hope this will work. It finds the two minimum numbers and then prints the
difference.

#include stdio.h
#include stdlib.h
void find_two_mins(int array[], int size)
{
int i,t;
int min1=array[0], min2=array[1];
for (i=2; isize; i++){
t=array[i];
if(t=min1) {
min2=min1;
min1=t;
continue;
}
}
printf(\nMin elements are 1: %d 2: %d, min1,min2);
printf(\n Absolute difference between two minimum elements are %d,
abs(min1-min2));
}


int main()
{
//int array[10]={ 9,2,3,4,1,7,5,6,8,0};
//
int array[10]={99,12,45,33,88,9098,112,33455,678,3};
find_two_mins(array,10);
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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Unbounded dictionary lookup

2010-09-22 Thread Yellow Sapphire
In case of a dictionary, can we assume that its a Sorted list of
words?

On Sep 22, 12:42 pm, ramdas kale ramda...@gmail.com wrote:
 If we take high = MAX_CAPACITY

 Here MAX_CAPACITY denotes the maximum no of words dictinary can index.
 Actual no of words stored in dictionary could be less than MAX_CAPACITY.



 On Wed, Sep 22, 2010 at 1:23 AM, Minotauraus anike...@gmail.com wrote:
  high= const.(10^const)

  What's const? The point of this isn't that it's a difficult prob to
  solve. Point lies in working with the design to make this close to log
  n.

  Define what value const holds.

  On Sep 21, 9:12 am, coolfrog$ dixit.coolfrog.div...@gmail.com
  wrote:
   its dictionary means shorted ordered arry.
   let low = 1; and high= const.(10^const)

   Boolean isWord(String word)
      {  while(low = high)
           {   mid = (low+ high)/2;
                   if(word = getWordAt(mid))
                     return true;
                  if( word  getWordAt(mid))
                      {  high = mid-1
                      }
                   else
                        low = mid+1;
            }

    }
   Its a simple Binary Search Algorithm ...
      who's complexity is O(log n) times.

  --
  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.comalgogeeks%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Ramdas Kale
 +919983526790

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Inserting a box with lesser dimension into a box of bigger dimensions than that.

2010-09-22 Thread Yellow Sapphire
We can first sort the dimensions of each box.

For example if the dimensions of a box is L=10, B=12, W=6 then convert
it to L=12, B=10, W=6.

The above step is not needed if the problem states that LBH for all
boxes.

Then using a multi-key sorting we can sort all the boxes in ascending
order (or descending order).

If we sort it in ascending order:

This will give us a sorted list where in each box in the list is
smaller or equal to the next one in the list.

The boxes will fit inside the other one only if all the dimensions are
less than the other one.

Lets us have the boxes in list LIST in the sorted order (multi key)

//START

init_list (current)
init_list (discarded)

Start: // its a label.

for i = 0 to length_of_list; do //don't increment i here

T1=LIST[i]
T2=LIST[i+1]

if ( T1.L T2.L  T1.B  T2.B  T1.W  T2.W ) {

 add_to_tail (current, T1 , T2)
 i=i+2;

 } else {

   add_to_tail (discarded, T2)
   i++;
 }
done // for loop ends

print_list(current) // here is your one solution.

if ( elements in discarded list) {
LIST=discarded
goto Start // goto the label start
}

///END


On Sep 22, 12:11 am, Dave dave_and_da...@juno.com wrote:
 Certainly having a smaller volume is necessary for a box to fit in
 another box, but it is not sufficient. E.g., a box of size 1 x 1 x 1
 will not fit in a box of size 2 x 2 x 1/2.

 Dave

 On Sep 21, 1:16 pm, rajess rajeshrules...@yahoo.com wrote:

  find the volume of boxes as v=l*b*h
  sort boxes in volumes in descending order and this is the way to
  insert boxes one into another

  On Sep 21, 7:55 pm, Rashmi Shrivastava rash...@gmail.com wrote:

   If there are n number of boxes and each with different dimensions and your
   job is to insert one box having lesser dimension than that to another.
   Consider size of boxes as,
   b1-s1(h1,l1,w1)
   b2-s2(h2,l2,w2)
   .
   .
   .
   bn-sn(hn,ln,wn)- Hide quoted text -

  - Show quoted text -

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Print 1 to n one per each line on the standard output

2010-09-22 Thread Yellow Sapphire
The question is to get an algorithm or a program.

If it's a program then using execl() or fork() system call you can
code this.

The code will not be a recursion in a sense that we will not call
functions recursively but will call the programs (executable code)
recursively.

On Sep 22, 8:49 pm, Divesh Dixit dixit.coolfrog.div...@gmail.com
wrote:
 Write an algorithm that will print 1 to n, one per each line on the
 standard output, where n is
 a integer parameter to the algorithm. An algorithm should not use
 while, for, do-while
 loops, goto statement, recursion, and switch statement.

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.