Hello everyone! Today we are going to start with a new topic in general. Data Structures! Hence lets get started with an introduction!
What is a Data Structure?
While Data refers to values or simply a set of values, Information refers to meaningful or processed data. Data may be organized in many different ways. The logical or mathematical model of a particular organization of data is called a data structure. The choice of a particular data model depends upon two considerations, as following:
- It must be rich enough in structure to mirror the actual relationship of data in the real world.
- The structure should be simple enough that one can process the data when necessary.
Types of Data Structures
Data Structures can be classified into the above subgroups. Lets us know more about the what and why of the above classification.
Primitive Data Structures
These are those data structures that fit the base architecture of a given computer. Primitive data are only single values that don't have any special capabilities. Primitive Data Types can further be classified into:
- Integers: represents integral data type, the mathematical integers that you might already be familiar with. Integral data types may be of different sizes and may or may not be allowed to contain negative values.
- Float: represents decimal numbers. The level of precision (number of digits that can be stored behind the decimal point) varies from system to system again.
- To represent 2, you'd choose an integer data type. To represent 2.3, you'd choose a float data type.
- Characters: represent the set of alphabets and special characters.
- Pointers: are used to point to another value stored elsewhere in the computer memory using its address. A pointer references a location in memory, and obtaining the value stored at that location is known as dereferencing the pointer. As a result, pointers store memory addresses.
- As an analogy, a page number in a book's index could be considered a pointer to the corresponding page; dereferencing such a pointer would be done by flipping to the page with the given page number.
Non-Primitive Data Types
These are those data structures that are derived from Primary/Primitive Data Structures. Non -Primitive Data Types are used to store a group of values. They can be further classified into:
- Arrays: This is the simplest type of Data Structure. By a linear array we mean a list of finite members n of similar data elements referenced respectively by a set of n consecutive numbers. Usually 1, 2, 3...n. If we choose the name A for the array, then the elements of A are denoted by the subscript notation a1, a2, a3…an or by the bracket notation A[1], A[2], A[3]...A[n].
- Linked Lists: are Data Structures consisting of a group of nodes which together represent a sequence. Each node is composed of a data and a reference to the next node in the sequence. This structure allows for a very efficient insertion or removal of elements from any positing in the sequence.
- Trees: Data frequently contains a hierarchical relationship between various elements. The Data Structure which reflects this relationship is called a Tree.
- Stacks: A stack, also called a Last In First Out (LIFO) Data Structure, is a linear list in which insertions and deletions can take place only at one end. This structure is similar in its operation to a stack of dishes as shown below. Note that new dishes are inserted only at the top of the stack and dishes can be deleted only from the top of the stack.
- Queue: A queue, also called a First In First Out (FIFO) Data Structure, is a linear list in which deletions can take place only at one end of the list, the FRONT of the list and insertions can take place only at the other end of the list, the REAR of the list. The structure operates in much the same way as a line of people waiting at a bus stop as pictured in the figure. The first person in line is the first person to board the bus.
- Graphs: Data sometimes contains a relationship between pairs of elements which is not necessarily hierarchical in nature. For example
Data Structure Operations
The data appearing in our Data Structure is processed by means of certain operations. In fact, the particular Data Structure that one chooses for a given situation depends largely on the frequency with which specific operations are performed. Given below are some of the most frequently given Data Structure Operations:
- Traversing: Accessing each record exactly once so that certain items in the record may be processed.
- Searching: Finding the location of the record with the given key value, or finding the location of all records which satisfy one or more conditions.
- Inserting: Adding a new record to the structure.
- Deleting: Removing a record from the structure.
Sometimes two or more of the operations may be used in some situations. For example we may want to delete a record with a given key, which may mean we first need to search for the location of the record and then delete it.
The following two operations which are used in special situations should also be considered.
- Sorting: Arranging the record in some logical order. Can be alphabetical, numerical, etc. order.
- Merging: Combining the record in two different sorted files into a single sorted file.
And with this, we finish our basic introductory lesson in data structures. I really hope you enjoyed it. I'll be looking forward to seeing you again in a new related lesson soon in the future. Take care :)
This article is so good.
ReplyDelete