-
Notifications
You must be signed in to change notification settings - Fork 0
/
datastructure.html
157 lines (138 loc) · 7.63 KB
/
datastructure.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
<head>
<title>Data Structures Tutorial</title>
<style>
body {
font-family: Arial, sans-serif;
background: linear-gradient(90deg,rgba(63,94,251,1) 0%, rgba(135,252,70,1) 100%);
color: #fff;
margin: 0;
padding: 0;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 40px;
background-color: rgba(0, 0, 0, 0.7);
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
h1 {
color: #fff;
text-align: center;
margin-bottom: 30px;
}
h2 {
color: #fff;
margin-top: 40px;
}
p {
line-height: 1.6;
margin-bottom: 20px;
}
ul {
list-style-type: disc;
margin-left: 20px;
}
a {
color: #fff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>Data Structures (DS) Tutorial</h1>
<h2>What is Data Structure?</h2>
<p>
The data structure name indicates itself that organizing the data in memory. There are many ways of organizing the data in memory, such as arrays, linked lists, stacks, queues, graphs, and more.
</p>
<p>
Data structures are not programming languages like C, C++, Java, etc. They are sets of algorithms that can be used in any programming language to structure the data in memory.
</p>
<h2>Types of Data Structures</h2>
<p>
There are two types of data structures:
</p>
<ul>
<li>Primitive data structure</li>
<li>Non-primitive data structure</li>
</ul>
<h3>Primitive Data Structure</h3>
<p>
The primitive data structures are primitive data types, such as int, char, float, double, and pointer, that can hold a single value.
</p>
<h3>Non-Primitive Data Structure</h3>
<p>
The non-primitive data structure is divided into two types: linear data structure and non-linear data structure.
</p>
<h4>Linear Data Structure</h4>
<p>
The arrangement of data in a sequential manner is known as a linear data structure. Examples include arrays, linked lists, stacks, and queues.
</p>
<h4>Non-Linear Data Structure</h4>
<p>
Non-linear data structures, such as trees and graphs, have elements arranged in a random manner where one element can be connected to 'n' number of other elements.
</p>
<h2>Major Operations</h2>
<p>
The major operations that can be performed on data structures are searching, sorting, insertion, updation, and deletion.
</p>
<h2>Which Data Structure?</h2>
<p>
The choice of a data structure depends on the efficiency required in terms of time and space. Different data structures can be implemented for a particular abstract data type (ADT), and the best one suited for the requirements is selected.
</p>
<h2>Advantages of Data Structures</h2>
<p>
The advantages of using data structures include efficiency, reusability, and abstraction. Data structures make programs efficient in terms of time and space, allow reusability, and provide abstraction by hiding the internal workings.
</p>
<h2>Data Structures Index</h2>
<ul>
<li><a href="#">DS Basics</a></li>
<li><a href="#">DS Array</a></li>
<li><a href="#">DS Linked List</a></li>
<li><a href="#">DS Stack</a></li>
<li><a href="#">DS Queue</a></li>
<li><a href="#">DS Tree</a></li>
<li><a href="#">DS Graph</a></li>
<li><a href="#">DS Searching</a></li>
<li><a href="#">DS Sorting</a></li>
<body>
<h1>What is an Algorithm?</h1>
<p>An algorithm is a process or a set of rules required to perform calculations or some other problem-solving operations, especially by a computer. The formal definition of an algorithm is that it contains a finite set of instructions which are being carried out in a specific order to perform a specific task. It is not the complete program or code; it is just a solution (logic) of a problem, which can be represented either as an informal description using a flowchart or pseudocode.</p>
<h2>Characteristics of an Algorithm</h2>
<ul>
<li>Input: An algorithm has some input values. We can pass 0 or some input value to an algorithm.</li>
<li>Output: We will get 1 or more outputs at the end of an algorithm.</li>
<li>Unambiguity: An algorithm should be unambiguous, which means that the instructions in an algorithm should be clear and simple.</li>
<li>Finiteness: An algorithm should have finiteness. Here, finiteness means that the algorithm should contain a limited number of instructions, i.e., the instructions should be countable.</li>
<li>Effectiveness: An algorithm should be effective as each instruction in an algorithm affects the overall process.</li>
<li>Language independent: An algorithm must be language-independent so that the instructions in an algorithm can be implemented in any of the languages with the same output.</li>
</ul>
<h2>Dataflow of an Algorithm</h2>
<p><strong>Problem:</strong> A problem can be a real-world problem or any instance from the real-world problem for which we need to create a program or a set of instructions. The set of instructions is known as an algorithm.</p>
<p><strong>Algorithm:</strong> An algorithm will be designed for a problem, which is a step-by-step procedure.</p>
<p><strong>Input:</strong> After designing an algorithm, the required and the desired inputs are provided to the algorithm.</p>
<p><strong>Processing unit:</strong> The input will be given to the processing unit, and the processing unit will produce the desired output.</p>
<p><strong>Output:</strong> The output is the outcome or the result of the program.</p>
<h2>Why do we need Algorithms?</h2>
<ul>
<li><strong>Scalability:</strong> It helps us to understand scalability. When we have a big real-world problem, we need to scale it down into small steps to easily analyze the problem.</li>
<li><strong>Performance:</strong> The real-world is not easily broken down into smaller steps. If the problem can be easily broken into smaller steps, it means that the problem is feasible.</li>
</ul>
<h2>Algorithm Example: Making Lemon Juice</h2>
<ol>
<li>First, we will cut the lemon into half.</li>
<li>Squeeze the lemon as much as you can and take out its juice in a container.</li>
<li>Add two tablespoons of sugar in it.</li>
<li>Stir the container until the sugar gets dissolved.</li>
<li>When the sugar gets dissolved, add some water and ice in it.</li>
<li>Store the juice in a fridge for.
</ul>
</div>
</body>
</html>