Data structures class

Assignment Help Data Structure & Algorithms
Reference no: EM13161785

data structures class this project will give you an introduction. There are two important data structures that you will learn and use. The first is a stack, it is a LIFO (Last In First Out) structure. You can think of it like a a stack of plates in your cabinet. You pile plates on top of each other when you put them away and you take a plate from the top of the pile when you need to use one. This functionality is called push (add to the top of the stack) and pop ( remove from the top of stack). There is one last function that most stacks have. This function is called peek because it will allow you to see what is at the top of the stack without removing it.

The other popular data structure is called a queue. The queue is a FIFO (First In First Out) data structure and you can think of it like standing in line at Disneyland. If you are fortunate enough to be first in line then you are the first person to get on the ride. You will see the stack and the queue all over computers if you study operating systems. The stack is used to store and keep track of variables and the queue is used to store data that is waiting to be processed. This is just to name a couple. In the operating system tasks that are being scheduled to run are put into the queue. There is a slight difference in that many of these queues are called priority queues in that each taks added to the queue is assigned a priority. The higher the priority a task has, the closer it gets to the front of the queue.

Your task is to create a priority queue class calle priQueue that is derived from the vector class. Your class should be constructed as a template class so that the type of data the queue operates on can easily be changed:

priQueue iQueue; // holds ints

priQueue sQueue; // holds string.

Your priority queue should be sorted by priority based on a value from 1 to 10. If a number is assigned that is outside the range of 1 to 10 you should give the element a value of 5. What this means is that each time an element is added to the queue it should be put in order by priority. If multiple elements are given the same priority their position relative to each other is unimportant as long as they are prioritized relative to other elements in the queue.

Your priQueue should have the following functionallity:

  • enqueue - Add an element to the queue
  • dequeue - Remove element from the front of the queue
  • peek - Return value at front of queue do not remove it
  • size - Returns the number of items in the queue.

Specifics

You should create a struct called qElem that will hold both the priority of the element and the data to be put in the queue. The struct should also be of template type so that the value it holds can be of any type. The priority variable type should be an int.

The priQueue class should be derived from vector and should also be a template class so that it can operate on any type. The enque function should be adding a qElem struct so that the data and the prority are coupled. This needs to be done so that the data and priority are related for sorting. Here is an example:

priQueue que;;

que.enqueue("Hello", 3);
que.enqueue("Goodbye", 9); // You are passing a string an an int but you should store a qElem struct.

string s = que.dequeue();

The string s at this point should hold "Goodbye" even though it was put in last because it has a higher priority.

Sorting your queue. You are to create your own sort functionality. Pick any sort that you would like but the bubble sort might be the easiest to implement.

 

 

Reference no: EM13161785

Questions Cloud

Compute the union and intersection of two sets : How can you compute the union and intersectio of two sets, using some of the methods that the set interfce provides? hint: your code should not be bigger than four lines
Public boolean chackanagram : write the anagramList() chackanagram. checkAnagram returns true if its two Word parameters have original words that are nagrams. If not, checkAnagram returns false. use the ethod header below to write checkanagram. Assume that all Word methods work a..
50 element array of integers with random numbers : write a java code to instantiate and initialize a 50 element array of integers with random numbers in the range of 45 through 256 inclusive.
Develop a web-scraping program : Develop a web-scraping program that can obtain the html contents from a URL and parse the contents to extract data to be used as the source data for a system integration document. This needs to be done in Visual Studio, preferrably VB, C#, or C++.
Data structures class : data structures class this project will give you an introduction. There are two important data structures that you will learn and use. The first is a stack, it is a LIFO (Last In First Out) structure. You can think of it like a a stack of plates in y..
Design a prgram using python : Design a prgram USING PYTHON that students can use to calculate what score they need on final exam to get a certan final grade for a course.
Indicates that the student id is abc54301 : Indicates that the student ID is ABC54301 and the answer to question 1 is  True, the answer to question 2 is False, and so on. This student did not  answer question 9. The exam has 20 questions, and the class has more than  150 students. Each corre..
Write java code to read integers from an input file : write java code to read integers from an input file and write only the odd numbers to an output file. the two file names will be provided on the command line as the input file followed by the output file.
List all the registration system stakeholders : 1. List all the registration system stakeholders. How is each group affected?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Find efficiency of high speed digital transmission system

Assume I have a multiplexer that is connected to a high speed digital transmission system that can transfer 1,536,000 data bits per second.

  Different levels of a dbms

Recognize the level within a database system user and designer of the DBMS software at which each of the following concerns or activities happen,

  Question about structured wiring

Describe how properly installed structured wiring save the need to recable when new applications are added. Provide some examples of a project that required to be recabled because it was not properly installed structured wiring?

  Describe why algorithm runs in on time

Assume you have the array A of n items, and you want to find k items in A closest to the median of A. Describe why your algorithm runs in O(n) time.

  Calculate bits number output of first round-des decryption

Calculate the bits number 1, 16, 33, and 48 at output of first round of DES decryption, suppose that ciphertext block is composed of all ones

  Solving single source shortest paths problem

Here is a proposed algorithm to solve single source shortest paths problem in a weighted directed graph G with possibly negative edges weights.

  Write algorithm find intersection of two singly-linked list

Write an algorithm (pseudocode) to find the intersection of two singly-linked lists. Assume that the data in each list are in nondecreasing order.

  Creating erd with primary, foreign keys and main attributes

A very small college wishes to keep track of history of all administrative appointments, The college chancellor may wish to know how many deans worked in college of business between January 1, 1960 and January 1 2008

  Coefficients of algorithm and negative coefficient mean

How could you utilize the larger grid size and longer time step? Write down the coefficients of your algorithm? What would negative coefficient mean?

  Build b tree for the part table

Build B+ tree for the PART table with n = 6 pointers; illustrate how B+ tree expand (show several intermediate trees) and what final tree will look like.

  Find minimum number of storage required for bfs and dfs

Assume we have problem space where there is uniform branching factor b and there is single goal node at depth m. Determine the minimum number of nodes expanded and storage required for BFS and DFS?

  Question about disk writing speed

Think about a disk holding documents with an average file length of 5 KB. Each document is allocated contiguously on adjacent sectors.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd