Interview questions

Algorithm interview questions – page 25

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

  1. Using bit manipulation, implement add, subtract and multiply on two integers.

  2. What are demand- and pre-paging?

  3. Given a byte, write a code to swap every two bits. [Using bit operators] Eg: Input: 10 01 11 01 Output: 01 10 11 10

  4. How can we print sum of two number without using main function?

  5. Write a program to print an unsigned integer that is greater than a given unsigned integer but has the same number of 1's in binary form.

  6. Write a class bit...It contains two functions: bool getBit(int n), setBit(int n). The constructor is passed an integer n that specifies the number of bits to be handled...setBit fn sets the nth bit while getBit fn returns the nth bit. Hint: Don...

  7. What is the difference between functions, call back functions and function pointers?

  8. What are dangling and Smart pointer? How do you avoid Memory Leaks?

  9. Indexing in databases give you ...

  10. If there is a large quantum in round robin it will be equivalent to a. First come first serve b. Shortest job first c. Least recently used d. None of these

  11. Given 10K of 16bit integers and unlimited memory... find the most efficient algorithm that counts number of bits set to 1.

  12. What is the functionality of a top command?

  13. How to crash your system immediately?

  14. Write a function which takes 3 integers x,p,n which flips 'n' bits of x from 'p'th position.

  15. What is shared library? With small c program implement Dll?

  16. Convert Binary Tree into Double Linked List in Such way that Doubly Linked List represents the spiral traversal of Binary Tree...Reply ASAP

  17. Whats the difference b/w a thread and a process? are Word and PowerPoint different processes or threads of a single process?

  18. How do u turn off the rightmost significant bit of a number

  19. How to convert decimal to binary and its formula?

  20. A number of steps are there. You can go to step n either from step n-1 or from step n-2. In how many ways can you go to step n?

  21. Given a sorted array, output all triplets <a,b,c> such that a-b = c. Expected time is O(n^2). My approach using binary search took O(n^2 logn). When you attempt an approach, test your code with this example and list your outputs for verifica...

  22. What is LPCTSTR? What does LP denote it?

  23. Write a function getBits that gives x bits from a given position p of a given number n.

  24. Two integers A and B are given, find the no of bits that need to be flipped in A to get B

  25. Given a sorted array of n integers that has been rotated an unknown number of times, give an O(log n) algorithm that finds an element in the array.

  26. You are receiving a continuous bit stream, one bit at a time. You have to tell when the number formed by the current and previous bit stream is divisible by 5. You are not allowed to store the info regarding the bits which have already passed

  27. Given an integer x, find out the smallest integer which has same number of set bits as x and is greater than x.

  28. The following function is intended to concatenate 2 input strings and return the result. What problems do you see with the code below?

  29. The best way to multiply an integer by 3.5?

  30. Given a 32-bit integer x. find the smallest integer x0 > x with the same number of ones in binary representation

Companies that ask Algorithm questions