Ittiam Systems
10+ British Airways Interview Questions and Answers
Q1. reverse an array inplace. -4 input AND gate using 2 input AND gates.give 2 ways and compare both.how will you identify which is better if both are given in a black box. -swap elements without using temp,in whic...
read moreQuestions on array manipulation and logic gates.
To reverse an array inplace, swap the first and last elements and continue swapping towards the middle.
To implement a -4 input AND gate using 2 input AND gates, use two 2-input AND gates and connect their outputs to a third 2-input AND gate.
To compare two black box implementations of an AND gate, test their output for all possible input combinations and compare the results.
To swap elements without using temp, use XOR operation. ...read more
Q2. you are given a 32 bit no. two bit positions say m and n are given. extract the pattern between m and n. e.g. 01100111110001011100100101011111 m=10,n=20; from m to n i have "10001011100"......so i had to extrac...
read moreExtract a pattern between two given bit positions in a 32-bit number.
Convert the number to binary string.
Extract the substring between the given positions.
Convert the substring back to decimal if needed.
Handle edge cases like invalid positions or overlapping positions.
Q3. Where do local variables go? Why is stack used for function calls? Can you perform arithmetic operations directly on data stored in stacks?
Local variables go on the stack. Stack is used for function calls due to its LIFO nature. Arithmetic operations can be performed on stack data.
Local variables are stored on the stack frame of the function they are declared in.
Stack is used for function calls because it allows for easy management of function call frames in a LIFO manner.
Arithmetic operations can be performed on data stored in the stack by first popping the operands and then pushing the result back onto the sta...read more
Q4. -calculation of stack space used by a combination of functions and which used for storage of different data types
To calculate stack space used by functions and data types, we need to consider their sizes and memory allocation.
Calculate the size of each data type used in the functions
Determine the number of variables declared in each function
Multiply the size of each variable by the number of times it is declared
Add up the total size of all variables in each function
Add the sizes of all functions together to get the total stack space used
Q5. -if you have to AND n inputs,how many AND gates will be required? (I said n-1 and he asked me to prove it mathematically)
To AND n inputs, n-1 AND gates are required.
Each input needs to be connected to an AND gate except for the last input which is connected to the output.
The output of each AND gate is connected to the input of the next AND gate.
This results in n-1 AND gates being required for n inputs.
Q6. What is stack? Where is it used? (i said function calls) What exactly happens in function calls?
Stack is a data structure used to store and manage function calls.
Stack is a LIFO (Last In First Out) data structure.
It is used to store function calls, local variables, and return addresses.
Pushing onto the stack adds a new element to the top, popping removes the top element.
Stack overflow occurs when the stack size exceeds its limit.
Example: recursive function calls use the stack to store return addresses and local variables.
Q7. Given numbers in range 1 to 1000000006, find the minimum number such that the product of its digits modulo 1000000007 is equal to itself
Find the minimum number whose product of digits modulo 1000000007 is equal to itself.
Iterate through numbers from 1 to 1000000006
Calculate the product of digits modulo 1000000007 for each number
If the product is equal to the number, return the number as the minimum
If no such number is found, return -1
Q8. Program to find the number of trailing zeros in a factorial
Program to find the number of trailing zeros in a factorial
Count the number of 5s in the factorial
Divide the number by 5 and add the quotient to the answer
Repeat until quotient is less than 5
Q9. Find the transpose of a 2*2 square matrix(in place)
Transpose a 2*2 square matrix in place
Swap the elements at (0,1) and (1,0) indices
No need to swap elements at (0,0) and (1,1) indices
Example: [[1,2],[3,4]] -> [[1,3],[2,4]]
Q10. Program to invert all bits from the leftmost set bit in an integer
Program to invert all bits from the leftmost set bit in an integer
Find the leftmost set bit using bitwise operations
Create a mask with all bits set to 1 from the leftmost set bit
XOR the mask with the integer to invert all bits from the leftmost set bit
Repeat the above steps until all bits are inverted
Q11. Program to invert the case of the last letter in each word of a sentence
Program to invert the case of the last letter in each word of a sentence
Split the sentence into an array of words
Loop through each word and get the last letter
Invert the case of the last letter using toUpperCase() and toLowerCase()
Replace the last letter in the word with the inverted case letter
Join the array of words back into a sentence
Q12. Can I increment a void pointer?
No, incrementing a void pointer is not allowed.
Void pointers do not have a data type, so incrementing them is not possible.
Attempting to increment a void pointer will result in a compilation error.
To increment a pointer, it must be of a specific data type.
Q13. Time complexity of various operations on hashmap
Time complexity of hashmap operations
Insertion and deletion: O(1) on average, O(n) in worst case
Search: O(1) on average, O(n) in worst case
Traversing: O(n)
Resizing: O(n)
Q14. Design a data structure for dictionary
Design a data structure for dictionary
Use hash table or trie data structure
Each key maps to a value
Keys should be unique
Support operations like insert, delete, search
Q15. -AND gate using multiplexer
AND gate can be implemented using a 2:1 multiplexer.
Connect both inputs of the AND gate to the select line of the multiplexer.
Connect one input of the multiplexer to 0 and the other input to the second input of the AND gate.
The output of the multiplexer is the output of the AND gate.
Q16. Implement memcopy in C
Implementing memcopy in C
Use a loop to copy each byte from the source to the destination
Handle overlapping memory regions correctly
Return a pointer to the destination
Ensure proper null termination for string copies
More about working at Ittiam Systems
Interview Process at British Airways
Top Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month