-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.html
More file actions
204 lines (192 loc) · 6.97 KB
/
README.html
File metadata and controls
204 lines (192 loc) · 6.97 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2022-08-03 Wed 13:05 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Data Structures \& C++ STL</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Yash Sonune" />
<link rel="stylesheet" type="text/css" href="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/css/htmlize.css"/>
<link rel="stylesheet" type="text/css" href="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/css/readtheorg.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://fniessen.github.io/org-html-themes/src/lib/js/jquery.stickytableheaders.min.js"></script>
<script type="text/javascript" src="https://fniessen.github.io/org-html-themes/src/readtheorg_theme/js/readtheorg.js"></script>
<script type="text/javascript">
// @license magnet:?xt=urn:btih:e95b018ef3580986a04669f1b5879592219e2a7a&dn=public-domain.txt Public Domain
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.classList.add("code-highlighted");
target.classList.add("code-highlighted");
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.classList.remove("code-highlighted");
target.classList.remove("code-highlighted");
}
}
/*]]>*///-->
// @license-end
</script>
</head>
<body>
<div id="content">
<h1 class="title">Data Structures \& C++ STL</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org2df848b">1. Containers</a></li>
<li><a href="#orgf39c2e0">2. Arrays in C++</a></li>
<li><a href="#orga102599">3. Vector in C++</a>
<ul>
<li><a href="#orgd13a0e5">3.1. Methods</a></li>
</ul>
</li>
<li><a href="#org72080e2">4. Deque in C++</a>
<ul>
<li><a href="#org999523e">4.1. Methods</a></li>
</ul>
</li>
</ul>
</div>
</div>
<p>
"Similar to Collection Library if you are cominng from java background"
</p>
<ul class="org-ul">
<li>Functions</li>
<li>Data Structures</li>
<li>Template Classes</li>
</ul>
<div id="outline-container-org2df848b" class="outline-2">
<h2 id="org2df848b"><span class="section-number-2">1</span> Containers</h2>
<div class="outline-text-2" id="text-1">
<ul class="org-ul">
<li>Container is an object that stores a collection of other objects</li>
<li>Container manages the storage space for its elements & provides member functions to access them (mostly through iterators)</li>
<li>There are 4 categories in Containers</li>
<li>Sequence Containers
Array (Fixed Sequence of Data)
Vector (Expanding in Forward direction)
Deque (Expanding in both directions)
Forward List (Linked List)
List (Double ended Linked List)</li>
<li>Associative Containers
<ul class="org-ul">
<li>Set (orderd Set with unique values)</li>
<li>Map (ordered key-value pairs)</li>
<li>MultiSet (ordered set with non-unique values)</li>
<li>Multimap (ordered keys with non-unique keys)</li>
<li>Unordered Associave Containers (Same as above except thing are not ordered which results in O(1) insertion, lookup and delection)</li>
<li>Unordered Set</li>
<li>Unordered Map</li>
<li>Unordered Multiset</li>
<li>Unordered MultiMap</li>
</ul></li>
<li>Containers Adaptors
NOTE: there are some problems which can only be modeled using these containers, however we build this containers using the premitive data structures or using the above mentioned, but they have been provided for your convenience
<ul class="org-ul">
<li>Stack</li>
<li>Queue</li>
<li>Priority Queue (Implementation based on heap)</li>
<li>the operations are of the complextiy O(n)</li>
</ul></li>
</ul>
</div>
</div>
<div id="outline-container-orgf39c2e0" class="outline-2">
<h2 id="orgf39c2e0"><span class="section-number-2">2</span> Arrays in C++</h2>
<div class="outline-text-2" id="text-2">
<ul class="org-ul">
<li>There are some pros of using STL based arrays</li>
</ul>
</div>
</div>
<div id="outline-container-orga102599" class="outline-2">
<h2 id="orga102599"><span class="section-number-2">3</span> Vector in C++</h2>
<div class="outline-text-2" id="text-3">
<p>
Dynamic array with the ability to resize itself automatically when an element is inserted
Contagious store location, relocation happens when the underlying data is full
</p>
</div>
<div id="outline-container-orgd13a0e5" class="outline-3">
<h3 id="orgd13a0e5"><span class="section-number-3">3.1</span> Methods</h3>
<div class="outline-text-3" id="text-3-1">
<ul class="org-ul">
<li>[] (overloaded)</li>
<li>at()</li>
<li>back()</li>
<li>begin()</li>
<li>caacity()</li>
<li>clear() - Clear all the elements, however the size remains the same</li>
<li>empty()</li>
<li>end()</li>
<li>erase()</li>
<li>front()</li>
<li>insert()</li>
<li>pop<sub>back</sub>()</li>
<li>push<sub>back</sub>()</li>
<li>reserve() (reserve the memory for the array while making)</li>
<li>resize()</li>
<li>size()</li>
</ul>
<p>
NOTE: We dont have push<sub>front</sub> and pop<sub>front</sub> methoed because elements will be added at the back, and also push/pop at the beginning would casue the whole element to be shifted.
</p>
</div>
</div>
</div>
<div id="outline-container-org72080e2" class="outline-2">
<h2 id="org72080e2"><span class="section-number-2">4</span> Deque in C++</h2>
<div class="outline-text-2" id="text-4">
<p>
double-ended queue is sequence containers with dynamic sizes that can be expanded or contracted on both ends (front or back)
deques are not guaranteed to store all its elements in contiguous storage locations: accessingg elements in a deque by offsetting a pointer to another element cause udefined behavior
Elements of a deque can be scattered in different chunks or storage
</p>
</div>
<div id="outline-container-org999523e" class="outline-3">
<h3 id="org999523e"><span class="section-number-3">4.1</span> Methods</h3>
<div class="outline-text-3" id="text-4-1">
<ul class="org-ul">
<li>[] (overloaded again)</li>
<li>at()</li>
<li>back()</li>
<li>begin()</li>
<li>capacity()</li>
<li>clear()</li>
<li>empty()</li>
<li>end()</li>
<li>erase()</li>
<li>front()</li>
<li>insert()</li>
<li>pop<sub>back</sub>()</li>
<li>pop<sub>front</sub>()</li>
<li>push<sub>back</sub>()</li>
<li>push<sub>front</sub>()</li>
<li>resize()</li>
<li>size()</li>
</ul>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="date">Date: 2022-07-31</p>
<p class="author">Author: Yash Sonune</p>
<p class="date">Created: 2022-08-03 Wed 13:05</p>
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>