Data Structure
Data Structure
03/16/24
Data Structures
There are two built-in data structures that can be used to organize
data, or to create other data structures:
Lists
Arrays
Arrays and Lists
A list is an ordered set of data. It is often used to store objects that
are to be processed sequentially.
You can see the difference between arrays and lists when you
delete items.
In a list, the missing spot is filled in when something is deleted.
In an array, an empty variable is left behind when something is
deleted.
Record
In computer science, a record (also called struct or compound
data) is a basic data structure.
A record is a collection of fields, possibly of different data types,
typically in fixed number and sequence. The fields of a record
may also be called members, particularly in object-oriented
programming. Fields may also be called elements.
03/16/24
Linked List
In computer science, a linked list is a linear collection of data
elements, called nodes, each pointing to the next node by means of
a pointer. It is a data structure consisting of a group of nodes which
together represent a sequence. Under the simplest form, each node
is composed of data and a reference (in other words, a link) to the
next node in the sequence. This structure allows for efficient
insertion or removal of elements from any position in the sequence
during iteration. More complex variants add additional links, allowing
efficient insertion or removal from arbitrary element references.
03/16/24
Memory Representation of Linear Linked List
Let LIST is linear linked list. It needs two linear arrays for memory
representation. Let these linear arrays are INFO and LINK. INFO[K]
contains the information part and LINK[K] contains the next pointer
field of node K. A variable START is used to store the location of the
beginning of the LIST and NULL is used as next pointer which
indicates the end of LIST. It is shown below:
03/16/24
Memory Representation of Linear Linked List
03/16/24
Binary Tree
03/16/24
Representation of Binary Tree in Memory
Let T is Binary
There are two ways of representing binary tree in memory
Sequential representation
Linked representation
Sequential Representation.
Suppose T is a complete binary tree. Then only single linear array TREE
is used as follows.
03/16/24
Representation of Binary Tree in Memory
The root R is stored in TREE[0].
If a node n occupies TREE[K],
then its left child in TREE[2*K]
& right child TREE [2*K+1].
If TREE[1]=NULL then it is empty tree.
03/16/24
Linked Representation
03/16/24
Linked Representation
03/16/24
Any Query
03/16/24