Wednesday 26 October 2011

Programming Ethics



Basics

When we deal with data structures, they are mainly of two types; linear or nonlinear. Linear term is used when a data structure is forming a sequence, and other doesn’t. We know everything in computer deals with memory and henceforth, we have a concept of array and linked lists. Similarly, nonlinear structures are represented as graphs and trees. The main purpose of such classification is to minimize our work and to perform basic operations on these liner structures.

Traversing: In this each element is processed in the list.
Searching: To find a location of an element with a known value.
Insertion: To add a new element in the list.
Deletion: To remove an element from the list.
Sorting: To arrange the elements in some defined order.
Merging: Combining more than two lists in a single list.


Now, it depends upon the user to use the best available option, i.e. arrays or linked list according to the available data and the number of operations one need to carryout.

Linear Arrays


A linear array can be described as a collection of same type of data type and should be finite i.e. having an end point. The elements in this case are referenced respectively with the help of index collection of consecutive numbers mainly starting from zero as a default. While dealing with memory, the elements are again stored respectively in consecutive memory locations.

When it comes of defining an array, this is simply in three parts. Firstly, we need to define its name then its data type (by default it is integer in case of C++), and the last one is its index set. So, it looks like int A [5]. Here, A is the name & 5 is the index set, this array is of integer type.


Note: Length of an array is given by a formula. Length=UB-LB+1, UB means upper bound and LB stands for lower bound. For an instance, the length or the number of elements in an array is always one more then the defined index set. Now, when actual programming is done with arrays, we come across two terms. Statical approach is the approach where it is defined in the memory that while compilation of a program, allocates memory space for array & hence sixe becomes fixed during program execution. Another approach is to get the value of index set while execution & hence this is termed a dynamical approach.


0 comments:

Post a Comment