Monday 13 April 2020

STATIC AND DYNAMIC DATA IMPLEMENTATIONS


In computer science, a static data structure is a data structure created for an input data set which is not supposed to change within the scope of the problem. When a single element is to be added or deleted, the update of a static data structure incurs significant costs, often comparable with the construction of the data structure from scratch. In real applications, dynamic data structures are used, which allow for efficient updates when data elements are inserted or deleted.There exist methods, called dynamization, to convert static data structures into dynamic ones.

1. Static data means the data that occurs one time during it life time.Once it is created it cannot be deleted or modified. Static data is the root of dynamic data and linked with dyanamic data as index of them.
2. In dyanamic data structure emory allocation for the data structure takes place at run time,only requered amount of memory is allocated(eg.linked lists).In static data structure memory is reseved at the time of compilation(eg.arrays).

Storing a queue in a static data structures
This implementation stores the queue in and tail of the queue are currently stored not necessarily at index 0. The array can if the last index of the array is reached.
The array indices at which the head must be maintained. The head of the queue is be a “circular array” – the queue “wraps round”
 
Storing a queue in a static data structures

Storing a queue in a dynamic data structure
As in the case of the stack, each node in a dynamic data structure contains data AND a reference to the next node.
A queue also needs a reference to the head node AND a reference to the tail node.
The following diagram describes the storage of a queue called Queue. Each node consists of data (DataItem) and a reference (NextNode).
 
Storage of queue

           The first node is accessed using the name Queue.Head.
           Its data is accessed using Queue.Head.DataItem
           The second node is accessed using Queue. Head. NextNode
           The last node is accessed using Queue. Tail

No comments:

Post a Comment