Anna CS 3301 - Introduction to Data Structure

Unformatted text preview:

Introductiontodatastructure Adatastructureisawayoforganizing storing and manipulatingdatainacomputerprogram sothatitcanbeused efficiently Itprovidesameanstorepresentdatainaparticular wayandtoperform variousoperationsonthatdata Datastructurescanbeclassifiedintotwotypes primitivedata structuresandnon primitivedatastructures Primitivedata structuresarebasicdatatypesthatarebuiltintoprogramming languages suchasintegers floats characters andbooleans Non primitivedatastructuresaremorecomplexandinclude arrays linkedlists stacks queues trees graphs andhashtables Thechoiceofadatastructuredependsonthespecific requirementsoftheprogram suchasthetypeofdatatobe stored thesizeofthedataset thefrequencyofaccessand modification andtheoperationsthatneedtobeperformedonthe data Eachdatastructurehasitsadvantagesanddisadvantages intermsofmemoryusage timecomplexity andeaseof implementation Usinganappropriatedatastructurecanleadtosignificant improvementsintheperformanceandefficiencyofaprogram makingitpossibletohandlelargerdatasetsandperform more complexoperations Therefore understandingdatastructures andtheirapplicationsisessentialforanycomputerprogrammer orsoftwaredeveloper Importanttopicindatastructures Thereareseveralimportanttopicsinthebasicsofdatastructures including Arrays Arraysareabasicdatastructurethatstorea collectionofelementsofthesamedatatypeincontiguous memorylocations LinkedLists Asmentionedbefore alinkedlistisalinear data structurethatconsistsofasequenceofnodes where eachnodestoresavalueandareferencetothenextnodein thesequence Stacks Astackisalineardatastructurethatfollowsthe Last In First Out LIFO principle Ithastwomainoperations pushandpop whichaddandremoveelementsfrom thetop ofthestack respectively Queues Aqueueisalineardatastructurethatfollowsthe First In First Out FIFO principle Ithastwomainoperations enqueueanddequeue whichaddandremoveelementsfrom thefrontandrearofthequeue respectively Trees Treesareanon lineardatastructurethatconsistsof nodesconnectedbyedges Eachnodehasaparentandzero ormorechildren andthetopmostnodeiscalledtheroot Graphs Graphsareanon lineardatastructurethatconsists ofasetofvertices nodes andasetofedgesconnecting them Theycanbedirectedorundirectedandcanbeusedto modelcomplexrelationshipsbetweenentities HashTables Hashtablesareadatastructurethatusesa hashfunctiontomapkeystoindicesinanarray allowingfor constant timeaccessandinsertionofkey valuepairs SearchingandSortingAlgorithms Algorithmssuchaslinear search binarysearch bubblesort mergesort andquicksort arefundamentaltoworkingwithdatastructuresandare essentialtounderstandinghowtomanipulateandorganize dataefficiently Array Anarrayisafundamentaldatastructureincomputer programmingthatisusedtostoreafixed size contiguousblock ofelementsofthesamedatatype Theelementsofanarrayare storedinasequence whichcanbeaccessedusinganindexora subscript Arrayscanbeone dimensionalormulti dimensional dependingonthenumberofindicesrequiredtoaccessan element Aone dimensionalarrayisessentiallyalistofelements whileatwo dimensionalarrayislikeatableorgrid withrowsand columns Themainadvantageofarraysisthattheyallowforefficient accesstoindividualelementsbasedontheirindex Thisis becausethememorylocationsoftheelementsinanarrayare contiguous andtheindexofanelementisusedtocalculateits memoryaddress Arraysarealsousefulforperformingvariousoperationson datasets suchassorting searching andmanipulating However arrayshavesomelimitations suchastheirfixedsize which cannotbechangedoncetheyarecreated Thismeansthatifthe sizeofanarrayneedstobeincreasedordecreased anewarray mustbecreatedandtheelementsmustbecopiedover Anotherlimitationofarraysisthattheyarenotdynamic meaningthattheirsizemustbedeterminedatcompile time This canbeaproblem whendealingwithdatasetsofunknownsizeor whenthesizeofthedatasetchangesovertime Insummary arraysareasimpleandefficientdatastructure forstoringandmanipulatingfixed sizedatasets buttheyarenot suitablefordynamicdatasetsordatasetsofunknownsize Linkedlist Alinkedlistisalineardatastructurethatconsistsofa sequenceofnodes whereeachnodestoresavalueanda reference orpointer tothenextnodeinthesequence Thefirst nodeiscalledtheheadofthelist andthelastnodeiscalledthe tail Thetailnodehasareferencetonull indicatingtheendofthe list Linkedlistsareusefulwhenthesizeofthedatasetisnot knowninadvance orwhenthedatasetneedstobedynamically modifiedduringprogram execution Linkedlistsallowforefficient insertionanddeletionoperationsatanypositioninthelist unlike arrays whichrequireshiftingelementswheninsertingordeleting elements Linkedlistscanbesinglylinkedordoublylinked Inasingly linkedlist eachnodehasareferencetothenextnodeinthe sequence Inadoublylinkedlist eachnodehasreferencesto boththenextandpreviousnodesinthesequence allowingfor efficienttraversalinbothdirections Themainadvantageoflinkedlistsistheirflexibilityinterms ofsizeanddynamicmodification Theycanbeeasilyresized and elementscanbeaddedorremovedwithoutshiftingother elements Linkedlistsarealsousefulforimplementingotherdata structures suchasstacks queues andassociativearrays However linkedlistshavesomedisadvantagesaswell They havesloweraccesstimesthanarraysforrandom access aseach elementmustbeaccessedsequentiallybyfollowingthe referencesfrom onenodetothenext Theyalsorequiremore memoryoverheadthanarrays aseachnodecontainsareference tothenextnode Insummary linkedlistsareaflexibleandefficientdata structureforstoringandmanipulatingdynamicdatasets butthey havesloweraccesstimesthanarraysforrandom accessand requiremorememoryoverhead Stack Astackisalineardatastructureincomputersciencethat representsacollectionofelementswhereelementscanbe insertedandremovedonlyfrom oneend calledthetopofthe stack Thelastelementinsertedintothestackisthefirstelement toberemoved last in first out LIFO Stacksareimplementedusingasimplearrayoralinkedlist Themainoperationsperformedonastackarepushandpop Pushaddsanelementtothetopofthestack andpopremoves theelementfrom thetopofthestack Stacksarewidelyusedinmanycomputerscience applications suchasexpressionevaluation functioncall management undo redooperations anddepth firstsearchina graph Theyarealsousedincompilerstostoreinformationabout theprogram scontrolflow suchasthereturnaddressesof functioncalls Theimplementationofastackusinganarrayissimpleand efficient However ithasafixedsize anditmaycausestack overflowerrorsifthesizeisexceeded Therefore stacks implementedusingalinkedlistcanberesizeddynamically Someotherimportantoperationsthatcanbeperformedon stacksincludepeek


View Full Document

Anna CS 3301 - Introduction to Data Structure

Download Introduction to Data Structure
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to Data Structure and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to Data Structure 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?