Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives Review the C programming language. Learn how to use the Netbeans Integrated Development Environment ( IDE ) for C programs Implement a Priority Queue

Objectives
Review the C programming language.
Learn how to use the Netbeans Integrated Development Environment (IDE) for C
programs
Implement a Priority Queue using a linked list.
Problem description
You need to implement a Priority Queue using a linked list.
A Priority Queue is used in Operating Systems kernel as part of the scheduling algorithm. Briefly,
when a process cannot continue running (perhaps because it is waiting for some event such as
input/output), the OS has to choose which waiting process that is ready to run gets control of the
CPU. Part of this algorithm involves a priority queue where the ready processes are ordered by their
priority. All things being equal, the highest priority task will be allowed to run.
Template code is given to you. You need to implement the functions PQ_insert and PQ_delete
functions.
You are given the header file pri_queue.h:
#ifndef PRI_QUEUE_H
#define PRI_QUEUE_H
typedef struct node {
int priority;
char * data;
struct node * next;
} Node_t,* Node_ptr_t;
extern void PQ_insert( int, char *);
extern Node_ptr_t PQ_delete();
extern Node_ptr_t PQ_get_head();
extern int PQ_get_size();
#endif /* PRI_QUEUE_H */
This header file defines new data types:
Node_t: A data structure for the nodes in the Priority Queue linked list. Each node contains its
priority, data (a string) and a pointer to the next node in the list. (If a node is the last one on the
list its next is NULL.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel 2024 In 7 Days

Authors: Alan Dinkins

1st Edition

B0CJ3X98XK, 979-8861224000

More Books

Students also viewed these Databases questions