Interview questions

Algorithm interview questions – page 26

811 questions. Tap “Show answer” to check yourself.

  1. Void main(){int i=20;j=35,x,y;x= y++ + x++;y= ++y + ++x;printf("%d %d" , x,y);}/* please tell me the value of x and y at each and every moment. i dont need the answer but the explanation of the anamolus behavior of increment expression.*/

  2. What are the types of cookies are there?

  3. Given a number, multiple it by 8 without using multiplication or addition. Do the same for 7.

  4. Prove that in a graph, sum of degrees = twice the number of edges.

  5. Bit palindrome: Write a function to check if the bit-wise representation of an integer is a palindrome.

  6. Write a Complete program check whether Graph is Connected or Not & also for whether Graph is Tree or not.

  7. For any string s (0 + 1)*, let d(s) denote the decimal value of s (eg: d(101) = 5, d(011) = 3). Let L = {s (0+1)* | d(s) mod 5 = 2 and d(s) mod 7 = 4}. Which of the following statements is true? a) L is recursively ...

  8. Why do most hardware testers use stacks in their programs to store data?

  9. Two 32bit integers m,n are given.replace all the bits in m from i to j locations with all the bits in n from k to l locations... eg. m = 110000000000 n = 10101010 i=3 j=5 k=5 l=7 o/p:110000101000

  10. How we can declare & initialize more than two variable of same name & print their different values?

  11. Which of the following languages over {0, 1} is regular? a) 0i1j such that i j b) 0iw1j such that w {0, 1} and i 0 c) All strings of 0s and 1s such that every pth character is 0 where p is prime d) None...

  12. Given a byte, write code to swap every two bits in pair.

  13. What is the function pointer? In which situation we need to use function pointer?

  14. Set the highest significant bit of an unsigned integer to zero

  15. How to count number of 0 bits in a given integer? write C code

  16. How to find whether a machine is 32bit or 64 bit? Write code for this

  17. What is a trap and trapdoor?

  18. Given any number say 12, find the next multiple of 8 eg 16 using bit-wise manipulations.?

  19. Belady's anomaly and scheduling algorithms (from OS)

  20. Floating point representation: Simple one If 23 bits are used for IEEE representation then whats the range of normalized nos. which can be represented?

  21. How to check if binary representation of a number is a palindrome or not? For eg. binary representation of 5 is 101 and is a palindrome.

  22. Write a function int findn(int n, int x); The function must return the nth number in the sequence of binary numbers with exactly x ones.

  23. Program to flip all odd bits of an integer

  24. Life cycle of thread

  25. Write a function F(x, p, n, y) such that it returns x with the n bits that begin at position p (from LSB) set to the rightmost n bits of y.

  26. What is busy waiting?

  27. Find the value of n the following code: int F(int n) if( n!=0& !(n&(n-1))) printf("%d",n) n is i. Even no ii. Odd nos iii. Non zero numbers iv. Number with power 2

  28. Reverse bits of an integer

  29. Set nth bit of an integer

  30. There is an array of size 'n' containing 0s and 1s. Find in O(n) and constant space the maximum sub sequence which has equal number of 1s and 0s.

Companies that ask Algorithm questions