Data Structures | Introduction

Download:Introduction To Data Structures

Data Structures:

A variable is a named location in memory which stores a data value.

A data structure is a collection of memory locations, which are joined together.

Operations on Data Structure:

  • Appending – Add a new data value to the end of the data structure
  • Inserting – Add a new data value somewhere else in the data structure
  • Editing – changing the value of one data item
  • Deleting – Removing a data value
  • Traversing – visiting every data item in turn. This is done when searching for an item or printing out every item in the data structure.
  • Sorting – rearrange the data items into alphabetical or numerical order.

Abstract Data Types:

An abstract data type is one that is created by the programmer, rather than defined within the programming language. These include data structures like:

  • Queues
  • Stacks
  • Trees
  • Graphs

An abstract data type is a logical description of how the data is viewed and the operations that can be performed on it. However, the way that this is completed is not necessarily known to the user. This is because it is up to the programmer, who creates the data structure, to decide how to implement it and how to build it into a programming language.

This is a good example of data abstraction. This level of abstraction also creates encapsulation around the data, which hides the details of implementation from the user.

Dynamic vs Static Data Structures:

An abstract data type many be implemented using either a dynamic or static data structure.

A dynamic data structure is a collection of data in memory that has the ability to grow or shrink in size. This done with something called ‘heap’, which is a portion of memory from which space is automatically allocated or de-allocated as required.

Dynamic data structures are very useful for implementing data structures such as queues when the maximum size of the data structure is not known in advance.

A Static Data Structure (such as an array) is fixed in size, and cannot increase in size or free up memory while the program is running. The size of the array has to be determined in advance by the programmer. If the maximum number of items in the array has been used up, then no more items can be added, even if there are still free memory space available.

 15 total views,  1 views today