Engineering Interview Questions | Glassdoor.co.in

# Engineering Interview Questions

81,949

Engineering interview questions shared by candidates

## Top Interview Questions

### Engineer-2 Driver Development at AMD was asked...

19 Mar 2009
 difference between Macro and typedef and their implementation1 AnswerOne we use these in programs we will easily get it

### Engineer-2 Driver Development at AMD was asked...

19 Mar 2009
 RTOS featurs and memory footprints1 AnswerDepends on particular RTOS study

### Applications Engineer at Oracle was asked...

19 Mar 2009
 When is it appropriate to use local interface in EJBsBe the first to answer this question

19 Mar 2009

### Applications Engineer at Oracle was asked...

19 Mar 2009
 How long will you stay with the company?Be the first to answer this question

### Applications Engineer at Oracle was asked...

19 Mar 2009
 How did you handle a situation when other person does is a stubborn and completely disagree with your point of view.Be the first to answer this question

### Software Engineer at Google was asked...

19 Mar 2009
 Come out with an algorithm for getting the column number provided the column name in a excel sheet and vice versa. Excel has a naming convention of A,B..Z,AA,AB,AC..ZZ,AAA... This had to be converted to the column numbers. A will be 1 and AA will 27.. Also the algorithm to find the name provided column number.13 AnswersIts conversion from decimal to base 26 with some exception like there is nothing maps to zero. There might be a better way to do it.void printColumn(uint32_t col) { col --; int div = 26; int add = 26; while( col / div ) { div *= 26; } div /= 26; while( div != 1) { printf("%c", (col / div) + 'a' - 1); col = col % div; div /= 26; } printf("%c\n", col + 'a'); }Opps above does not work after ZZ. The correct one is void printColumn(uint32_t col) { int a = 26; int denominator = 1; while(a 0; i /= 26) low += i; // if value is lower than lower bound, decrease quotient by one if( denominator != 1 && col < (quotient * denominator + low) ) { quotient --; } printf("%c", quotient - 1 + 'A'); col = col - denominator * quotient; denominator /= 26; } }Show more responsesLet the size of the string asked is 3 e.g GHD . The formula to this : [ 26+26^2+...+ 26^(size-1) + (LetterIndex-1)*{26^(size-1)+....+(LetterIndex-1)*26}+Index ]In the code the above formula will use recursion to find the column number.The answer can be as simple as finding the first combination of number * i such that it is less then xcelcolvalue; ie repeat this till xcelColValue >= 26 ( 0 = 26){ int i = 1, num = 1; while((num * (i + 1)) 26){ i = 1; num++;} else i++; xcelNum -= num*i; sb.append((char) i); } if (xcelNum > 0) sb.append((char) xcelNum); return sb.toString(); }Also the above code is rough idea and not tested but gives enough idea on simplifying the solution. The code does not use lot of / and % calcuations but could elegantly find the solution. Note the Gaurd if(i > 26){ i = 1; num++;} else i++; which is important in finding the combination of num and i which multiples at least to xcelNum.I think the above is incorrect and it should be : public static String xcelString(int xcelNum) { StringBuffer sb = new StringBuffer(); while(xcelNum >= 26){ int i = 1; for(;(26 * (i + 1)) 0) sb.append((char) xcelNum); return sb.toString(); }Edge conditions aside, the program would be /* inputString - the column name. For e.g. "BZC" */ char [] columnName = inputString.toUpperCase().toCharArray(); int columnNumber = 0; for(int i = 0; i < columnName.length - 1; i++){ columnNumber = columnNumber + (int) Math.pow(26, (columnName.length - 1 - i)) * (columnName[i] - 64) ; } columnNumber = columnNumber + (columnName[columnName.length - 1] - 64); System.out.println("Column number is " + columnNumber);Edge conditions aside, the program would be /* inputString - the column name. For e.g. "BZC" */ char [] columnName = inputString.toUpperCase().toCharArray(); int columnNumber = 0; for(int i = 0; i < columnName.length - 1; i++){ columnNumber = columnNumber + (int) Math.pow(26, (columnName.length - 1 - i)) * (columnName[i] - 64) ; } columnNumber = columnNumber + (columnName[columnName.length - 1] - 64); System.out.println("Column number is " + columnNumber);int columnNumber(String col) { result = 0; for(i = 0;i< strlen(col) ; i++) { result *= 26; result + = col[i] - 'A' +1; } }int columnNumber(String col) { result = 0; for(i = 0;i< strlen(col) ; i++) { result *= 26; result + = col[i] - 'A' +1; } }public static String numToExcel(int n) { if(n 0) { int remainder = n%26; char newChar = (char) ('Z' - (26 -remainder)%26); result = newChar + result; n = (n-1)/26; } return result; }

### Software Engineer at Google was asked...

19 Mar 2009
 Design a data structure for LRU cache3 AnswersThere are many ways to do thisWould a Priority Queue work here? If we have a hash function to help us the lookup, then we might have to just end up truncating tail of the Queue and add element to the head or vice versa.In java, just extend the LinkedHashMap static class MyLru extends LinkedHashMap { int capacity; public MyLru(int capacity){ super(capacity,0.75f,true); this.capacity = capacity; } @Override protected boolean removeEldestEntry(Map.Entry eldest) { if(size()>capacity) { return true; } return false; } }

### Senior Software Engineer at NDS was asked...

21 Mar 2009
 Write implementation of ThreadPool1 Answeravailable in most of the site

### Senior Software Engineer at NDS was asked...

21 Mar 2009
 Write implementation of HashMap1 Answerthere in the java.util source
110 of 81,949 Interview Questions