One More IV : Optimization
-
Problem 1: Optimization A C++ class has the following member: int status_[75]; During performance analysis it was found out that the class (its object) was performing unsatisfactorily making it a necessary candidate for optimization. The following additional information was also found out *) Each element of the status_ array assumes only the following 4 values: -1, 0, 1, 2 *) The bulk of the time was spent in loops like: for(size_t i=0; i != 75; ++i) { if(status_[i] == 1) { // do something... } } *) The set of elements of the status_ array that assume a particular value is sparse making the above loop inefficient. Assume that 0 is the default value. *) The status_ array is updated at places scattered throughout the code making it difficult to rewrite. However, a particular element is updated only through a statement like status[i] = -1; Task: Your task is to optimize the class, considering the above information. The optimization should introduce the least bugs possible, i.e. it must have minimal changes and those changes that have lesser chance of introducing bugs. Never Ending Probloem
-
Problem 1: Optimization A C++ class has the following member: int status_[75]; During performance analysis it was found out that the class (its object) was performing unsatisfactorily making it a necessary candidate for optimization. The following additional information was also found out *) Each element of the status_ array assumes only the following 4 values: -1, 0, 1, 2 *) The bulk of the time was spent in loops like: for(size_t i=0; i != 75; ++i) { if(status_[i] == 1) { // do something... } } *) The set of elements of the status_ array that assume a particular value is sparse making the above loop inefficient. Assume that 0 is the default value. *) The status_ array is updated at places scattered throughout the code making it difficult to rewrite. However, a particular element is updated only through a statement like status[i] = -1; Task: Your task is to optimize the class, considering the above information. The optimization should introduce the least bugs possible, i.e. it must have minimal changes and those changes that have lesser chance of introducing bugs. Never Ending Probloem
read this[^] before asking what you do
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-
Problem 1: Optimization A C++ class has the following member: int status_[75]; During performance analysis it was found out that the class (its object) was performing unsatisfactorily making it a necessary candidate for optimization. The following additional information was also found out *) Each element of the status_ array assumes only the following 4 values: -1, 0, 1, 2 *) The bulk of the time was spent in loops like: for(size_t i=0; i != 75; ++i) { if(status_[i] == 1) { // do something... } } *) The set of elements of the status_ array that assume a particular value is sparse making the above loop inefficient. Assume that 0 is the default value. *) The status_ array is updated at places scattered throughout the code making it difficult to rewrite. However, a particular element is updated only through a statement like status[i] = -1; Task: Your task is to optimize the class, considering the above information. The optimization should introduce the least bugs possible, i.e. it must have minimal changes and those changes that have lesser chance of introducing bugs. Never Ending Probloem
Again, asking people to answer these questions for you does not help you, and does not help the company that is interviewing you get a proper evaluation of your skill level. At the very least, you should make an attempt prior to asking for help!
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Problem 1: Optimization A C++ class has the following member: int status_[75]; During performance analysis it was found out that the class (its object) was performing unsatisfactorily making it a necessary candidate for optimization. The following additional information was also found out *) Each element of the status_ array assumes only the following 4 values: -1, 0, 1, 2 *) The bulk of the time was spent in loops like: for(size_t i=0; i != 75; ++i) { if(status_[i] == 1) { // do something... } } *) The set of elements of the status_ array that assume a particular value is sparse making the above loop inefficient. Assume that 0 is the default value. *) The status_ array is updated at places scattered throughout the code making it difficult to rewrite. However, a particular element is updated only through a statement like status[i] = -1; Task: Your task is to optimize the class, considering the above information. The optimization should introduce the least bugs possible, i.e. it must have minimal changes and those changes that have lesser chance of introducing bugs. Never Ending Probloem
Indian Idol wrote:
Your task...
Not ours.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
-
Problem 1: Optimization A C++ class has the following member: int status_[75]; During performance analysis it was found out that the class (its object) was performing unsatisfactorily making it a necessary candidate for optimization. The following additional information was also found out *) Each element of the status_ array assumes only the following 4 values: -1, 0, 1, 2 *) The bulk of the time was spent in loops like: for(size_t i=0; i != 75; ++i) { if(status_[i] == 1) { // do something... } } *) The set of elements of the status_ array that assume a particular value is sparse making the above loop inefficient. Assume that 0 is the default value. *) The status_ array is updated at places scattered throughout the code making it difficult to rewrite. However, a particular element is updated only through a statement like status[i] = -1; Task: Your task is to optimize the class, considering the above information. The optimization should introduce the least bugs possible, i.e. it must have minimal changes and those changes that have lesser chance of introducing bugs. Never Ending Probloem
This is not my interview questions. I saw this question somewhere and I wanted to increase my Academic knowledge. Noting related to homework. I have some solutions just wanted to verify and hoping to get a better solution.
-
This is not my interview questions. I saw this question somewhere and I wanted to increase my Academic knowledge. Noting related to homework. I have some solutions just wanted to verify and hoping to get a better solution.