cobra
Nothing
 0of 0 votes
AnswersI have Created Dynamic Web Application...
 cobra in India
there is user table with column "enabled" to check if the user is already logged in
enabled = true > logged in otherwise not
if i logged in , i cannot loggin at the same time in anothe r browser ..
but if i logged in and close the browser, how can i handle further loggin ?? Report Duplicate  Flag
Java  0of 0 votes
AnswersRegular Expression:
 cobra in India
1. it should contain 8 characters
2. atleast one alphabet
3. atleast one number
Number and Alphabets may not be consecutive Report Duplicate  Flag
Algorithm  0of 0 votes
AnswerAfter creating Huffman tree, how to print the huffman code for each character which are the leaf nodes?
 cobra in India
leaf nodes contain: character (ex:'a') and its frequency
other nodes contain: character '*' and sum of the frequency of the child nodes. Report Duplicate  Flag
Algorithm  0of 0 votes
Answerswhat is the difference between IN , ANY and ALL in oracle?
 cobra in India
can anyone explain with an example? Report Duplicate  Flag
Database  0of 0 votes
AnswersGiven a pointer to the root of a binary tree , check whether the tree is
 cobra in India
balanced or not. Report Duplicate  Flag
Microsoft Data Structures  0of 0 votes
AnswersGiven pointers to the first node of two linked lists A and B which may
 cobra in India
be merged at a point. The problem is to find the merge point if it exists
else return null. Report Duplicate  Flag
Microsoft Data Structures
It is correlated subquery.. we can also use
select * from books order by price desc limit(0,5);
but if the 5th price is repeated , the query wont consider..
but this correlated subquery uses the condition : price >= 5th expensive price
but how the '5th expensive price' is calculated? it is done by making use of count(*) :)
For n=4.. you have to take 1,2 or 3.. So for n=1 , you have to take nothing.. so C(1) = 0.. C(2) = 1 ( {1, 1}), C(3) = 3 ({1,1,1},{2,1},{1,2})... and by your algo: C(4) = C(3) + C(2) + C(1) which gives 4(3+1+0) .. And also C(5) = 15 and by your algorithm it is 13.. a wrong answer..
 cobra January 05, 2013public class Program15072768 {
static int count = 0;
static void C(int n,int tsum)
{
if(tsum == n)
{
count++;
return;
}
else if(tsum > n)
{
return;
}
else{
for(int i=1;i<n;i++)
{
C(n,i+tsum);
}
}
}
public static void main(String[] args) {
C(4,0);
System.out.println(count);
}
}

cobra
January 05, 2013 Table Structure is wrong!!
table1 employee: employee_id, employee_name, salary, dept_id
table 2 department: dept_id, dept_name, reg_id
table 3 region: reg_id , reg_name
Query :
select employee_id, employee_name, salary , e.dept_id
from employee e join department d on e.dept_id = d.dept_id
join region r on r.reg_id = d.reg_id
where r.reg_name = ?
From 1 to 50
Let the coin be at the initial position and the number of steps moved is zero
>>the next six step or cell(2,3,4,5,6,7) can be reached with minimum 1 dice roll
>>mark the cell with 1
>>if any of these six cell has lower point of ladder then mark upper point of ladder with 1
>>continue the above steps with MAXIMUM upper point of the ladder and mark the further cell with current weight(here it is 1) with 1
For 51 to 100
>> instead of ladder use snake!!
use HashMap<Integer,Set<Word>> where key is the length of the word..
get the Set<Word> for the given length and use a function
boolean isWord(String input)
{
// which returns true if a word which differs by one character exists and also not visited before..
// this process repeated till we reach the target word or null...
}

cobra
December 18, 2012 1. calculate number of space between words: here it is 2
2. calculate number of space to be distributed : here 1511 = 4
3. each space between words will have additional space: 4/2 and either first or last space will have 4%2 (here 0, so distribution is common) additional space
finally: "DOG<space><space><space>IS<space><space><space>CUTE"
@Sanjay:
if you seen the decimal value should not repeat, then 225/1000 give only 0.(2)
the task is the decimal PATTERN should not be repeated.. not decimal VALUE..
you are seeing for the first decimal quotient not to repeat..
but i seen first remainder not to repeat..
because 10/7 and 11/7 both give quotient 1..
my answer for 1/97 is
0.01(030927835051546391752577319587628865979381443298969072164948453608247422680412371134020618556701)
as there are 97 possible remainders.. these number of decimal points.. when you try to go further.. the pattern in the bracket will be repeated..
 cobra August 09, 2012Use One pointer to the list and a queue of size 5:
1) traverse to the 5th node
2) insert the element at the queue
3) if the queue is full, take rear element out and insert the new element at the front
4) repeat it till the pointer reaches null
5) the rear pointer of the queue contains the 5th element from the tail of the list..
for simplicity : i am explaining for sorting 10 numbers with memory size 2
a) find the minimum element and its index in one full traverse from i to (total_numbers 1) [here it is 8]for (i+1)th iteration
for ex: {5,8,1,3,9,10,6,4,2,7} , store {2,1} where 2 is the index and 1 is the element for 1st iteration
b) swap(input[min_index],input[i]) where (i+1)th iteration
here,
swap (input[2],input[0]) for the 1st iteration
c) repeat a) and b) for 8 times .. as for 9th iteration no swaping will be there and elements are sorted..
take {1,2,3,1,4,2,3,7,5,6}
range : only one range.. 1...7
now..
first consecutive: 1,2,3 as the next 1 repeated and cannot be taken into account and length = 3
next..
1,4,2,3,7,5,6.. and length = 7 greater than previous one.. so update it..
if there is any out of range value eg: 10.. counting is stopped and checked for consecutiveness(whether '1' in array[] is continuous) and previous count..
Note: you have to update the count only the array[] is of the form {1,1,1,0,0,0..} not {1,0,1,0,1,1} because numbers should be consecutive
consider the array[] = {1,1000,2,999,998}
here longest sorted sequence is {998,999,1000} which can only be taken for count..
if 1,2 are continuous then 998,999,1000 are also continuous with long length..
in either case {1,2} doesnt affect the answer.. so we can leave {1,2} while traversing..
@anonymous: a small mistake in your algo..
boolean MatchString(Stream stream, String str)
{
boolean done= false;
int i = 0;
while(!done)
{
char c = stream.readNextChar();
if(str.charAt(i) == c )
{
if(i == (str.length1))
{
return true;
}
i++;
}
else if(c == str.charAt(0))
i=1;
else
{
i = 0;
}
}
}
@leet and @anonymous: when the loop ends???
can i write
if( c == '\0')
return false;
if i am wrong what is the condition for the loop to terminate if the stream is stopped..
 cobra August 05, 2012Open Chat in New Window
1. we can search at index 0,1,2,4,8,16....
 cobra July 06, 20132. at the point we get getItemAt(x) == 1, our required index at x/2 < ans_index <= x
3. from (x/2)+1 to x we can do binary search and can find the required index