Search for question
Question

2. Use the STL queue (std:queue) container to implement a print queue that accepts incoming print jobs, named as PrintJob #1, PrintJob #2, etc. The print jobs arrive in random order in the sense that the first job might be PrintJob #4, the next one might be Printjob #1, etc. The print queue will look something like this:

PrintJob #4 PrintJob #2 PrintJob #1 PrintJob #3 ..

The program will generate the print job name strings (the digits are random numbers) and inserts these into the queue in the order received. After every second job inserted in the queue, the program will pop the job at the front of the queue displaying a message saying a particular job, identified by its name, is completed and the size of the queue.

As each job is inserted in the queue, the program will display a message saying “Added PrintJob #n to the queue. Size of the queue is …”.

Insert a total about 10 jobs to the queue. Please remember that the actions of adding jobs to the queue and every so often removing the job at the front of the queue should be interspersed.

Submit the code and the output on Camvas.


Most Viewed Questions Of Data Structures And Algo

3. We have a two-word query. For one term the postings list consists of the following 16 entries: [4,6,10,12,14,16,18,20,22,32,47,81,120,122,157,180] and for the other it is the one entry postings list: [47]. Work out how many comparisons would be done to intersect the two postings lists with the following two strategies. Briefly justify your answers (Let (x,y) denote a posting comparison. x refers to a value in the upper list and y refers to a value in the lower list) write down those comparisons): a. Using standard postings lists b. Using postings lists stored with skip pointers, with a skip length of VP (for a postings list of length P).


5. Consider the following fragment of a positional index with the format: word: document: (position, position, ...); document: (position, ...) Gates: 1: (3); 2: (6); 3: (2,17); 4: (1) IBM: 4: (3); 7: (14) Microsoft: 1: (1); 2: (1,21); 3: (3); 5: (16,22,51) The /k operator, word1 /k word2 finds occurrences of word1 within k words of word2 (on either side), where kis a positive integer argument. Thus k=1 demands that word1 be adjacent to word2. a. Describe the set of documents that satisfy the query Gates /2 Microsoft. b. Describe each set of values for k for which the query Gates /k Microsoft returns a different set of documents as the answer.


Draw the binary tree representation of the following arithmetic expression (((5+2) * (2-1)) / ((2+9) + ((7−2) − 1)) * 8) Write this expression to its postfix equivalent.


2. An algorithm takes 0.5 ms for input size 100. How long will it take for input size 500 if the running time is the following (assume low order terms are negligible) a. Linear b. O(NlogN) c. Quadratic


(a) Suppose you work for a major airline and are given the job of writing the algorithm for processing upgrades into first class on various flights. Any frequent flyer can request an upgrade for his or her up-coming flight using this online system. Frequent flyers have different priorities, which are determined first by frequent flyer status (which can be, in order, silver, gold, platinum, and super) and then, if there are ties, by length of time in the waiting list. In addition, at any time prior to the flight, a frequent flyer can cancel his or her upgrade request (for instance, if he or she wants to take a different flight), using a confirmation code they got when he or she made his or her upgrade request. When it is time to determine upgrades for a flight that is about to depart, the gate agents inform the system of the number, k, of seats available in first class, and it needs to match those seats with the k highest-priority passengers on the waiting list. Describe a system that can process upgrade requests and cancellations in O(log n) time and can determine the highest-priority flyers on the waiting list in O(k log n) time, where n is the number of frequent flyers on the waiting list.


1. The following pairs of words are stemmed to the same form by the Porter stemmer. Which pairs would you argue shouldn't be conflated. Give your reasoning. a. abandon/abandonment b. absorbency/absorbent c. marketing/markets d. university/universe e. volume/volumes


Which of the below is the correct way to call the function " ": A. cout<<myFunction(10 , 12.45); O B. myFunction (7, 4); O C. myFunction(12.5, 11.8); D. cout<<myFunction(10.7, 6);


Northeastern University CET2200 – Data Structures and Algorithms Homework 4 1. Order the following functions by growth rate N, N1.5, N2, √N, NlogN, 2N.


4. Assume a biword index. Give an example of a document which will be returned for a query of New York University but is actually a false positive which should not be returned.


What is the output of the following piece of code? #include <iostream> using namespace std; int main() { int array [] = {1, 2, 3, 4, 5); cout<<array[4]; return 0; }