Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. One More IV : Optimization

One More IV : Optimization

Scheduled Pinned Locked Moved C / C++ / MFC
performancec++algorithmsdata-structureshelp
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nawal K Gupta
    wrote on last edited by
    #1

    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

    T Z D N 4 Replies Last reply
    0
    • N Nawal K Gupta

      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

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      read this[^] before asking what you do


      TOXCCT >>> GEII power

      [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

      1 Reply Last reply
      0
      • N Nawal K Gupta

        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

        Z Offline
        Z Offline
        Zac Howland
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • N Nawal K Gupta

          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

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • N Nawal K Gupta

            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

            N Offline
            N Offline
            Nawal K Gupta
            wrote on last edited by
            #5

            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.

            S 1 Reply Last reply
            0
            • N Nawal K Gupta

              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.

              S Offline
              S Offline
              super_ttd
              wrote on last edited by
              #6

              :~

              -- TTD --

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups