This past week, the Dow Jones Industrial Average's (^DJI 0.40%) best-performing stock was Microsoft (MSFT 1.82%), which rose 9.27%, while the worst-performing component was Hewlett-Packard (HPQ -0.46%), down 15.21%.

But despite the difference between the big moves each company made this week, they have a lot in common. And I don't believe it would be too much of a stretch to think that in a few weeks or months, the two companies could switch positions, with Microsoft falling and Hewlett-Packard rising.

The most obvious similarity is that Microsoft and HP are both large-cap technology companies. They both generate a good portion of their revenue from the PC industry, and they've both seen PC sales falter, thus hurting their main source of revenue and lowering their profits.

With the quick emergence of tablets and smartphones, both companies have also tried moving into mobile computing to offset their PC losses. Neither has had much success so far, but they certainly need to change their focus from the PC business to other opportunities.

Neither company is on the verge of going bankrupt and falling off the map, but as we've seen so many times before, if Microsoft and HP don't start changing now, they will fall off the map within the next decade. The technology industry is constantly changing and evolving. Companies that get comfortable and lazy get left behind.

The good news for both companies' shareholders is that they're aware of the need to change, and change now. HP in particular has been attempting to change its business for almost two years now, as CEO Meg Whitman leads her team down the turnaround path she's laid out. The stock took a hit this week after Whitman said HP won't grow revenue in 2014, a reversal from her previous outlook. But the stock is still up 57.19% since the start of 2013, and there's a long way to go before Whitman wraps up her five-year turnaround plan. Time will tell if the team at HP can right the ship and get sales and profits growing again despite a dying PC business.

As for Microsoft, shares went wild on the announcement that CEO Steve Ballmer will retire within the next 12 months. I think Ballmer's exit is a sign that Microsoft understands the need to change directions if it wants to remain an industry leader.

Still, don't be surprised if the tables turn for these companies down the road. HP could jump higher as its turnaround plan plays out, and Microsoft could tank if a new CEO comes in and things appear worse than investors thought they were. Don't be shocked. These things happen.