cobra
BAN USERNothing
- 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 | PURGE
Java - 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 | PURGE
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 | PURGE
Database
calculate price/length: for the given example it is..
1, 2.5, 2.67 , 2.25, 2, 2.42, 2.125, 2.5
here the length 3 have maximum price.. cut the piece of length N into pieces of length 3..
Benefit = number_of_pieces * 2.67
in addition there may be piece of length 2 or 1 give rise to additional cost of 2.5 or 1..
It seems ordinary question.. i dont know in conform whether i am right.. its just ordinary insertion of node in BST.
public Tree insert(Tree tree,int element)
{
if(tree==null )
{
tree = new Tree();
tree.element = element;
tree.left = tree.right = null;
}
else if(element < tree.element)
tree.left = insert(tree.left, element);
else if(element > tree.element)
tree.right = insert(tree.right,element);
return tree;
}
// In main function
for(int i = 0;i< preorder.length;i++)
tree = insert(tree,preorder[i]);
Sorry for down voting for incorrect reason... but i am not yet convinced with your method..
do you have full working code?
check ideone.com/0sCod .. check the expected output in the comment and the actual output.. it differs.. if i am wrong .. correct it and repost.. and then i up-vote..
Time Complexity: O(n)
package com.programs;
public class Compress {
/**
* Input -- aaabbccd output -- a3b2c2d1
*/
public static void main(String[] args) {
String input = "aaabbccd";
int count = 0;
char temp = input.charAt(0);
for(int i=0;i<input.length();i++)
{
if(input.charAt(i)==temp)
count++;
else
{
System.out.print(temp+""+count);
count = 1;
temp = input.charAt(i);
}
}
System.out.print(temp+""+count);
}
}
1. sort the array in extra space..
- cobra August 05, 20122. find the max length of consecutive range, min and max of that range.. here length = 5, max = 8, min= 4
3. create an array[length (or) max-min+1]... here array[5]..
4. now traverse the original input with count = 0
a) if the element is within the calculated range, increase the count and array[element-min] set to 1
b) if the element is repeated(which is already set in the array[]) or out of range.. check whether the element in array[] are consecutively set to 1.. if it is, store that temporary output with count.. reset count and array[] to zero
c) repeat a).. if the count exceeds the previous count.. update it..
Note: we have to iterate through all range of values..
for example: {1,2,3,51,7,52,8,53,9,54,10,55}
i)first process with 51..55
ii)next with 7...10
iii)next with 1..3
if i) is found to be continous in input with length = 5 then no need to see for ii) and iii) as they have length less than 5..