saurabh.comps
BAN USER// Rough code
// Please correct my mistakes
// Correct the logic
// Do rest by yourself
void ConstructTree(char *in, char *pre, Node **head, int size){
if (*(pre+0) == '\0') {
*head = null;
return;
}
if (*(in+0) == '\0'){
*head = null;
return;
}
int i = 0;
while ( i < size ){
if ( *(in+0) == *(pre + i)){
break;
}
i++;
}
(*head) = (Node *)malloc(sizeof(Node));
*head->val = *(in+0);
ConstructTree(in+i, pre, &((*head)->left), i-1);
ConstructTree(in+i, pre+i+1, &((*head)->right), end);
}
get the inode structure of directory and check for similarity in file names, content comparison..
- saurabh.comps November 09, 2009// rough code
// please correct this..
// Please point mistake in logic..
// write the finddepth by yourself..
int findDia(Node *root){
int ldepth, rdepth;
int dia, ldia, rdia;
if (root == null)
return 0;
else {
if (root->left != null)
ldepth = findDepth(root->left);
if (root->right != null)
rdepth = findDepth(root->right);
dia = ldepth + rdepth +1;
ldia = findDia(root->left);
rdia = findDia(root->right);
int subtDia;
if ( ldia > rdia ) {
subtDia = ldia;
}
else {
subtDia = rdia;
}
}
return dia>subtdia?dia:subtDia;
}
http://mindprod.com/jgloss/interfacevsabstract.html
- saurabh.comps November 08, 2009http://mindprod.com/jgloss/interfacevsabstract.html
- saurabh.comps November 08, 2009I think all these "anon" guys are just fucking piece of shit...
--Anonymous
char * longestPalindrome(char *str, int len ){
char * retstr = (char *)malloc(len+1);
int i = 1;
int mid = (len>>1);
while ( i < mid && (*(str+i+mid) == *(str-i+mid)) )i++;
int retlen = i;
int j = 0;
while ( j <= 2*i){
retstr = *(str-j+mid);
j++;
}
*(retstr + j) = '\0';
if ( strlen (longestPalindrome(str+0, mid-1 )) > longestPalindrome(str+mid+1, mid-1 ) ) {
if ( retlen < strlen (longestPalindrome(str+0, mid-1 )))
return strlen (longestPalindrome(str+0, mid-1 ));
else
return retstr;
}
else {
if ( retlen < strlen (longestPalindrome(str+mid+1, mid-1 )))
return strlen (longestPalindrome(str+mid+1, mid-1 ));
else
return retstr;
}
}
// Rough code... refine by yourself..
// Please point mistakes in logic
He should follow islam.. He'll always go to heaven... with probability 1...
OBL {Allah hu akbar allah}
Logic:
Read each charecter,
Hash it to a bitmap with each character being hashed to its corresponding bit position.
assumption:
all values in lower case
char * remDuplicate(char * str){
int d;
char *c = (char *)malloc(strlen(str) + 1);
int d = 0;
int i = 0, j = 0;
while ( *(str+i) != '\0'){
if (isSet(*(str+i) , &d)) {
i++;
} else {
*(c+j) = *(str+i);
i++; j++;
setBit(*(str+i), &d);
}
}
*(c+j) = '\0';
return c;
}
void setBit(char c, int *d){
int bitpos = c - 97;
int n = 1;
while (bitpos > 0) {
n = n << 1; bitpos--;
}
*d = (*(d))|n;
}
int isPresent(char c, int *d) {
int bitpos = c - 97;
int n = 1;
while (bitpos > 0){
bitpos--;
n = n<<1;
}
if ( (*d)&n)
return 1;
else
return 0;
}
Please point out if i have made any pointer mistakes
- saurabh.comps November 08, 2009In my opinion returning an error object which contains the exception object, error code, some custom message from developer and extra information is the best practice. There should be one global file which should contain all error codes and corresponding messages and meta data. This error code file object should be static and only read only API should be available from this file structure...
guys chip in with some idea.. evaluate mine as well...
Dont understand the question... Can you be bit more explicit?
How do you define distance in the input?
Compare it with the results returned by Google.
- saurabh.comps November 08, 2009Test for inputs..
Functional testing:
1. If item selected is delivered or not?
What if no item is there?
If the gripper or hooker to drop the item in the tray works or not?
What if more than available number of items are stuffed in the tray? If there is
any testing on basis of weights of item?
What if machine does not have change? What does it do?
What if multiple items are withdrawn in one go?
Test for fraud coins?
Performance:
How quickly item is dropped in the tray?
Logic behind returning change?
Usability testing:
Ease ness to use? Who is going to use the machine?
Where the items are delivered?
If assitance is provided in dealing with machine or not?
Security testing:
If machine is secure or not?
etc.,....
swap in with pre in the whole code...
- saurabh.comps November 09, 2009