Thursday, March 19, 2009

Algorithm Analysis

Algorithm Analysis is another essential part of the computer programming process. Algorithm analysis is analyzing the algorithm that you have created for efficiency and running time. There are different ways to solve programming problems and many times one way is way more efficient than another. In algorithm analysis you are presented with ways to decide how long a certain algorithm will take to run. There are several different types of analysis that can be done. The type of analysis I will focus on is asymptotic analysis. Asymptotic analysis is a technique of graphing different scenarios in different types of notation to get a picture of what the running time would be. Big Oh notation is one of the types of asymptotic analysis. This analysis allows you to find the worst case scenario of an algorithm and ensure that the algorithm is running below that time. Big omega is analysis which finds the best case scenario and theta notation which finds the average case scenario. Using these notations you can analyze the algorithm to get a picture of the running time of a program and then compare which algorithms are more efficient than others.

Pointers in C++


Pointers are a key feature within the C++ programming language. Pointers are variable used to point to different data within a program. An analogy used to describe pointers is that your address is a pointer to your home. The pointer has its own memory address. Pointers must be initialized to a specific data type. A pointer of type int can only point to int data, while a pointer of type string can only point to data of type string. Pointers are used for many different uses within C++.

One of the most essential uses of a pointer is to use it to point to the different elements of an array of dynamic memory. Dynamic memory is memory created with the new operator which enables you to easily remove the memory after it is no longer necessary for to the program. This is necessary in C++ because it does not have garbage collection. This makes the pointer essential to programming in C++. Once memory is dynamically allocated you can reference it using the pointer. The use of the pointer to reference the memory saves memory space and allows the programmer to function at a higher efficiency than if programmed without the use of the pointer and dynamic memory allocation.