Wednesday, July 21, 2010

Stack vs. Queue

I was asked the other day about First In, First Out (FIFO) and First In, Last Out (FILO) data structures.

Sticking to basic data structure examples a Stack and a Queue represent these type of operations.

Queue

Think of a queue as standing in line at the movie theater or anywhere else you would stand in line.  You stand in line until called up (ususally when a ticket window is available to help you, or in computer terms when a queue item is ready to be processed).  The first person in line will be the first person helped and the last person in line will be the last person helped.  So First In, First Out; FIFO.  Conversely, Last In will be Last Out.

Stack

In a "traditional" implementation of a stack things will be First In, Last Out; FILO.  Think of a stack as a stack of papers.  As you stack the paper the first paper in the stack will be at the bottom.  So as you work through the stack of papers, the last item will be first one off the stack.  So First In, Last Out.  Conversely, Last In, First Out.

Of note, putting an item on a stack is called a "push" and removing an item from the stack is called a "pop".

Usage in Applications

A queue is probably used more often than a stack based on my professional experience.  Generally, items on a queue follow an order such that you want to process the first item in before the previous item due to business rules.  For example, imagine if I had a queue for order creation and changes.  An order must exist to be changed so logically I need to process the creation of the order first.  Using a queue, the creation action will always occur before the changes.  Then when a change occured, I could apply the changes to the order.  Then a subsequent change would be inacted upon the order based on the previous change, etc.

A stack is well suited for cases where the newest information is what you'll access first. So a cache or something like that.  I might have a stack to store objects and the last used object will be the last (first out) item of the cache.

Friday, July 16, 2010

Artistic PC Mods

Something I've become interested in recently is optimizing living space.  A basic example, why have a room dedicated to computers, monitors, scanners, faxes, etc?  Instead of buying a monitor why not buy a more expensive TV that has the resolution I need and use that as my monitor?  Especially considering I can't use the computer in one room and watch TV in another room at the same time.

The challenge in this type of a situation is how to hide/integrate your electronics.  The computer will overheat if you shove it in an enclosed space but also is cluttered looking if you shove it next to your entertainment center.

Presently, I'm looking into three different solutions that I wanted to share and I'd be interested to know if anyone does these and how they turn out.

1. Functional Computer Wall Art:  Ditch the case and mount your computer components to a piece of colored peg board or plywood.  Layout the components so its visually interesting (artistic) but also so everything is connected and functional.  Maybe add some lighting or other dramatic effect to have a functional one of a kind piece of art.  With something like this you could mount it above your TV or on a wall and cleverly run cables in a neat and orderly manner.

2. Computer Table: Build your computer into a coffee table or something such that you can use the table as a table but when needed it holds your keyboard, mouse, and computer components required to run.  If you have a flat panel you could mount it horizontally under a transparent acrylic table top.  If done, I would try and make the components (like the wall art) look interesting.

3. Submerged Computer:  I've been thinking about but its a little expensive to setup.  Basically you take a small fish tank (about 5-6 gallons) and mount your computer components inside.  Instead of water you use mineral oil, which is non-conductive.  The mineral oil serves to draw heat from the computer components and well as give an appearance, well, an aquarium.

Most plans you'll see for this on the internet (and I agree with) state that you should only submerge the motherboard and its accessories.  Hard drives and other optical drives should be mounted behind or in the light housing on top of the tank.  Both types of drives rely on high RPM rotation to work properly and the mineral oil would cause them to spin too slowly.  While a hard drive should be sealed well enough to be submerged its not recommended.  A solid state drive, however, will not have any problems.

One thing you'll notice in such a setup is that the fans will spin slowly due to the friction of the mineral oil.  No worries as the oil is what is absorbing the heat now so the fans really offer more of a visual appeal than anything.  You could also use a pump an add bubbles to the aquarium too.  

I've been contemplating a design where a smaller tank is submerged in the bigger tank but with water so I could put a fish or two in it.  That way it woul really look like a real aquarium despite being two separate things.  My concern, however, is if water starts leaking and/or spills into the other tank.  Zap!

Final word of warning on these mineral oil tanks as well... the mineral oil has a tendency to wick so over time you'd start finding oil dripping from your mouse,keyboard,etc.  The best solution is to make sure the ports are out of the oil solution and using a wireless setup.

Saturday, July 10, 2010

Gazelle

I wanted to take a quick opportunity and mention a cool website for those looking for a no hassle way to sell your DVDs and small electronic devices with no hassle.  The website is Gazelle.com.

The process is simple... you browse their site and find items that you have that they are willing to buy.  It will ask you for the condition of the item and what accessories you have.  Based on this, you get a guaranteed price for the item.  If you have enough stuff then Gazelle ships you a box and postage paid label.  Otherwise, you get the postage paid label but have to provide your own box.

Once the condition of your items is verified Gazelle will pay you via PayPal, Check by mail, etc.  If there is a dispute between the condition you listed and what Gazelle believes the condition is then you can either accept the revised offer or have them ship you the item back for free.

Last, if an item no longer has value they will take it and either sell it to a reuse shop or recycle it.

The key is not to wait as if you have items sitting around they progressively lose value.

Some examples from this week of items they're collecting and prices paid for items in good condition:
Iron Man for XBox 360: $8
HTC Droid Eris : $128? I can't remember exactly.
Nintendo Wii  w/ controller: $78

But an old Blackberry like the 8700 series is a recycle item.

It is worth noting that you could get better prices from Ebay or god forbid Craig's List but you have the time, selling and shipping costs to contend with.  If you're going for max price then Gazelle may not be the answer but if you're going for sold now then it might be a better bet.

Wednesday, July 7, 2010

Arduino and LaunchPad

There are two great products out right now to help you begin tinkering with running your software in conjunction with hardware devices.  And... its never been easier!

The first is the Arduino boards.  The newer boards offer a USB interface to upload your application and communicate back and forth with the device.  There are a variety of sensors, GPS, wireless, ethernet, and other boards/cards/chips such that you can design exactly what you need.

Out of the Box ready Arduino boards run from $20-$40.  The sensors and LEDs run less than $2.00 but the networking/communication products run $40+.

Secondly, is TI's Launchpad kit.  The kit contains a couple of their value line chips and an evaluation board with some built-in LEDs and buttons.  Like the Arduino, the board uses USB.  Once programmed, these chips can be moved to a permanent board with whatever accessories you choose.  This kit is a mere $4.30.  Yes four dollars and thirty cents.  However, the kit is currently on backorder through August.

Both platforms also have free software and the languages are a flavor of C++ with much of the complexity hidden behind pre-written modules.