Senior Software Interview Questions | Glassdoor

# Senior Software Interview Questions

4,548

Senior software interview questions shared by candidates

## Top Interview Questions

Sort: Relevance Popular Date

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

Jan 13, 2011
 Write the function that calculates price of the cup of coffee where price of the condiments depends on size of the coffee cup. For example milk cost 10 c for small cup 15 c for medium and 20 c for large 3 Answers You have to index elements of one array of enums by essentially using ordinals of another enum Use Decorator pattern classic decorator design pattern, 23 design patterns book has this.

Jan 16, 2013

### Senior Software Engineer at Ericsson-Worldwide was asked...

Mar 24, 2009
 I had not expected to be asked logic questions, which made me nervous. The first one was a weigh nine items on a balancing scale to find the odd one out in the fewest scale uses 3 Answers Split them into three groups of three, weigh two to determine the odd set out, then split that stack of three into three sets of one, and weigh two to find the single one out, requiring only two scale uses. The above strategy works only if you know whether the odd item is lighter or heavier. If you do not know how it differs, you will need more scale uses. 111-111-114 <--- By weighing any of two sets, you get 114. 1-1-4 <----- By weighing any of two, you can find out 4.

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

Apr 23, 2011
 "Given a log file spanning multiple days, and given a page transition A -> B -> C, find all the unique users who made this page transition in the logs" 3 Answers This one was doable. But we were short on time and the manager seemed annoyed to be there. How is the transition encoded? Would a simple grep work? Unlikely. The task was do it in Java 1.6, also they had to make the entire transition A -> B -> C, not neccessarily on the same line and maybe not even on the same date. Think Standard Web Server Logs. So you get: datetime - User X gets Page A . . . (millions of lines later) datetime User X gets Page B.... (millions of lines later) datetime User X gets Page C.... You get the idea. If I give you A -> B -> C, you get "User X" as out put, because they made the transition.

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

Dec 15, 2010
 Tell me the difference between C# and C++ 3 Answers As a non-C# programmer I wondered where this question came from. I did my best, and thought I consider the major differences. well, the biggest difference is that c# is managed, and c++ isn't. c# is comparable to java. C++ can be managed too.

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

Jul 17, 2010
 serialize binary tree 3 Answers Do something similar to Breadth-First-Traversal. For each node assign an integer key that should be serialized along with the nodes data. Start with 0 as key for the root. For each node with key x, push it's left child (if it exists) with key 2x+1 and it's right child (if it exists) with key 2x+2. The key uniquely identifies position of the node in the tree. Record both pre-order and mid-order sequence Do the array representation of the tree: children at 2n and 2n+1

### Senior Software Engineer at Northrop Grumman was asked...

Jun 21, 2010
 2 - in C#, can you tell whether whatever the user has input is a string or integer? 3 Answers 2- no. there is no method like that. you have to make your own. I did that with regex bool isInt(string userInput) { int i; return Int32.TryParse(userInput, out &i); } if it's ASP.NET - regardless of whether the code-behind is C# or VB, a will reject non-integers also IsInt posted above will work (but take out the ampersand, that's what the 'out' is for). as #1 mentioned, this works too: return System.Text.Regex.IsMatch(userInput, "^\d+\$", RegexOptions.CultureInvariant);

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

Oct 27, 2010
 what is the bubble sort algorithm 3 Answers the alogrythm used for standard algo Best O(n) worst O(n2) case for(int i= count; i>=0;--i) for(int j=0; j a[i+1]) swap(a[i], a[i+1]) can do swap wit xor swap a[i] = a[i]^a[i+1] a[i+1]=a[i]^a[i+1] a[i]=a[i]^a[i+1] int[] bubbleSort( int[] input ) { int swap_occurred = 1; while (swap_flag) { swap_occurred = 0; for (int i=0; i

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

Jan 18, 2011
 Write a C function to return the number of set bits in an integer. 4 Answers 32 bits in an integer(int) data type on most systems. static const int NumberOfSetBits[8] = { /* in nibble, half byte */ 0, /* 0x0, b0000 */ 1, /* 0x1, b0001 */ 1, /* 0x2, b0010 */ 2, /* 0x3, b0011 */ 1, /* 0x4, b0100 */ 2, /* 0x5, b0101 */ 2, /* 0x6, b0110 */ 3 /* 0x7, b0111 */ 1 /* 0x8, b1000 */ 2 /* 0x9, b1001 */ 2 /* 0xA, b1010 */ 3 /* 0xB, b1011 */ 2 /* 0xC, b1100 */ 3 /* 0xD, b1101 */ 3 /* 0xE, b1110 */ 4 /* 0xF, b1111 */ }; #define NumBytesInInt 4 /* assumes 32bit system */ int GetNumberOfSetBits(int anInteger) { uint8_t buf[NumBytesInInt ]; int i; int count = 0; memcpy(buf, &anInteger, sizeof(buf)); for (i=0; i> 4]; } return count; } int GetNumSetBits( int anInt ) { int count = 0; for( sizeof( int) ) { count += (anInt & 0x01); anInt >>= 1; } return count; } Show More Responses This looks mos efficient, int GetNumSetBits( int anInt ) { int count ; while(anInt) { count += (anInt&0x1); anInt >>= 1; } return count; }