Running queue_starter.js

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


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

// Initial requirement: support ops of a minimal breadth-first search
// Design decisions:
//   base on (re-use) the 324 linked list implementation
//   enqueue at list bottom  (reuse list's insert method)
//   therefore, dequeue at list top (reuse list's "first" pointer)
//   min utility (maintaianece) ops: init, check empty


// -----------------------------------------------------------------------
// Queue object constructor

function Queue()
{
   // specify object data and property fields

   this.head =                // (fill code) mark queue front

   // specify (i.e., design) interface names (queue methods)

   this.isEmpty               // (fill code) return true if queue empty
   this.enqueue = qqEnqueue;  // insert item at tail of queue
   this.dequeue =             // (fill) remove and return item from head of queue


}

// -----------------------------------------------------------------------
// functions used by methods of Queue() object, note "qq" prefix to 
// distinguish from similar functions in linked-list package


// specify (i.e., design) interface arguments and return values

function qqEmpty()         // implement based on linked list .isEmpty() method
{
   return 0;               // (replace by correct call)
}

// --------------------
function qqEnqueue(item)
{

}

// --------------------
function qqDequeue()
{
   var item;

   return item;
}