abhays.1984
BAN USER- 0of 0 votes
AnswersGiven an array of balls, which can be one of two colors (RED or BLUE), write a function that partitions the array in-place such that on exit from the function all the balls of the same color are contiguous. It does not matter whether the red or blue balls come first. The return value from the function is the index of the first ball of the second color. If there is only one color of balls in the array then the return value should be 0. It is not legal to change the color of a ball. They must be moved. Consider performance, memory utilization and code clarity and elegance of the solution when implementing the function.
- abhays.1984
C++ Prototype
class Ball
{
public:
enum BallColor { RED, BLUE };
BallColor Color() const { return _color; }
private:
BallColor _color;
// Other data in class (unrelated to assignment)
};
unsigned Partition( Ball aBalls[], unsigned cBalls )
{
//your code goes here
}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
Answers#1. Implement (in C++ or C#) a function that removes the nth element of a single linked list.
- abhays.1984
C++:
class Node
{
char* value;
Node* next;
};
Node** RemoveNth (Node** list, int n)
{
}
C#:
class Node
{
string value;
Node next;
}
Node RemoveNth(Node list, int n)
{
}
#2. Using the following table provide at least 5 test cases to test the function implemented in the previous part.
Node n Expected Result
~~~~ ~~~ ~~~~~~~~~~~~~~~~~| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Coding Data Structures Testing - 0of 0 votes
AnswersWrite a function that would: return the 5th element from the end in a singly linked list of integers, in one pass, and then provide a set of test cases against that function
- abhays.1984| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Coding Testing Linked Lists
can anyone write atleast 5 scenarios to test the above function?
- abhays.1984 March 23, 2010