Company: Visa

Difficulty: medium

Problem Statement

Process Log Order A security tool watches a machine for viruses by studying the order in which processes were started. Every process may spawn child processes, and a child process can only be started by its parent, so a child must always appear in the log table after its parent. There is no cyclic relationship between processes, and process 1 is the designated bootstrap process, the first process to run. The tool builds its log table like this: Enqueue process 1 in a queue (FIFO). While the queue is not empty: 1. Append the first entry of the queue to the log table. 2. Add every child process of that entry to the queue. 3. Remove that entry from the queue. Because the child processes of one parent may be added to the queue in any order, the same machine can produce many different log tables. A log table is valid exactly when it can be produced by the procedure above, that is, when it is a breadth-first traversal of the process tree rooted at process 1 . You are given the parent/child r

More Visa OA questionsInterview experiences