Data Structure Cte 115
Data Structure Cte 115
Data Structure is the systematic way used to organise the data. The characteristics
of Data Structures are:
Time Complexity
The time factor should be very punctual. The running time or the execution time of a
program should be limited. The running time should be as less as possible. The less
the running time, the more accurate the device is.
Correctness
Each data must definitely have an interface. Interface depicts the set of data
structures. Data Structure should be implemented accurately in the interface.
Space Complexity
The Space in the device should be managed carefully. The memory usage should be
used properly. The space should be less occupied, which indicates the proper
function of the device. J
Data elements in a linear data structure are linked to one another in a sequential
arrangement, with each element linked to the elements in front of and behind it. In
this manner, a single run can traverse the structure. Linear data structures consist of
four types. They are:
• Stack
• Array
• Queue
• Linked list
Stack
The linear data structure stores the data elements in the ‘first-in/ last-out’ or the ‘last-
in/ first out’ order. These orders are known as FILO and LIFO orders, respectively. By
using Stack, the element can be added and removed simultaneously from the same
end. In Stack, the terms ‘Push’ and ‘Pop’ are used instead of ‘insert’ and ‘delete’.
Application of the Stack
1. A Stack helps to manage the data in the ‘Last in First out’ method.
2. When the variable is not used outside the function in any program, the Stack
can be used.
3. It allows you to control and handle memory allocation and deallocation.
4. It helps to automatically clean up the objects.
Disadvantages of Stack
1. It is difficult in Stack to create many objects as it increases the risk of the Stack
overflow.
2. It has very limited memory.
3. In Stack, random access is not possible
Stack Operation
2
Push item Pop Item
8
45
Arrays
An array is a linear data structure that collects elements of the same data type and
stores them in contiguous and adjacent memory locations. Arrays work on an index
system starting from 0 to (n-1), where n is the size of the array.
One-Dimensional Arrays:
You can imagine a 1d array as a row, where elements are stored one after another.
Multi-Dimensional Arrays:
Two-Dimensional Arrays:
Queue
The queue is a linear data structure that follows the FIFO order. FIFO stands for First
in and First Out. The order is that the elements which are inserted first are to be
removed first.
We can also define a queue to be a list in which all additions to the list are made at
one end, and all deletions from the list are made at the other end. The element
which is first pushed into the order, the operation is first performed on that.
Characteristics of Queue
Linked List
Linked Lists separate the data structures that are stored consecutively. The last
node of a data structure will be linked to the first node of the next data structure. The
first element of any data structure is known as the Head of the List.
In simple words, a linked list consists of nodes where each node contains a data
field and a reference(link) to the next node in the list.
There are three types of Linked Lists. They are:
The data structure in which the data elements are randomly arranged. The elements
are non-arranged sequentially. The data elements are present at different levels. In
Non-linear data structures, there are different paths for an element to reach the other
element. The data elements in the non-linear data structures are connected to one or
more elements. There are two types of non-linear data structures. They are:
Tree data structures are completely different from the arrays, stacks, queues and
linked lists. Tree data structures are hierarchic. The tree data structure collects the
nodes together to depict and stimulate the sequence. Tree data structure does not
store the data sequentially. It stores the data on multiple levels. The top node of the
Tree Data Structure is known as the Root Node. Any type of data can be stored in the
root node. Each node shall definitely contain the data. The branches in the Tree Data
Structure are known as the children.
The different parts of the Tree Data Structure are:
1. Root Node
2. Child Node
3. Edge
4. Siblings
5. Leaf Node
6. Internal Nodes
In Graph Data Structure, one node is simply connected to the other node through the
edge of the graph. The Graph Data Structure obviously uses Non-linear data
structures which are not sequentially arranged. The graph data structures consist of
edges and nodes represented by E and V, respectively. Graph Data Structures do not
have root nodes. It does not have a standard order of arranging the data. Every tree
is also known as the graph with n-1 edges where ‘n’ represents the total number of
vertices in the graph. There are various categories in the graphs such as undirected,
unweighted, directed and weighted.
The different parts of the graph are as follows.
1. Vertex
2. Edges
3. Directed Edge
4. Undirected Edge
5. Weighted Edge
6. Degree
7. Indegree
8. Outdegree
Data Types
Data types are the basic elements in the classification of the data. Data types are
used in the transmission of information between the programmer and the compiler.
There are different data types. They are as follows.
Boolean:
Boolean is a data type, and the value in the Boolean can be either false or true or
positive or negative. A Boolean type of data proves whether the data is valid or
invalid. Boolean values have two possible states such as True or False. In the binary
system, the values 0 and 1 are used
Integer:
The integer data type stores both positive numbers and negative numbers along with
zero (-1, 0, 1). All the arithmetic operations can be efficiently done through integer
data types.
Float:
A floating-point data type approximates real numbers they include both integers and
fractional part. These number are useful when dealing with computations that
requires decimal point. (e.g. 100.3,120.6,5.1).
String
A string data type consists of a series of characters, either in the form of a literal
constant or a variable. (e.g. text, number, or symbol)
following are the most frequent operations that may be done on data structures:
Data Storage.
Data Exchange.
Data structures such as linked lists can enable core operating systems resources
and services to perform functions like file directory management, memory allocation,
and processing scheduling queues.
Scalability.
Big data applications rely on data structures to manage and allocate data storage
across many distributed storage locations. This function guarantees scalability and
high performance.
2. The use of data structures makes it easier to retrieve data from a storage
device.
3. The data structure allows for the effective and efficient processing of both
little and big amounts of data.
4. Manipulation of vast amounts of data is simple when a proper data
structure technique is used.
5. The use of a good data structure may assist a programmer to save a lot of
time or processing time while performing tasks such as data storage,
retrieval, or processing.
7. Data structures such as arrays, trees, linked lists, stacks, graphs, and so on
are thoroughly verified and proved, so anybody may use them directly
without the need for study and development.
Because linear data has only one non-linear data structure data elements
Traversal level, traversing each data item cannot be retrieved in a single run. It is
needs only one run. necessary to traverse many runs.