<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4922233653576692316</id><updated>2011-04-21T15:52:06.453-07:00</updated><title type='text'>Speak Up</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://simplenstraight.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4922233653576692316/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://simplenstraight.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Chirag Sethi</name><uri>http://www.blogger.com/profile/16510329321349750614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4922233653576692316.post-637067741496342736</id><published>2008-08-14T03:41:00.000-07:00</published><updated>2008-08-14T03:42:26.750-07:00</updated><title type='text'>Understanding Data Structures using STL in C++</title><content type='html'>&lt;p style="line-height: normal; font-family: trebuchet ms;" id="uttp13" class="MsoNormal"&gt; &lt;span id="y_1o"  style="font-size:100%;"&gt;What is a data structure? &lt;/span&gt;&lt;/p&gt; &lt;span id="y_1o0"  style="font-size:100%;"&gt;-&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 7pt;" id="uttp18"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span id="y_1o1"  style="font-size:100%;"&gt;It’s an abstract object that allows us to use computers efficiently. &lt;/span&gt; &lt;p style="text-indent: -18pt; line-height: normal; font-family: trebuchet ms;" id="uttp16" class="MsoNormal"&gt; &lt;/p&gt; &lt;p style="margin-left: 18pt; line-height: normal; font-family: trebuchet ms;" id="uttp21" class="MsoNormal"&gt; &lt;span id="y_1o2"  style="font-size:100%;"&gt;There are three important aspects of any data structure: &lt;/span&gt; &lt;/p&gt; &lt;p style="margin-left: 72pt; text-indent: -36pt; line-height: normal; font-family: trebuchet ms;" id="uttp24" class="MsoNormal"&gt; &lt;span id="y_1o3"  style="font-size:100%;"&gt;(i)&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 7pt;" id="uttp26"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span id="y_1o4"  style="font-size:100%;"&gt;Abstraction&lt;br /&gt; It’s actions and responses (Functional). &lt;/span&gt; &lt;/p&gt; &lt;p style="margin-left: 72pt; text-indent: -36pt; line-height: normal; font-family: trebuchet ms;" id="uttp30" class="MsoNormal"&gt; &lt;span id="y_1o5"  style="font-size:100%;"&gt;(ii)&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 7pt;" id="uttp32"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span id="y_1o6"  style="font-size:100%;"&gt;Implementation&lt;br /&gt; How it is supported by the computer (programming language + compiler). &lt;/span&gt; &lt;/p&gt; &lt;p style="margin-left: 72pt; text-indent: -36pt; line-height: normal; font-family: trebuchet ms;" id="uttp36" class="MsoNormal"&gt; &lt;span id="y_1o7"  style="font-size:100%;"&gt;(iii)&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 7pt;" id="uttp38"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span id="y_1o8"  style="font-size:100%;"&gt;Application&lt;br /&gt; Algorithms (what can be done using the abstraction). &lt;/span&gt; &lt;/p&gt; &lt;p style="line-height: normal; font-family: trebuchet ms;" id="uttp42" class="MsoNormal"&gt; &lt;span style="font-size:100%;"&gt;&lt;u id="vtzc"&gt;&lt;b id="uttp43"&gt;&lt;span id="y_1o9"&gt;Abstraction&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp52" class="MsoNormal"&gt; &lt;span id="y_1o10"  style="font-size:100%;"&gt;There were no Data Structures in assembly. Every program was coded at BIT VECTOR LEVEL(1960s) i.e everything was programmer's responsibility, but today there are embedded systems which will do most of your job with simple microprocessors(thanks to abstraction).At that time there was a basic set of operations like ADD,SHIFT,AND,OR,STORE,RECALL,LABELS,GOTO (for linear(sequential) as well as non-linear execution).&lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp55" class="MsoNormal"&gt; &lt;span id="y_1o11"  style="font-size:100%;"&gt; &lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp58" class="MsoNormal"&gt; &lt;span id="y_1o12"  style="font-size:100%;"&gt;Later on it was also discovered that, on microcoded implementations of certain architectures, complex operations tended to be &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;i id="uttp60"&gt;slower&lt;/i&gt;&lt;/span&gt;&lt;span id="y_1o13"  style="font-size:100%;"&gt; than a sequence of simpler operations doing the same thing. &lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp62" class="MsoNormal"&gt; &lt;span id="y_1o14"  style="font-size:100%;"&gt;This gave rise to Reduces Instruction Set Computer (RISC Philosophy) &lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp65" class="MsoNormal"&gt; &lt;span id="y_1o15"  style="font-size:100%;"&gt;Links:&lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp68" class="MsoNormal"&gt; &lt;span style="font-size:100%;"&gt;&lt;a title="http://en.wikipedia.org/wiki/RISC" id="a-vv" href="http://en.wikipedia.org/wiki/RISC"&gt;http://en.wikipedia.org/wiki/RISC&lt;/a&gt;&lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp71" class="MsoNormal"&gt; &lt;span style="font-size:100%;"&gt;&lt;a title="RISC Vs CISC" id="uttp72" href="http://cse.stanford.edu/class/sophomore-college/projects-00/risc/risccisc/"&gt;&lt;span id="y_1o16"&gt;RISC Vs CISC&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span id="y_1o17"  style="font-size:100%;"&gt; : &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;a title="http://cse.stanford.edu/class/sophomore-college/projects-00/risc/risccisc/" id="tt8q" href="http://cse.stanford.edu/class/sophomore-college/projects-00/risc/risccisc/"&gt;http://cse.stanford.edu/class/sophomore-college/projects-00/risc/risccisc/&lt;/a&gt;&lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp76" class="MsoNormal"&gt; &lt;span id="y_1o18"  style="font-size:100%;"&gt; &lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp79" class="MsoNormal"&gt; &lt;span style="font-size:100%;"&gt;&lt;u id="pyb9"&gt;&lt;b id="pyb90"&gt;&lt;span id="y_1o19"&gt;Data types in C++ (available abstraction) &lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp82" class="MsoNormal"&gt; &lt;span id="y_1o20"  style="font-size:100%;"&gt; &lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp85" class="MsoNormal"&gt; &lt;span style="font-size:100%;"&gt;&lt;u id="d1rp"&gt;&lt;b id="d1rp0"&gt;&lt;span id="y_1o21"&gt;Basic/Primitives&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/span&gt; &lt;/p&gt; &lt;ul id="uttp88" style="font-family: trebuchet ms;" type="disc"&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp89" class="MsoNormal"&gt;     &lt;p id="j-3a8"&gt; &lt;span id="y_1o22"  style="font-size:100%;"&gt;Int &lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp92" class="MsoNormal"&gt;     &lt;p id="j-3a9"&gt; &lt;span id="y_1o23"  style="font-size:100%;"&gt;Float- for abstracting real numbers &lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp95" class="MsoNormal"&gt;     &lt;p id="j-3a10"&gt; &lt;span id="y_1o24"  style="font-size:100%;"&gt;Char - ASCII encoding (8 bits with first bit 0 -- 127 characters) and it's indian version ISCII&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp98" class="MsoNormal"&gt;     &lt;p id="j-3a11"&gt; &lt;span id="y_1o25"  style="font-size:100%;"&gt;Bool &lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp101" class="MsoNormal"&gt; &lt;span style="font-size:100%;"&gt;&lt;u id="jtzt"&gt;&lt;span id="y_1o26"&gt;&lt;b id="jtzt0"&gt;Complex&lt;/b&gt; &lt;/span&gt;&lt;/u&gt;&lt;/span&gt; &lt;/p&gt; &lt;ul id="uttp104" style="font-family: trebuchet ms;" type="disc"&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp105" class="MsoNormal"&gt;     &lt;p id="j-3a12"&gt; &lt;span id="y_1o27"  style="font-size:100%;"&gt;Linear- Like Arrays etc.&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp108" class="MsoNormal"&gt;     &lt;p id="j-3a13"&gt; &lt;span id="y_1o28"  style="font-size:100%;"&gt;Non-linear – Complex abstracted storage mechanism (like sets etc.)&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="jtzt2" class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;u id="jtzt3"&gt;&lt;b id="jtzt4"&gt;&lt;span id="jtzt5"&gt;Standard Template Librar&lt;/span&gt;&lt;/b&gt;&lt;span id="y_1o30"&gt;y&lt;/span&gt;&lt;/u&gt;&lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="cswo0" class="MsoNormal"&gt; &lt;span style="font-size:100%;"&gt;&lt;b id="dj.r"&gt;&lt;span id="y_1o31"&gt; Provides :&lt;/span&gt;&lt;/b&gt;&lt;/span&gt; &lt;/p&gt; &lt;ul id="uttp119" style="font-family: trebuchet ms;" type="disc"&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp120" class="MsoNormal"&gt;     &lt;p id="j-3a14"&gt; &lt;span id="y_1o32"  style="font-size:100%;"&gt;CONTAINERS -- used to store things i.e. act as template for any type.e.g. Vectors, Queues, Stack, List, Sets, Maps .&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp123" class="MsoNormal"&gt;     &lt;p id="j-3a15"&gt; &lt;span id="y_1o33"  style="font-size:100%;"&gt;ALGORITHMS &lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp126" class="MsoNormal"&gt;     &lt;p id="j-3a16"&gt; &lt;span id="y_1o34"  style="font-size:100%;"&gt;ITERATORS (like pointers)&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="q2t.0" class="MsoNormal"&gt; &lt;span id="y_1o35"  style="font-size:100%;"&gt; STL CONTAINERS &lt;/span&gt; &lt;/p&gt; &lt;p style="margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp132" class="MsoNormal"&gt; &lt;span id="y_1o36"  style="font-size:100%;"&gt; For details regarding syntax and &lt;/span&gt;&lt;span id="y_1o36"  style="font-size:100%;"&gt;usage go to &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;a id="uttp134" href="http://www.cppreference.com/"&gt;&lt;span id="y_1o37"&gt;http://www.cppreference.com/&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; &lt;/p&gt; &lt;ul id="uttp138" style="font-family: trebuchet ms;" type="disc"&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp139" class="MsoNormal"&gt;     &lt;p id="j-3a17"&gt; &lt;span id="y_1o38"  style="font-size:100%;"&gt;Vectors&lt;br /&gt; Similar to array in the sense of storage of data (providing linear access). But there is a big difference: length of array once fixed cannot be changed but a vector has no fixed length (obv bounded by memory limit) i.e a vector can be considered as a dynamic array.&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp143" class="MsoNormal"&gt;     &lt;p id="j-3a18"&gt; &lt;span id="y_1o39"  style="font-size:100%;"&gt;Stack and Queue&lt;br /&gt; both allow the operations push(add) and pop(remove) but the behaviours are different.&lt;br /&gt; A Stack is a data structure based on LIFO(Last-In-First-Out) whereas a Queue is based on FIFO(First-In-First-Out).&lt;br /&gt; Read more about it here &lt;a id="gw9m" href="http://www.helium.com/items/1057009-understanding-the-difference-between-fifo-and-lifo" title="http://www.helium.com/items/1057009-understanding-the-difference-between-fifo-and-lifo"&gt;http://www.helium.com/items/1057009-understanding-the-difference-between-fifo-and-lifo&lt;/a&gt; &lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp149" class="MsoNormal"&gt;     &lt;p id="j-3a19"&gt; &lt;span id="y_1o40"  style="font-size:100%;"&gt;List&lt;br /&gt; Lists are sequences of elements stored in a linked list. Compared to vectors, they allow fast insertions and deletions, but slower random access.&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li style="margin-bottom: 0.0001pt; line-height: normal;" id="uttp153" class="MsoNormal"&gt;     &lt;p id="j-3a20"&gt; &lt;span id="y_1o41"  style="font-size:100%;"&gt;And many more (not discussed here, you can find good references here : &lt;a id="w86d" href="http://publib.boulder.ibm.com/infocenter/comphelp/v9v111/index.jsp?topic=/com.ibm.xlcpp9.aix.doc/standlib/containers.htm" title="http://publib.boulder.ibm.com/infocenter/comphelp/v9v111/index.jsp?topic=/com.ibm.xlcpp9.aix.doc/standlib/containers.htm"&gt;http://publib.boulder.ibm.com/infocenter/comphelp/v9v111/index.jsp?topic=/com.ibm.xlcpp9.aix.doc/standlib/containers.htm&lt;/a&gt; )&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p style="margin-left: 18pt; margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="q2t.3" class="MsoNormal"&gt; &lt;span style="font-size:100%;"&gt;&lt;b id="c.4_"&gt;&lt;span id="y_1o42"&gt;Why so many Containers?&lt;/span&gt;&lt;/b&gt;&lt;/span&gt; &lt;/p&gt; &lt;p style="margin-left: 18pt; margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp159" class="MsoNormal"&gt; &lt;span style="font-size:100%;"&gt;&lt;b id="uttp160"&gt;&lt;span id="y_1o43"&gt;Answer:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span id="y_1o44"  style="font-size:100%;"&gt; because their performance is different in different situations i.e. some are optimized to do well in some particular situations e.g. vectors are fast for random access but too slow in insertions whereas a list supports fast insertion and deletion but slow random access.&lt;/span&gt; &lt;/p&gt; &lt;p style="margin-left: 18pt; margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="g_2p0" class="MsoNormal"&gt; &lt;span id="g_2p1"  style="font-size:100%;"&gt;ALGORITHMS&lt;/span&gt; &lt;/p&gt; &lt;p style="margin-left: 18pt; margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp167" class="MsoNormal"&gt; &lt;span id="y_1o46"  style="font-size:100%;"&gt;We assume that some basic operations are already present on the template data-type like &lt;,== etc. predefined algorithms in STL work fine with these containers and what they contain within themselves.&lt;/span&gt; &lt;/p&gt; &lt;p style="margin-left: 18pt; margin-bottom: 0.0001pt; line-height: normal; font-family: trebuchet ms;" id="uttp170" class="MsoNormal"&gt; &lt;span id="y_1o47"  style="font-size:100%;"&gt;There are many algorithms available in STL. Like binary_search, sort, max_element, sort_heap etc. They need specialised pointers (called ITERATORS) for access to each element sequentially.&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4922233653576692316-637067741496342736?l=simplenstraight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://simplenstraight.blogspot.com/feeds/637067741496342736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4922233653576692316&amp;postID=637067741496342736' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4922233653576692316/posts/default/637067741496342736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4922233653576692316/posts/default/637067741496342736'/><link rel='alternate' type='text/html' href='http://simplenstraight.blogspot.com/2008/08/understanding-data-structures-using-stl.html' title='Understanding Data Structures using STL in C++'/><author><name>Chirag Sethi</name><uri>http://www.blogger.com/profile/16510329321349750614</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
