C Google Interview Questions

You have to debug a crashing application. You are given the source. When you run it repeatedly in a debugger you observe that it never crashes in the same place twice. It uses only the C standard library and is single threaded.

What coding errors could cause the crashes? How would you find them?

Design a system to efficiently calculate the top 1MM Google search queries and create a report of these. Additionally:

  • You are given twelve servers
  • Each has two processors, 4GB of ram and four 400GB hard drives.
  • The machines are networked
  • The log data as roughly 100 Billion log lines in it.
  • The log data comes in twelve, 320 Gb files.
  • Each line of the files has roughly 40 search queries
  • You can only use open source software or software that you write.

Given an array A[N] containing N numbers. Crate an array Output[N] where Output[i] is equal to the product of all the elements of A[N] except A[i].

For example Output[0] is the product of A[1] to A[N-1] and Output[1] is the product of A[0] and from A[2] to A[N-1].

Do this without using the division operator. Do it in O(n).

You are given a linked list of integers of length N.

N is very large and you don’t know N.

Write a function to return k completely random numbers from the list.

Do this in O(n).

Hint: Use random function rand() (returns a number between 0 and 1) and irand() (return either 0 or 1) 2.

Write a function to efficiently determine the result of a game of Tic Tac Toe.

The function takes as input the game and the sign (x or o) of the player. The function returns if this player has won the game or not.

Carefully consider both the data structure and the algorithm for your answer.