Top Banner
Data Structures Topics: Linked List Stack Queue Binary Tree Binary Search Tree Heap Hashing Graph Advanced Data Structure Array Matrix Misc Linked List: Singly Linked List: Introduction to Linked List Linked List vs Array Linked List Insertion Linked List Deletion A Programmer’s approach of looking at Array vs. Linked List Find Length of a Linked List (Iterative and Recursive) Search an element in a Linked List (Iterative and Recursive) How to write C functions that modify head pointer of a Linked List? Write a function to get Nth node in a Linked List Given only a pointer to a node to be deleted in a singly linked list, how do you delete it? Print the middle of a given linked list Nth node from the end of a Linked List
20

Data Structures - GeeksforGeeks

Sep 13, 2015

Download

Documents

Priyanka Yadav

dwd
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1em 1/20

    DataStructuresTopics:

    LinkedListStackQueueBinaryTreeBinarySearchTreeHeapHashingGraphAdvancedDataStructureArrayMatrixMisc

    LinkedList:

    SinglyLinkedList:

    IntroductiontoLinkedListLinkedListvsArrayLinkedListInsertionLinkedListDeletionAProgrammersapproachoflookingatArrayvs.LinkedListFindLengthofaLinkedList(IterativeandRecursive)SearchanelementinaLinkedList(IterativeandRecursive)HowtowriteCfunctionsthatmodifyheadpointerofaLinkedList?WriteafunctiontogetNthnodeinaLinkedListGivenonlyapointertoanodetobedeletedinasinglylinkedlist,howdoyoudeleteit?PrintthemiddleofagivenlinkedlistNthnodefromtheendofaLinkedList

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1em 2/20

    WriteafunctiontodeleteaLinkedListWriteafunctionthatcountsthenumberoftimesagivenintoccursinaLinkedListReversealinkedlistDetectloopinalinkedlistFunctiontocheckifasinglylinkedlistispalindromeGivenalinkedlistwhichissorted,howwillyouinsertinsortedwayIntersectionpointoftwoLinkedLists.RecursivefunctiontoprintreverseofaLinkedListRemoveduplicatesfromasortedlinkedlistRemoveduplicatesfromanunsortedlinkedlistPairwiseswapelementsofagivenlinkedlistPracticequestionsforLinkedListandRecursionMovelastelementtofrontofagivenLinkedListIntersectionoftwoSortedLinkedListsDeletealternatenodesofaLinkedListAlternatingsplitofagivenSinglyLinkedListMergetwosortedlinkedlistsIdenticalLinkedListsMergeSortforLinkedListsReverseaLinkedListingroupsofgivensizeReversealternateKnodesinaSinglyLinkedListDeletenodeswhichhaveagreatervalueonrightsideSegregateevenandoddnodesinaLinkedListDetectandRemoveLoopinaLinkedListAddtwonumbersrepresentedbylinkedlists|Set1DeleteagivennodeinLinkedListundergivenconstraintsUnionandIntersectionoftwoLinkedListsFindatripletfromthreelinkedlistswithsumequaltoagivennumberRotateaLinkedListFlatteningaLinkedListAddtwonumbersrepresentedbylinkedlists|Set2

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1em 3/20

    Sortalinkedlistof0s,1sand2sFlattenamultilevellinkedlistDeleteNnodesafterMnodesofalinkedlistQuickSortonSinglyLinkedListMergealinkedlistintoanotherlinkedlistatalternatepositionsPairwiseswapelementsofagivenlinkedlistbychanginglinksGivenalinkedlistoflinesegments,removemiddlepointsConstructaMaximumSumLinkedListoutoftwoSortedLinkedListshavingsomeCommonnodesCanwereversealinkedlistinlessthanO(n)?Clonealinkedlistwithnextandrandompointer|Set2InsertionSortforSinglyLinkedListPointtonexthighervaluenodeinalinkedlistwithanarbitrarypointer

    CircularLinkedList:

    CircularLinkedListIntroductionandApplications,CircularLinkedListTraversalSplitaCircularLinkedListintotwohalvesSortedinsertforcircularlinkedlist

    DoublyLinkedList:

    DoublyLinkedListIntroductionandInsertionDeleteanodeinaDoublyLinkedListReverseaDoublyLinkedListTheGreatTreeListRecursionProblem.CopyalinkedlistwithnextandarbitpointerQuickSortonDoublyLinkedListSwapKthnodefrombeginningwithKthnodefromendinaLinkedList

    QuizonLinkedList

    Stack:

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1em 4/20

    IntroductiontoStackInfixtoPostfixConversionusingStackEvaluationofPostfixExpressionReverseaStingusingStackImplementtwostacksinanarrayCheckforbalancedparenthesesinanexpressionNextGreaterElementReverseastackusingrecursionTheStockSpanProblemDesignandImplementSpecialStackDataStructureImplementStackusingQueuesDesignastackwithoperationsonmiddleelementHowtocreatemergablestack?Howtoefficientlyimplementkstacksinasinglearray?IterativeTowerofHanoi

    QuizonStack

    Queue:

    QueueIntroductionandArrayImplementationLinkedListImplementationofQueueApplicationsofQueueDataStructurePriorityQueueIntroductionDeque(IntroductionandApplications)ImplementQueueusingStacksCheckwhetheragivenBinaryTreeisCompleteornotFindthelargestmultipleof3FindthefirstcirculartourthatvisitsallpetrolpumpsMaximumofallsubarraysofsizekAnInterestingMethodtoGenerateBinaryNumbersfrom1tonHowtoefficientlyimplementkQueuesinasinglearray?

    QuizonQueue

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1em 5/20

    BinaryTree:

    BinaryTreeIntroductionHandshakingLemmaandInterestingTreePropertiesBinaryTreePropertiesTypesofBinaryTreeApplicationsoftreedatastructureTreeTraversalsThreadedBinaryTreeSizeofatreeDetermineifTwoTreesareIdenticalMaximumDepthorHeightofaTreeWriteaCprogramtoDeleteaTree.WriteanEfficientCFunctiontoConvertaBinaryTreeintoitsMirrorTreeIfyouaregiventwotraversalsequences,canyouconstructthebinarytree?Givenabinarytree,printoutallofitsroottoleafpathsoneperline.TheGreatTreeListRecursionProblem.LevelOrderTreeTraversalCountleafnodesinabinarytreeLevelordertraversalinspiralformCheckforChildrenSumPropertyinaBinaryTree.ConvertanarbitraryBinaryTreetoatreethatholdsChildrenSumPropertyDiameterofaBinaryTreeHowtodetermineifabinarytreeisheightbalanced?InorderTreeTraversalwithoutRecursionInorderTreeTraversalwithoutrecursionandwithoutstack!RoottoleafpathsumequaltoagivennumberConstructTreefromgivenInorderandPreordertraversalsGivenabinarytree,printallroottoleafpathsDoubleTreeMaximumwidthofabinarytree

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1em 6/20

    FoldableBinaryTreesPrintnodesatkdistancefromrootGetLevelofanodeinaBinaryTreePrintAncestorsofagivennodeinBinaryTreeCheckifagivenBinaryTreeisSumTreeCheckifabinarytreeissubtreeofanotherbinarytreeConnectnodesatsamelevelConnectnodesatsamelevelusingconstantextraspacePopulateInorderSuccessorforallnodesConvertagiventreetoitsSumTreeVerticalSuminagivenBinaryTreeFindthemaximumsumleaftorootpathinaBinaryTreeConstructSpecialBinaryTreefromgivenInordertraversalConstructaspecialtreefromgivenpreordertraversalCheckwhetheragivenBinaryTreeisCompleteornotBoundaryTraversalofbinarytreeConstructFullBinaryTreefromgivenpreorderandpostordertraversalsIterativePreorderTraversalMorristraversalforPreorderLinkedcompletebinarytree&itscreationTernarySearchTreeSegmentTree|Set1(Sumofgivenrange)LargestIndependentSetProblemIterativePostorderTraversal|Set1(UsingTwoStacks)IterativePostorderTraversal|Set2(UsingOneStack)ReverseLevelOrderTraversalConstructCompleteBinaryTreefromitsLinkedListRepresentationConvertagivenBinaryTreetoDoublyLinkedList|Set1TreeIsomorphismProblemFindallpossibleinterpretationsofanarrayofdigitsIterativeMethodtofindHeightofBinaryTreeCustomTreeProblem

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1em 7/20

    ConvertagivenBinaryTreetoDoublyLinkedList|Set2PrintancestorsofagivenbinarytreenodewithoutrecursionDifferencebetweensumsofoddlevelandevenlevelnodesofaBinaryTreePrintPostordertraversalfromgivenInorderandPreordertraversalsFinddepthofthedeepestoddlevelleafnodeCheckifallleavesareatsamelevelPrintLeftViewofaBinaryTreeRemoveallnodeswhichdontlieinanypathwithsum>=kExtractLeavesofaBinaryTreeinaDoublyLinkedListDeepestleftleafnodeinabinarytreeFindnextrightnodeofagivenkeySumofallthenumbersthatareformedfromroottoleafpathsConvertagivenBinaryTreetoDoublyLinkedList|Set3LowestCommonAncestorinaBinaryTree|Set1FinddistancebetweentwogivenkeysofaBinaryTreePrintallnodesthatareatdistancekfromaleafnodeCheckifagivenBinaryTreeisheightbalancedlikeaRedBlackTree,PrintallnodesatdistancekfromagivennodePrintaBinaryTreeinVerticalOrder|Set1ConstructatreefromInorderandLevelordertraversalsFindthemaximumpathsumbetweentwoleavesofabinarytreeReversealternatelevelsofaperfectbinarytreeCheckiftwonodesarecousinsinaBinaryTreeCheckifabinarytreeissubtreeofanotherbinarytree|Set2SerializeandDeserializeaBinaryTreePrintnodesbetweentwogivenlevelnumbersofabinarytreeclosestleafinaBinaryTreeConvertaBinaryTreetoThreadedbinarytreePrintNodesinTopViewofBinaryTreeBottomViewofaBinaryTreePerfectBinaryTreeSpecificLevelOrderTraversal

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1em 8/20

    ConvertleftrightrepresentationofabianrytreetodownrightPrintlevelordertraversallinebylineMinimumno.ofiterationstopassinformationtoallnodesinthetreeCloneaBinaryTreewithRandomPointersGivenabinarytree,howdoyouremoveallthehalfnodes?VertexCoverProblem|Set2(DynamicProgrammingSolutionforTree)CheckwhetherabinarytreeisafullbinarytreeornotFindsumofallleftleavesinagivenBinaryTreeRemovenodesonroottoleafpathsoflength

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1em 9/20

    RemoveBSTkeysoutsidethegivenrangeCheckifeachinternalnodeofaBSThasexactlyonechildFindifthereisatripletinaBalancedBSTthataddstozeroMergetwoBSTswithlimitedextraspaceTwonodesofaBSTareswapped,correcttheBSTConstructBSTfromgivenpreordertraversal|Set1ConstructBSTfromgivenpreordertraversal|Set2FloorandCeilfromaBSTConvertaBSTtoaBinaryTreesuchthatsumofallgreaterkeysisaddedtoeverykeySortedLinkedListtoBalancedBSTInplaceconversionofSortedDLLtoBalancedBSTFindapairwithgivensuminaBalancedBSTTotalnumberofpossibleBinarySearchTreeswithnkeysMergeTwoBalancedBinarySearchTreesBinaryTreetoBinarySearchTreeConversionTransformaBSTtogreatersumtreeInorderpredecessorandsuccessorforagivenkeyinBSTKthLargestElementinBSTwhenmodificationtoBSTisnotallowedHowtohandleduplicatesinBinarySearchTree?

    QuizonBinarySearchTrees

    QuizonBalancedBinarySearchTrees

    Heap:

    BinaryHeapBinomialHeapHeapSortKthLargestElementinanarraySortanalmostsortedarray/Sortanalmostsortedarray/TournamentTree(WinnerTree)andBinaryHeap

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1e 10/20

    Hashing:

    HashingIntroductionPrintaBinaryTreeinVerticalOrderFindwhetheranarrayissubsetofanotherarrayUnionandIntersectionoftwoLinkedListsFindapairwithgivensumCheckifagivenarraycontainsduplicateelementswithinkdistancefromeachotherFindItineraryfromagivenlistofticketsFindnumberofEmployeesUndereveryEmployee

    QuizonHashing

    Graph:

    Introduction,DFSandBFS:

    GraphanditsrepresentationsBreadthFirstTraversalforaGraphDepthFirstTraversalforaGraphApplicationsofDepthFirstSearchApplicationsofBreadthFirstTraversalDetectCycleinaDirectedGraphDetectCycleinaanUndirectedGraphDetectcycleinanundirectedgraphLongestPathinaDirectedAcyclicGraphTopologicalSortingCheckwhetheragivengraphisBipartiteornotSnakeandLadderProblemMinimizeCashFlowamongagivensetoffriendswhohaveborrowedmoneyfromeachotherBoggle(Findallpossiblewordsinaboardofcharacters)Assigndirectionstoedgessothatthedirectedgraphremainsacyclic

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1e 11/20

    MinimumSpanningTree:

    PrimsMinimumSpanningTree(MST))ApplicationsofMinimumSpanningTreeProblemPrimsMSTforAdjacencyListRepresentationKruskalsMinimumSpanningTreeAlgorithmBoruvkasalgorithmforMinimumSpanningTree

    ShortestPaths:

    DijkstrasshortestpathalgorithmDijkstrasAlgorithmforAdjacencyListRepresentationBellmanFordAlgorithmFloydWarshallAlgorithmJohnsonsalgorithmforAllpairsshortestpathsShortestPathinDirectedAcyclicGraphSomeinterestingshortestpathquestions,Shortestpathwithexactlykedgesinadirectedandweightedgraph

    Connectivity:

    FindifthereisapathbetweentwoverticesinadirectedgraphConnectivityinadirectedgraphArticulationPoints(orCutVertices)inaGraphBiconnectedgraphBridgesinagraphEulerianpathandcircuitFleurysAlgorithmforprintingEulerianPathorCircuitStronglyConnectedComponentsTransitiveclosureofagraphFindthenumberofislandsCountallpossiblewalksfromasourcetoadestinationwithexactlykedgesEulerCircuitinaDirectedGraph

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1e 12/20

    BiconnectedComponentsCheckifagivengraphistreeornotKargersalgorithmforMinimumCut

    HardProblems:

    GraphColoring(IntroductionandApplications)GreedyAlgorithmforGraphColoringTravellingSalesmanProblem(NaiveandDynamicProgramming)TravellingSalesmanProblem(ApproximateusingMST)HamiltonianCycleVertexCoverProblem|Set1(IntroductionandApproximateAlgorithm)KCentersProblem|Set1(GreedyApproximateAlgorithm)

    MaximumFlow:

    FordFulkersonAlgorithmforMaximumFlowProblem

    Findmaximumnumberofedgedisjointpathsbetweentwovertices

    Findminimumstcutinaflownetwork

    MaximumBipartiteMatching

    ChannelAssignmentProblem

    QuizonGraph

    QuizonGraphTraversals

    QuizonGraphShortestPaths

    QuizonGraphMinimumSpanningTree

    AdvancedDataStructure:

    AdvancedLists:

    MemoryefficientdoublylinkedlistXORLinkedListAMemoryEfficientDoublyLinkedList|Set1

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1e 13/20

    XORLinkedListAMemoryEfficientDoublyLinkedList|Set2SkipList|Set1(Introduction)SelfOrganizingList|Set1(Introduction)

    Trie:

    Trie|(InsertandSearch)Trie|(Delete)LongestprefixmatchingATriebasedsolutioninJavaPrintuniquerowsinagivenbooleanmatrix

    HowtoImplementReverseDNSLookUpCache?HowtoImplementForwardDNSLookUpCache?

    SuffixArrayandSuffixTree:

    SuffixArrayIntroductionSuffixArraynLognAlgorithmSuffixTreeIntroductionUkkonensSuffixTreeConstructionPart1UkkonensSuffixTreeConstructionPart2UkkonensSuffixTreeConstructionPart3UkkonensSuffixTreeConstructionPart4,UkkonensSuffixTreeConstructionPart5UkkonensSuffixTreeConstructionPart6GeneralizedSuffixTreeBuildLinearTimeSuffixArrayusingSuffixTreeSubstringCheckSearchingAllPatternsLongestRepeatedSubstring,LongestCommonSubstring,LongestPalindromicSubstring

    AVLTree:

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1e 14/20

    AVLTree|Set1(Insertion)AVLTree|Set2(Deletion)

    AVLwithduplicatekeys

    SplayTree:

    SplayTree|Set1(Search)SplayTree|Set2(Insert)

    BTree:

    BTree|Set1(Introduction)BTree|Set2(Insert)BTree|Set3(Delete)

    SegmentTree:

    SegmentTree|Set1(Sumofgivenrange)SegmentTree|Set2(RangeMinimumQuery)

    RedBlackTree:

    RedBlackTreeIntroductionRedBlackTreeInsertion.RedBlackTreeDeletionProgramforRedBlackTreeInsertion

    Others:

    TernarySearchTreeIntervalTreeImplementLRUCacheSortnumbersstoredondifferentmachinesFindthekmostfrequentwordsfromafileGivenasequenceofwords,printallanagramstogether

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1e 15/20

    TournamentTree(WinnerTree)andBinaryHeapDecisionTreesFake(Counterfeit)CoinPuzzle(12CoinPuzzle)SpaghettiStackDataStructureforDictionaryandSpellChecker?KDTreeBinomialHeapKDTreeBinaryIndexedTree

    Array:

    GivenanarrayA[]andanumberx,checkforpairinA[]withsumasxMajorityElementFindtheNumberOccurringOddNumberofTimesLargestSumContiguousSubarrayFindtheMissingNumberSearchanelementinasortedandpivotedarrayMergeanarrayofsizenintoanotherarrayofsizem+nMedianoftwosortedarraysWriteaprogramtoreverseanarrayProgramforarrayrotationReversalalgorithmforarrayrotationBlockswapalgorithmforarrayrotationMaximumsumsuchthatnotwoelementsareadjacentLeadersinanarraySortelementsbyfrequency|Set1CountInversionsinanarrayTwoelementswhosesumisclosesttozeroFindthesmallestandsecondsmallestelementinanarrayCheckforMajorityElementinasortedarrayMaximumandminimumofanarrayusingminimumnumberofcomparisonsSegregate0sand1sinanarray

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1e 16/20

    klargest(orsmallest)elementsinanarray|addedMinHeapmethodMaximumdifferencebetweentwoelementsUnionandIntersectionoftwosortedarraysFloorandCeilinginasortedarrayAProductArrayPuzzleSegregateEvenandOddnumbersFindthetworepeatingelementsinagivenarraySortanarrayof0s,1sand2sFindtheMinimumlengthUnsortedSubarray,sortingwhichmakesthecompletearraysortedFindduplicatesinO(n)timeandO(1)extraspaceEquilibriumindexofanarrayLinkedListvsArrayWhichsortingalgorithmmakesminimumnumberofmemorywrites?Turnanimageby90degreeNextGreaterElementCheckifarrayelementsareconsecutive|AddedMethod3FindthesmallestmissingnumberCountthenumberofoccurrencesinasortedarrayInterpolationsearchvsBinarysearchGivenanarrayarr[],findthemaximumjisuchthatarr[j]>arr[i]Maximumofallsubarraysofsizek(AddedaO(n)method)Findwhetheranarrayissubsetofanotherarray|AddedMethod3FindtheminimumdistancebetweentwonumbersFindtherepeatingandthemissing|Added3newmethodsMedianinastreamofintegers(runningintegers)FindaFixedPointinagivenarrayMaximumLengthBitonicSubarrayFindthemaximumelementinanarraywhichisfirstincreasingandthendecreasingCountsmallerelementsonrightsideMinimumnumberofjumpstoreachend

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1e 17/20

    ImplementtwostacksinanarrayFindsubarraywithgivensumDynamicProgramming|Set14(MaximumSumIncreasingSubsequence)LongestMonotonicallyIncreasingSubsequenceSize(NlogN)FindatripletthatsumtoagivenvalueFindthesmallestpositivenumbermissingfromanunsortedarrayFindthetwonumberswithoddoccurrencesinanunsortedarrayTheCelebrityProblemDynamicProgramming|Set15(LongestBitonicSubsequence)Findasortedsubsequenceofsize3inlineartimeLargestsubarraywithequalnumberof0sand1sDynamicProgramming|Set18(Partitionproblem)MaximumProductSubarrayFindapairwiththegivendifferenceReplaceeveryelementwiththenextgreatestDynamicProgramming|Set20(MaximumLengthChainofPairs)Findfourelementsthatsumtoagivenvalue|Set1(n^3solution)Findfourelementsthatsumtoagivenvalue|Set2(O(n^2Logn)Solution)Sortanearlysorted(orKsorted)arrayMaximumcircularsubarraysumFindtherowwithmaximumnumberof1sMedianoftwosortedarraysofdifferentsizesShuffleagivenarrayCountthenumberofpossibletrianglesIterativeQuickSortFindthenumberofislandsConstructionofLongestMonotonicallyIncreasingSubsequence(NlogN)FindthefirstcirculartourthatvisitsallpetrolpumpsArrangegivennumberstoformthebiggestnumberPancakesortingAPancakeSortingProblem

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1e 18/20

    TugofWarDivideandConquer|Set3(MaximumSubarraySum)CountingSortMergeOverlappingIntervalsFindthemaximumrepeatingnumberinO(n)timeandO(1)extraspaceStockBuySelltoMaximizeProfitRearrangepositiveandnegativenumbersinO(n)timeandO(1)extraspaceSortelementsbyfrequency|Set2FindapeakelementPrintallpossiblecombinationsofrelementsinagivenarrayofsizenGivenanarrayofofsizenandanumberk,findallelementsthatappearmorethann/ktimesFindthepointwhereamonotonicallyincreasingfunctionbecomespositivefirsttimeFindtheIncreasingsubsequenceoflengththreewithmaximumproductFindtheminimumelementinasortedandrotatedarrayStableMarriageProblemMergeksortedarrays|Set1RadixSortMoveallzeroestoendofarrayFindnumberofpairssuchthatx^y>y^xCountalldistinctpairswithdifferenceequaltokFindifthereisasubarraywith0sumSmallestsubarraywithsumgreaterthanagivenvalueSortanarrayaccordingtotheorderdefinedbyanotherarrayMaximumSumPathinTwoArraysCheckifagivenarraycontainsduplicateelementswithinkdistancefromeachotherSortanarrayinwaveformKthSmallest/LargestElementinUnsortedArray,KthSmallest/LargestElementinUnsortedArrayinExpectedLinearTime,

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1e 19/20

    KthSmallest/LargestElementinUnsortedArrayinWorstCaseLinearTimeFindIndexof0tobereplacedwith1togetlongestcontinuoussequenceof1sinabinaryarrayFindtheclosestpairfromtwosortedarraysGivenasortedarrayandanumberx,findthepairinarraywhosesumisclosesttoxCount1sinasortedbinaryarrayPrintAllDistinctElementsofagivenintegerarrayConstructanarrayfromitspairsumarrayFindcommonelementsinthreesortedarraysFindthefirstrepeatingelementinanarrayofintegersFindthesmallestpositiveintegervaluethatcannotberepresentedassumofanysubsetofagivenarrayRearrangeanarraysuchthatarr[j]becomesiifarr[i]isjFindpositionofanelementinasortedarrayofinfinitenumbersCanQuickSortbeimplementedinO(nLogn)worstcasetimecomplexity?CheckifagivenarraycontainsduplicateelementswithinkdistancefromeachotherFindtheelementthatappearsonceReplaceeveryarrayelementbymultiplicationofpreviousandnextCheckifanytwointervalsoverlapamongagivensetofintervalsDeleteanelementfromarray(Usingtwotraversalsandonetraversal)Givenasortedarrayandanumberx,findthepairinarraywhosesumisclosesttoxFindthelargestpairsuminanunsortedarrayOnlinealgorithmforcheckingpalindromeinastreamFindUnionandIntersectionoftwounsortedarraysPythagoreanTripletinanarrayMaximumprofitbybuyingandsellingashareatmosttwice

    QuizonArray

  • 14/06/2015 DataStructuresGeeksforGeeks

    data:text/htmlcharset=utf8,%3Cdiv%20class%3D%22pageinfo%22%20style%3D%22height%3A%2023.3333339691162px%3B%20fontsize%3A%201.1e 20/20

    Matrix:

    SearchinarowwiseandcolumnwisesortedmatrixPrintagivenmatrixinspiralformABooleanMatrixQuestionPrintuniquerowsinagivenbooleanmatrixMaximumsizesquaresubmatrixwithall1sPrintuniquerowsinagivenbooleanmatrixInplaceMxNsizematrixtranspose|UpdatedPrintMatrixDiagonallyDynamicProgramming|Set27(Maximumsumrectangleina2Dmatrix)StrassensMatrixMultiplicationCreateamatrixwithalternatingrectanglesofOandXFindtherowwithmaximumnumberof1sPrintallelementsinsortedorderfromrowandcolumnwisesortedmatrixGivenannxnsquarematrix,findsumofallsubsquaresofsizekxkCountnumberofislandswhereeveryislandisrowwiseandcolumnwiseseparatedFindacommonelementinallrowsofagivenrowwisesortedmatrixGivenamatrixofOandX,replaceOwithXifsurroundedbyX

    Misc:

    CommonlyAskedDataStructureInterviewQuestions|Set1AdatastructurefornelementsandO(1)operations

    YoucancreateanewDataStructuretopicanddiscussitwithothergeeksusingGeeksforgeeksQ&Apage.SeealreadydiscussedDataStructurequestionsonforum.