Running pq_starter.js

➕︎ Aa ➖︎ |Dark 1Dark 2Light|HackFira Code|Back to  PT Mono
// CPCS 324 Algorithms & Data Structures 2
// Outline - Priority queue data structure
// 2020, Dr. Muhammad Al-Hashimi


// -----------------------------------------------------------------------
// Basic design decisions and implementation planning (objects & interfaces)

// initial requirements: to quickly support Dijkstra and second Prim's algorithms,
// implement minimum functionality, interfaces match algorithm specs

// design decisions:
// Reuse the 324 linked list implementation, how will the PQ ops be implemented?
// <student fill here>

// code plan: start to write your API specifications (JSDOC comments) and think about
// design consequences (design impact)

// Impact analysis:
// <student fill here>



// -----------------------------------------------------------------------
// Priority queue object constructor (document using JSDOC comments)

function PQueue()
{
   this.pq = pqInit;              // requirement: linked-list implementation


   // specify (design) methods

   this.isEmpty = pqEmpty;        // return true if queue empty
   this.deleteMin = pqDeleteMin;  // remove/return item with minimum priority key
   this.insertUpdate = pqUpsert;  // insert item/key if not found otherwise update prior if new key smaller

}

// -----------------------------------------------------------------------
// Priority queue node constructor (document using JSDOC comments)

function PQNode(item, key)
{
   this.item = item;
   this.prior = key;

   // specify (design) methods

}

// -----------------------------------------------------------------------
// functions used by PQueue() object methods
// specify interface information (JSDOC comments)
// note required names
// ...