PDF4PRO ⚡AMP

Modern search engine that looking for books and documents around the web

Example: tourism industry

Data Structures - Stanford University

Back to document page

Data StructuresJaehyun ParkCS 97SIStanford UniversityJune 29, 2015Typical Quarter at Stanfordvoid quarter() {while(true) { // no break :(task x = GetNextTask(tasks);process(x);// new tasks may enter}} GetNextTask()decides the order of the tasks2Deciding the Order of the Tasks Possible behaviors of GetNextTask(): Returns the newest task (stack) Returns the oldest task (queue) Returns the most urgent task (priority queue) Returns the easiest task (priority queue) GetNextTask()should run fast We do this by storing the tasks in a clever way3OutlineStack and QueueHeap and Priority QueueUnion-Find StructureBinary Search Tree (BST)Fenwick TreeLowest Common Ancestor (LCA)Stack and Queue4Stack Last in, first out (LIFO) Supports three constant-time operations Push(x): insertsxinto the stack Pop(): removes the newest item Top(): returns the newest item Very easy to implement using an arrayStack and Queue5Stack Implementation Have a large enough arrays[]and a counterk, which startsat zero Push(x): sets[k] = xand incrementkby 1 Pop(): decrementkby 1 Top().)

1. Make a new node in the last level, as far left as possible – If the last level is full, make a new one 2. If the new node breaks the heap property, swap with its parent node – The new node moves up the tree, which may introduce another conflict 3. Repeat 2 until all conflicts are resolved Running time = tree height = O(logn)

  Levels, Structure

Download Data Structures - Stanford University


Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Spam in document Broken preview Other abuse

Related search queries