Giter Club home page Giter Club logo

dsa-queues-hw's Introduction

Group assignment for Data Structures and Algorithms. Worked with Ragy Costa De Jesus.

  • In this assignment, you will implement N dynamic priority queues. Let us first look at a single queue. Your program is given a sequence of objects, for example: a, b, w, a, x, s, … The queue maintains numElements such objects, so that the first (front) is the oldest in the sequence, and the last (rear) is the most recent in the sequence. When the queue is full, the oldest (front) is deleted, so that the new object can be inserted (in rear). If an object that is already in the queue is seen again, it becomes the most recent (= it is moved to the rear). This way, the queue is maintained ordered by the key’s place in the sequence (rear = most recently referenced, front = least recently referenced).

  • The queue will be implemented using a queue based on a single-linked list (DynamicNode, rear and front pointers, so it should be similar to DynamicQueue on Canvas Files). Elements are inserted at the rear, deletion is explained in the following paragraphs. To implement a SINGLE queue, you CANNOT use: array, or any available library or STL classes_._

  • We must use N queues, and rather than using N hard-coded variables, you should keep the N queues in a 1-D array. So, if you want to use the 1-st queue, you would use Queues[0] in the main code; if you want to use the i-th queue, you would use Queues[i] in your main code. If instead of an array, your code has hardcoded the queues with N queue variables => about 10% off.

  • Your program must set (hardcode) these: the number of queues (N=length of the array), and the max number of elements in each queue (QUEUESIZE).

  • Your program reads a file that contains a sequence of <key, index> When a <key index> pair is read, the program must insert the key to the corresponding queue, queues[index]. In the example above, reading the first line <a 1> will insert ‘a’ into queues[1]. For example, to insert key ‘a’ into a specific queue, queues[i]:

    1. Check if the key (‘a’) already exists in the queue.
    2. If ‘a’ does NOT exist in the queue:
      • If the queue is NOT full insert new node with key ‘a’ in rear of queue.
      • Else //queue is full -- that is, it contains QUEUESIZE elements remove front element of the queue; then, insert new node with key ‘a’ in rear.
    3. Else // ‘a’ already exists in the queue
      • Move the node with ‘a’ to the rear (so rear is again the most recently referenced key).

Example output using data.txt file (https://github.com/dfgrisales5078/DSA-QUEUES-HW/blob/main/cmake-build-debug/data.txt), using number of queues N = 4 and queue size QUEUESIZE = 4

dsa-queues-hw's People

Contributors

dfgrisales5078 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.