Ask Programming Language Expert

1. Compare the growth rates of the following pairs of functions:

a. f(n) = n and g(n) = (n + 1) / 2.

b. f(n) = n2 and g(n) = n2 + 6n.

c. f(n) = log n and g(n) = log n2.

d. f(n) = 2n and g(n) = 22n.

e. f(n) = 5n and g(n) = 4n3/2.

2. Show that:

a. (n + 1)3 is Ο(n3).

b. 2n + 1 is Ο(2n).

c. n is o(n log n).

d. n2 is ω(n).

e. n3 log n is ?(n3).

3. Give a big-Oh characterization of the running time of the following loops in terms of n.

a. Algorithm 1:

s = 0

for i = 1 to n

    s = s + i

b. Algorithm 2:

p = 1

for i = 1 to 2 * n

    p = p * i

c. Algorithm 3:

p = 1

for i = 1 to n ** 2

    p = p * i

d. Algorithm 4:

s = 0

for i = 1 to 2 * n

    for j = 1 to i

        s = s + i

e. Algorithm 5:

s = 0

for i = 1 to n ** 2

    for j = 1 to i

        s = s + i

4. In this problem, you are required to write a program that allows an operator to manage a (simulated) print queue. Your program must include facilities to support the following print queue operations:

a. List all the jobs.

b. Add a new job.

c. Remove a job.

d. Release the next job.

e. Increase the priority of a job.

f. Decrease the priority of a job.

The print queue should be implemented as a priority queue based upon the binary heap with hashing algorithms pseudocode provided on the CS340 Algorithms web page. The data structures used to implement your program might look something like this:

      struct Job

{

      int priority;

      int jobNo;

    string filename;

    int fileSize;

};

struct HashPointer

  {

      int jobNo;

      int location;

  };

  struct PrintQueue

  {

      int elementCount;

      Job a [HEAP_SIZE];

      HashPointer h [HEAP_SIZE];

  };

      The print queue should provide storage for up to 15 jobs (i.e., HEAP_SIZE=16). A job in the print queue (found in the Job array a in PrintQueue) is completely described by the priority, jobNo, fileName, and fileSize members of Job. The jobNo for each job is a unique value that is incremented after each new job is added to the print queue. The jobNo should be initialized to 1. For each new job added to the print queue, the values for priority, fileName, and fileSize are entered by the operator. Valid values for the priority member must be in the range from 1 to 3, inclusive, where 1 is the highest priority and 3 is the lowest. Whenever there is more than one job with the same priority, the job with the smaller file size will be considered to have higher priority. Jobs in the print queue are ordered by priority. The HashPointer array h in PrintQueue is used for finding and directly accessing a job in the Job array a.

Once your program is implemented and tested, you can demonstrate that it works by following the sequence of events given below:

- Create print queue

- List all

- Insert a153  // a = file name, 15 = file size, 3 = priority    (a will be assigned jobNo=1)

- Insert b103    (b will be assigned jobNo=2)

- Insert c53    (c will be assigned jobNo=3)

- List all  // 3: c 5 3\n    2: b 10 3\n    1: a 15 3\n    (3, 2, and 1 are job numbers and \n is meant to indicate that each job should be printed on a new line)

- Insert d202    (d will be assigned jobNo=4)

- Insert e252    (e will be assigned jobNo=5)

- Insert f152    (f will be assigned jobNo=6)

- List all

- Release next

- Release next

- List all

- Insert g154

- Insert g152    (g will be assigned jobNo=7)

- Change priority 12  // 1 = job number of a, 2 = new priority

- List all

- Change priority 73

- Change priority 82

- Change priority 21

- Change priority 54

- List all

- Remove 3  // 3 = job number of c

- Remove 5

- List all

- Release next

- Release next

- Release next

- List all

If you are working alone, submit to UR Courses: (1) any .cpp and .h files you might have created (and only the .cpp and .h files) zipped into one file and (2) a single script file showing the execution of your program as you follow the sequence of events given above.

If you are working in a partnership, one of the partners should submit to UR Courses: (1) a file named partners that provides the name and student numbers of the partners, (2) any .cpp and .h files you might have created (and only the .cpp and .h files) zipped into one file and (3) a single script file showing the execution of your program as you follow the sequence of events given above. The other partner/s should submit to UR Courses: (1) a file named partners that provides the name and student numbers of the partners. Note that all partners need to submit the partners file.

5. The dynamic linked list topological sorting algorithm pseudocode provided on the CS340 Algorithms web page generates only one possible ordering of the items. In some situations, it may be that one or more items can be interchanged and the output generated will be another possible ordering of the items. And in other situations, if the items were tasks in constructing a house, for example, or courses offered at a university, it may be that one or more tasks could be done concurrently, or one or more courses could be taken concurrently.

In this problem, you are required to implement the dynamic linked list topological sorting algorithm pseudocode provided on the CS340 Algorithms web page. However, you are required to modify the algorithm so that it identifies items that can occur concurrently.

After the data structure has been built in the input phase, print it out in the following format (the data shown below is based on the example shown in class):

      Leader 1

     element = 1

     inDegree = 0

     nextLeader = 2

     Follower 1 = 2

     Follower 2 = 3

  Leader 2

     element = 2

     inDegree = 1

     nextLeader = 4

     Follower 1 = 4

     Follower 2 = 10

  .

  .

  .

 

  Leader 10

     element = 9

     inDegree = 1

     nextLeader = N/A

     Follower 1 = 10

     Follower 2 = 4

      In the output phase, create a list of items, one per line, except for concurrent items. Concurrent items should be listed on the same line. For example, if the problem consists of items A, B, C, and D, and the output is

A

B C

D

this implies that B and C are concurrent items.

      Once your program is implemented and tested, you can demonstrate that it works by using the CS_Prerequisites.txt file in the /home/venus/hilder/cs340/assignment2/datafiles directory as input.

If you are working alone, submit to UR Courses: (1) any .cpp and .h files you might have created (and only the .cpp and .h files) zipped into one file and (2) a single script file showing the execution of your program using the CS_Prerequisites.txt file as input.

If you are working in a partnership, one of the partners should submit to UR Courses: (1) a file named partners that provides the name and student numbers of the partners, (2) any .cpp and .h files you might have created (and only the .cpp and .h files) zipped into one file and (3) a single script file showing the execution of your program using the CS_Prerequisites.txt file as input. The other partner/s should submit to UR Courses: (1) a file named partners that provides the name and student numbers of the partners. Note that all partners need to submit the partners file.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91580529
  • Price:- $110

Guranteed 48 Hours Delivery, In Price:- $110

Have any Question?


Related Questions in Programming Language

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As