## National Instruments Interview Questions

- 1of 1 vote

AnswerSkynet

- glory for dreams July 02, 2015 in United States

Skynet has grown to become the dominant force on earth and has almost completely wiped out the

human race. Skynet has been

building robots ever since it's inception and has been updating it's models every year while making

them better. Skynet wants to annihilate humanity completely. It plans to remove one last band of

humans lead by John Connor. Skynet thinks it can destroy these humans using only two of it's robots.

But Skynet doesn't want to send two robots with the same model number lest John Connor finds out a

weakness in that model and easily destroy both of them.

Skynet has at its disposal N robots and to save space Skynet has stored information about pairs of

robots belonging to the same model. If it doesn't have any info stored for a particular robot then it is

implied that the robot is the only one in that model.

Given these constraints, in how many ways can Skynet pick two robots to destroy John Connor and

his rag tag group of humans.

Inputs

N Total

number of robots. Each robot is assigned a number from 0 to N1

(2 <= N <= 100000)

P Number

of pairs for which Skynet has information (2 <= P <= 100000)

This is followed by P pairs. Each pair has two numbers P and P each where 0<=P <=N1

and

0<=P <=N1

and P != P

Output

Number of ways in which Skynet can select 2 robots such that both the robots are different models.

Example Input:

4 2

0 1

2 3

Example Output:

4

Explanation:

Here robots 0 and 1 are of one model, say model A. And 2 and 3 are of another model, say B.

Therefore the total number of

possibilities of picking 2 robots such that no two robots are of the same model are (

0, 2), (0, 3), (1, 2)

and (1, 4) = 4| Report Duplicate | Flag | PURGE

National Instruments SDE1 C++ - 0of 0 votes

AnswersGLaDOS is feeling bored, so she decided to come up with a board game. The game is as follows. There is

- glory for dreams April 24, 2015 in India

board of dimension n x n (2 <= n <= 10). Each position in this board is either a 0 or a power of 2, between 2

and 2048. Once the board is set up, there are only two moves allowed - move all left or move all right.

The way move all left works is as follows:

For every row on the board, starting from the rightmost position each element is moved to its left. An

element with a zero value does not move. An element with non-zero value can move to its left if the value of

the element to its left is a 0 or has the same value as the current element.

In case, the element to the left is 0 then the element and 0 swap positions i.e., 4 0 0 4 would become 4 0 4 0

In case, the element to the left has the same value as the current element then the left element combines

with its right element and creates an element with double the value in place of the right element and leaves

a 0 in its current place. For e.g., 2 2 would become 4 0 or 2 2 2 2 would become 4 0 4 0.

The combining operation can cause a cascading operation i.e., if the new element created has the same

value as the element to its left, it can combine again.

For e.g., if a row had 8 4 2 2, move left would combine 2 and 2 to form 4 leading to 8 4 4 0. Now, it is

possible to combine further as the element to the left of 4 has the same value, thus after the second

combine, the row would be 8 8 0 0. And again 8 and 8 would form a 16. Thus the final values in the row

would be 16 0 0 0.

But if the row was 8 4 2 0 2, then moving left would result in 8 4 2 2 0. The cascading operation is allowed

only after a combination operation, There would no cascading operation if the element is swapped with 0.

Similar rules apply for move all right, wherein for every row elements starting from the leftmost position

move to their right.

You can either choose move all left or move all right operation but not both. Now given a state of the board,

you have determine what will be the maximum value on the board after either move all left or move all right.

Example

3

2 2 0

2 2 4

2 0 2

Move all left would result in:

4 0 0

4 0 4

2 2 0

The maximum value on the board after this move is 4.

Move all right would result in:

0 4 0

0 0 8

0 2 2

In the first row, 2 and 2 combines to form 4. In the second row, left most 2 combines with 2 to form 4. As the

element to its right has a value 4, combination operation cascades to form 8.

The maximum value on the board after this move is 8.

Now of the two operations, the higher of the two maximum values is 8. Thus the expected output is 8.

Input

3

2 2 0

2 2 4

2 0 2

Output

8

Input

3

0 0 4

0 2 2

0 4 8

Output

8

Time limit per test case:

1 second(s)| Report Duplicate | Flag | PURGE

National Instruments Software Developer C C++ - -2of 2 votes

Answersthere are five persons and each one of them hit a stump with a ball twice. Probability of each one hitting it is P then how many people hit the stump in both the chances?

- ilovecoding July 24, 2013 in India| Report Duplicate | Flag | PURGE

National Instruments Software Engineer / Developer Algorithm - 0of 0 votes

AnswersGiven a shuffle of cards what data structure would you use ? Also tell how would you carry out the suffle operation on that deck such that it is ensured that each card gets shuffled.

- cinderella September 25, 2010| Report Duplicate | Flag | PURGE

National Instruments Software Engineer / Developer Algorithm Data Structures - 0of 0 votes

AnswersGiven a shuffle of cards what data structure would you use ? Also tell how would you carry out the suffle operation on that deck such that it is ensured that each card gets shuffled.

- cinderella September 25, 2010| Report Duplicate | Flag | PURGE

National Instruments Software Engineer / Developer Algorithm - 2of 2 votes

AnswersInput : Two large singly linked lists representing numbers with most significant digit as head and least significant as last node.

- Abhay Srivastava July 01, 2010

Output: Difference between the numbers as a third linked list with Most significant digit as the head.

Eg:

---

Input:

A = 5->4->2->0->0->9->0->0

B = 1->9->9

Output:

C = 5->4->2->0->0->7->0->1

Required complexity :

O(n)

Constraint:

Reversing linked list is NOT allowed| Report Duplicate | Flag | PURGE

National Instruments Software Engineer in Test - 4of 0 votes

AnswersGiven location of huge number of points (you decide the data structure to represent them). Write a function that returns the number of points that are with distance D of a given point P.

- SG October 15, 2008

Write function, complete with what data structures, function signature etc.| Report Duplicate | Flag | PURGE

National Instruments Software Engineer / Developer Large Scale Computing - 1of 1 vote

AnswersDesign a One shot timer library capable of supporting multiple times simultaneously. Cancel is also supported. Only ONE hardware timer register.So basically, a process/function can call SetTime(10) and it will get notified after 10 seconds. It can also say SetTime(2)... SetTime(7). Then it will get two notifications, one after 2 and one after 7. [SetTime returns a handle]

- SG October 15, 2008

The process(s) can also issue a cancel. Cancel(handle), to cancel a specific timer they set.

The hardware timer registers, assume decrements by 1 every 1 second. So if you set it to 10, it will notify you after 10 seconds. Basically it interrupts, and lets say calls RegExpired(). You can Read/Write this register anytime very fast (uS).

The key here how you make use of this single register to support any number of timer events that applications/processes are demanding asynchronously.

Discuss the data structure you would use and implement it in C.| Report Duplicate | Flag | PURGE

National Instruments Software Engineer / Developer Coding - 1of 0 votes

AnswersMake a nonblocking UART library given a underlying UART hardware, data registers and flags that mark end of transmission and stuff.

- SG October 15, 2008

This is very common. Simply look for Software UART in embedded systems. Also uses some OS concepts like round-robin, preventing spin locks etc.| Report Duplicate | Flag | PURGE

National Instruments Software Engineer / Developer Coding - 1of 1 vote

AnswersPrint a Link list in reverse order.

- SG October 15, 2008

Given: PrintReverse(List *head){}

Discuss Pros and cons of Inplace reversal, as compared to reversing by creating a new list. They were looking not only for Memory and Space, but also from a concurrency Point of View.| Report Duplicate | Flag | PURGE

National Instruments Software Engineer / Developer Coding - 1of 1 vote

AnswersGiven a binary tree where each node's value is a COLOR. A clump is formed when more than 3 COLORS are adjacent to each other. Return the total number of clumps in a binary tree.

- vodangkhoa July 17, 2006| Report Duplicate | Flag | PURGE

National Instruments Software Engineer / Developer Coding

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window