2

Jobs with and without Priority (Id-2780)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 2780

 

Jobs are submitted to an operating system. Operating system does something called job scheduling when a number of jobs are submitted to an operating system at the same time. Some of the jobs have only job id and time required to complete the job. Whereas some other jobs are having priority in addition to job id and time required. Given a set of jobs without priority print the id of the job that requires minimum time to execute and given a set of jobs with priority, print the id and priority of the job which requires minimum time to execute. Design a OOP model to solve the problem.

Input Format

Number of jobs without priority

Id of job1

Time required by job1

Id of job-n

Time required by job-n

Number of jobs with priority

Id of job1

Time required by job1

Priority of job1

Id of job-n

Time required by job-n

Priority of job-n

Output Format

Id of job with out priority that requires minimum time

Id of job with priority that requires minimum time  and its priority.

Code

Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 🙂

Example: <pre> Your Code </pre>

C++ Code 

The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

 

Click Here to Leave a Comment Below 2 comments
vishal.p - March 22, 2018

bro i got code for CSE1002 Customer discount (Id-1413)




0



0

Reply
ABINASH - March 22, 2018

CSE1002 Generic Double Ended Queue
solution for above problem is wanted please help

Design a generic class queue to maintain a list of elements. Queue is a linear data structure that follow FIFO ordering of elements. It is a special kind of list where elements can be inserted at one end and deleted at the end. There are two end points called front and rear. Front is the point of deletion and that move for each deletion but always points to the element that was inserted first among the elements remaining in the queue. Rear is the point of the insertion and move for each insertion but always points to the element that was inserted last among the elements remaining in the queue. Provide member functions to check if a queue is empty, queue is full, enqueue and dequeue.

Enqueue – if queue is not full, increment rear and place the element

dequeue – If queue is not empty, return element pointed by front and increment front

isempty – Return true when front is greater than rear or when both are -1

isfull – return true when rear is capacity – 1

Extended the class queue to create another generic class deque which represents a double ended queue. In deque, elements can be added to or removed from either the front or rear. The operations in a deque are defined as follows:

push_back – Insert an element at the rear (enqeue in Queue)

push_front – Insert an element at the front, if queue is not full push all elements forward and place new element, change rear also

pop_back – Remove an element at the rear, if queue is not empty, return element pointed by rear and decrement rear

pop_front – Remove an element at the front (dequeue in Queue)

print – print elements of queue from first to last

Input Format

Choice of queue and data type (1 – integer linear queue, 2 – String deque)

Choice of operation

For queue – 1 – isempty, 2 – isfull, 3 – enqueue, 4 – dequeue, 5 – Print content of queue, 6 – exit

for enqueue option 3, element to be inserted will follow the choice

For deque – 1 – isempty, 2 – isfull, 3 – push_back, 4 – push_front, 5 – pop_back, 6 – pop_front 7 – Print content of deque, 8 – exit

for both the push options 3 and 4, element to be inserted will follow the choice

Output Format

Print the content of queue after each operation, print elements from first to last




0



0

Reply

Leave a Reply:

This site uses cookies and by using the site you are consenting to this.