Академический Документы
Профессиональный Документы
Культура Документы
NPTELIITGuwahati
IntroductiontoDataStructure
Printthispage
INTRODUCTION
It is important for every Computer Science student to understand the concept of Information and how it is
organizedorhowitcanbeutilized.
WhatisInformation?
Ifwearrangesomedatainanappropriatesequence,thenitformsaStructureandgivesusameaning.This
meaningiscalledInformation.ThebasicunitofInformationinComputerScienceisabit,BinaryDigit.
So,wefoundtwothingsinInformation:OneisDataandtheotherisStructure.
WhatisDataStructure?
1. Adatastructureisasystematicwayoforganizingandaccessingdata.
2. Adatastructuretriestostructuredata!
Usuallymorethanonepieceofdata
Shoulddefinelegaloperationsonthedata
Thedatamightbegroupedtogether(e.g.inanlinkedlist)
3. Whenwedefineadatastructureweareinfactcreatinganewdatatypeofourown.
i.e.usingpredefinedtypesorpreviouslyuserdefinedtypes.
Suchnewtypesarethenusedtoreferencevariablestypewithinaprogram
Start
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Printthispage
WhyDataStructures?
1. Datastructuresstudyhowdataarestoredinacomputersothatoperationscanbeimplementedefficiently
2. Datastructuresareespeciallyimportantwhenyouhavealargeamountofinformation
3. Conceptualandconcretewaystoorganizedataforefficientstorageandmanipulation.
MethodsofInterpretingbitSetting
1. BinaryNumberSystem
NonNegative
Negative
OnesComplementNotation
TwosComplementNotation
2. BinaryCodedDecimal
3. RealNumber
4. CharacterString
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Printthispage
NonNegativeBinarySystem
InthisSystemeachbitpositionrepresentsapowerof2.Therightmostbitpositionrepresent20whichequals1.
Thenextpositiontotheleftrepresents21=2andsoon.AnIntegerisrepresentedasasumofpowersof2.A
stringofall0srepresentsthenumber0.Ifa1appearsinaparticularbitposition,thepowerof2representedby
thatbitpositionisincludedintheSum.Butifa0appears,thepowerof2isnotincludedintheSum.Forexample
10011,thesumis
OnesComplementNotation
NegativebinarynumberisrepresentedbyonesComplementNotation.Inthisnotationwerepresentanegative
number by changing each bit in its absolute value to the opposite bit setting. For example, since 001001100
represent38,11011001isusedtorepresent38.Theleftmostnumberisreservedforthesignofthenumber.A
bit String Starting with a 0 represents a positive number, where a bit string starting with a 1 represents a
negativenumber.
TwosComplementNotation
In Twos Complement Notation is also used to represent a negative number. In this notation 1 is added to the
Ones Complement Notation of a negative number. For example, since 11011001 represents 38 in Ones
ComplementNotation11011010usedrepresent38inTwosComplementNotation.
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Printthispage
BinaryCodedDecimal
InthisSystemastringofbitsmaybeusedtorepresentintegersintheDecimalNumberSystem.Fourbitscanbe
usedtorepresentaDecimaldigitbetween0and9inthebinarynotation.Astringofbitsofarbitrarylengthmaybe
dividedintoconsecutivesetsoffourbits.Witheachsetrepresentingadecimaldigit.Thestringthenrepresentsthe
numberthatisformedbythosedecimaldigitsinconventionaldecimalnotation.Forexample,inthissystemthebit
string00110101isseparatedintotwostringsoffourbitseach:0011and0101.Thefirstoftheserepresentsthe
decimaldigit3andthesecondrepresentsthedecimal5,sothattheentirestringrepresentstheinteger35.
Inthebinarycodeddecimalsystemweuse4bits,sothisfourbitsrepresentsixteenpossiblestates.Butonly10of
thosesixteenpossibilitiesareused.Thatmeans,whosebinaryvaluesare10orlarger,areinvalidinBinaryCoded
DecimalSystem.
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Printthispage
RealNumber
TheFloatingPointNotationusetorepresentRealNumbers.ThekeyconceptoffloatingpointnotationisMantissa,
BaseandExponent.ThebaseisusuallyfixedandtheMantissaandtheExponentvarytorepresentdifferentReal
Number.ForExample,ifthebaseisfixedat10,thenumber235.47couldberepresentedas
.The
Mantissais23547andtheexponentis2.Otherpossiblerepresentationsare
and
.
In the floatingpoint notation a real number is represented by a 32bit string. Including in 32bit, 24bit use for
representation of Mantissa and remaining 8bit use for representation of Exponent .Both the mantissa and the
exponentaretwoscomplementbinaryIntegers.Forexample,the24bittwoscomplementbinaryrepresentationof
23547is111111111010010000000101,andthe8bittwoscomplementbinaryrepresentationof2is11111110.
Sotherepresentationof235.47is11111111101001000000010111111110.Itcanbeusedtorepresentextremely
largeorextremelysmallabsolutevalues.
CharacterStrings
Incomputerscience,informationisnotalwaysinterpretednumerically.Itemsuchasnames,addressandjobtitle
must also be represented in some fashion with in computer. To enable the representation of such nonnumeric
objects, still another method of interpreting bit strings is necessary. Such information is usually represented in
characterstringform.Forexample,insomecomputers,theeightbits11000000isusedtorepresentthecharacter
"A" and 11000001 for character "B" and another for each character that has a representation in a particular
machine.So,thecharacterstring"AB"wouldberepresentedbythebitstring1100000011000001.
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Printthispage
Theassignmentofbitstringtocharactermaybeentirelyarbitrary,butitmustbeadheredtoconsistently.Itmay
bethatsomeconvenientruleisusedinassigningbitstringtocharacter.Thenumberofbitsvariescomputerwise
usedtorepresentacharacter.
Some computers are use 7bit (therefore allow up to 128 possible characters), some computers are use 8bits
(upto256character),andsomeuse10bits(upto1024possiblecharacters).Thenumberofbitsnecessaryto
representacharacterinaparticularcomputeriscalledthebytesizeandagroupofbitsthatnumberiscalleda
byte.
Array
Incomputerprogramming,agroupofhomogeneouselementsofaspecificdatatypeisknownasanarray,one
of the simplest data structures. Arrays hold a series of data elements, usually of the same size and data type.
Individualelementsareaccessedbytheirpositioninthearray.Thepositionisgivenbyanindex,whichisalso
calledasubscript.Theindexusuallyusesaconsecutiverangeofintegers,(asopposedtoanassociativearray)
buttheindexcanhaveanyordinalsetofvalues.
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Printthispage
Somearraysaremultidimensional,meaningtheyareindexedbyafixednumberofintegers,forexamplebya
tuple of four integers. Generally, one and twodimensional arrays are the most common. Most programming
languageshaveabuiltinarraydatatype.
LinkList
Incomputerscience,alinkedlistisoneofthefundamentaldatastructuresusedincomputerprogramming.It
consists of a sequence of nodes, each containing arbitrary data fields and one or two references ("links")
pointingtothenextand/orpreviousnodes.Alinkedlistisaselfreferentialdatatypebecauseitcontainsalink
toanotherdataofthesametype.Linkedlistspermitinsertionandremovalofnodesatanypointinthelistin
constanttime,butdonotallowrandomaccess.
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Printthispage
TypesofLinkList
1. LinearlylinkedList
Singlylinkedlist
Doublylinkedlist
2. Circularlylinkedlist
Singlycircularlylinkedlist
Doublycircularlylinkedlist
3. Sentinelnodes
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Stack
Printthispage
AstackisalinearStructureinwhichitemmaybeaddedorremovedonlyatoneend.Therearecertainfrequent
situationsincomputersciencewhenonewantstorestrictinsertionsanddeletionssothattheycantakeplaceonly
atthebeginningortheendoftheendofthelist,notinthemiddle.TwooftheDataStructuresthatareusefulin
such situations are Stacksand queues. A stack is a list of elements in which an elements may be inserted or
deletedonlyatoneend,calledtheTop.Thismeans,inparticular,theelementsareremovedfromastackinthe
reverseorderofthatwhichtheyareinsertedintothestack.Thestackalsocalled"lastinfirstout(LIFO)"list.
Specialterminologyisusedfortwobasicoperationassociatedwithstack
:
1. "Push"isthetermusedtoinsertanelementintoastack.
2. "Pop"isthetermusedtodeleteanelementfromastack.
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Queue
Printthispage
A queue is a linear list of elements in which deletions can take place only at one end, called the " front " and
insertioncantakeplaceonlyattheotherend,called"rear".Theterm"front"and"rear"areusedindescribing
alinearlistonlywhenitisimplementedasaqueue.
Queuesarealsocalled"firstinfirstout"(FIFO)list.Sincethefirstelementinaqueuewillbethefirstelementout
ofthequeue.Inotherwords,theorderinwhichelementsenterinaqueueistheorderinwhichtheyleave.The
reallifeexample:thepeoplewaitinginalineatRailwayticketCounterformaqueue,wherethefirstpersonina
lineisthefirstpersontobewaitedon.Animportantexampleofaqueueincomputerscienceoccursintimesharing
system,inwhichprogramswiththesamepriorityformaqueuewhilewaitingtobeexecuted.
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Tree
Printthispage
Datafrequentlycontainahierarchicalrelationshipbetweenvariouselements.ThisnonlinearDatastructurewhich
reflectsthisrelationshipiscalledarootedtreegraphor,tree.
This structure is mainly used to represent data containing a hierarchical relationship between elements, e.g.
record,familytreeandtableofcontents.
Atreeconsistofadistinguishednoder,calledtherootandzeroormore(sub)treet1,t2,...tn,eachofwhose
rootsareconnectedbyadirectededgetor.
Inthetreeoffigure,therootisA,Nodet2hasrasaparentandt2.1,t2.2andt2.3aschildren.Eachnodemay
havearbitrarynumberofchildren,possiblyzero.Nodeswithnochildrenareknownasleaves.
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Graph
Printthispage
Agraphconsistsofasetofnodes(orVertices)andasetofarc(oredge).Eacharcinagraphisspecifiedbya
pair of nodes. A node n is incidentto an arc x if n is one of the two nodes in the ordered pair of nodes that
constitutex.Thedegreeofanodeisthenumberofarcsincidenttoit.Theindegreeofanodenisthenumber
ofarcsthathavenasthehead,andtheoutdegreeofnisthenumberofarcsthathavenasthetail.
Thegraphisthenonlineardatastructure.Thegraphshowninthefigurerepresents7verticesand12edges.
TheVerticesare{1,2,3,4,5,6,7}andthearcsare{(1,2),(1,3),(1,4),(2,4),(2,5),(3,4),(3,6),(4,5),(4,6),
(4,7),(5,7),(6,7)}.Node(4)infigurehasindegree3,outdegree3anddegree6.
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1
03/01/2016
NPTELIITGuwahati
IntroductiontoDataStructure
Printthispage
AbstractDataType
1. AbstractDataTypes(ADT's)areamodelusedtounderstandthedesignofadatastructure
2. 'Abstract'impliesthatwegiveanimplementationindependentviewofthedatastructure
3. ADTsspecifythetypeofdatastoredandtheoperationsthatsupportthedata
4. ViewingadatastructureasanADTallowsaprogrammertofocusonanidealizedmodelofthedataandits
operations
Prev
http://nptel.ac.in/courses/Webcoursecontents/IIT%20Guwahati/data_str_algo/frameset.htm
First|Next|Last
1/1