Profile photo for Cosmin Negruseri

Software development examples:

  • debugging a somewhat linear piece of code. if the code has many steps mostly executed in a sequence and there's a bug, you can isolate the bug by finding the earliest step where the code produces results which are different from the expected ones.
  • cherry picking a bad code change from a release candidate. When pushing a large code release in production one would sometimes find that there's a problem with that binary. If reverting the whole release wasn't an option the release engineer would binary search through the code change ids. He would figure out the earliest code change which creates the bug.
  • figuring out resource requirements for a large system. one could try running load tests on the system and binary search for the minimum amount of CPUs required to handle a predicted load. (this approach is better than random guessing but much worse than doing some analysis of your system and doing some good educated guesses)
  • figuring out how big should your cache size be for a serving system or deciding on the TTL for the cache.

Algorithmic puzzle examples:

  1. Given A a sorted array find out how many times does x occur in A.
  2. Given a real number x, find out its cubic root.
  3. Given A a sorted array with distinct numbers, find out an i such that A[i] == i.
  4. Given the +,-,*,/,sqrt operations and a real number x find an algorithm to get log_2_x.
  5. Given an array of distinct numbers A such that A[0] > A[1] and A[n-1] > A[n-2] find out a local minimum (find out an i such that A[i-1] > A[i] < A[i + 1]).
  6. Let A be a sorted array with distinct elements. A is rotated k positions to the right (k is unknown). Find out k.
  7. Let A be a sorted array with distinct elements. A is rotated k positions to the right (k is unknown). Find out if A contains a number x.
  8. Given two sorted arrays of length n and m, find out the kth element of their sorted union.
  9. Given A, an array comprised of an increasing sequence of numbers followed immediately by a decreasing one. Determine if a given number x is in the array.
  10. Given an array of N distinct int values in ascending order, determine whether a given integer is in the array. You may use only additions and subtractions and a constant amount of extra memory.
  11. Player A chooses a secret number n. Player B can guess a number x and A replies how does x compare to n (equal, larger, smaller). What's an efficient strategy for B to guess n.
View 10 other answers to this question
About · Careers · Privacy · Terms · Contact · Languages · Your Ad Choices · Press ·
© Quora, Inc. 2025