SlideShare a Scribd company logo
1 of 11
/*
* To change this license header, choose License Headers in
Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* To change this license header, choose License Headers in
Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
#include
#include
#include "PQLL_Mahato.h"
int peek(Node** head)
{
return (*head)->data;
}
//Removes the element with the
//highest priority from the list
void dequeue(Node** head)
{
Node* temp = *head;
(*head) = (*head)->next;
free(temp);
}
// function to check is list is empty
int isEmpty(Node** head)
{
return (*head) == NULL;
}
Node* newNode(char d, int p)
{
Node* temp = (Node*)malloc(sizeof(Node));
temp->data = d;
temp->priority = p;
temp->next = NULL;
return temp;
}
// Function to enqueue according to priority
void enqueue (Node** head, char d, int p)
{
Node* start = (*head);
// Create new Node
Node* temp = newNode(d, p);
// special case: The head of list has lesser
// priority than new node. So insert new
// node before head node and change head node.
if ((*head)->priority > p) {
// Insert New node before head
temp->next = *head;
(*head) = temp;
}
else {
// Traverse the list and find a
// position to insert a new node
while (start->next != NULL &&
start->next->priority < p){
start = start->next;
}
// Either at the ends of the list
// or at the required position
temp->next = start->next;
start->next = temp;
}
}
/*
* File: PQLL_Mahato.h
* Author: Aaditya
*
* Created on April 7, 2020, 9:44 PM
*/
#ifndef PQLL_MAHATO_H
#define PQLL_MAHATO_H
#ifdef __cplusplus
extern "C" {
#endif
///Node
typedef struct node {
char data;
/*
* To change this license header, choose License Headers in
Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: PQLLMain_Mahato.c
* Author: Aaditya
*
* Created on April 8, 2020, 9:45 PM
*/
#include
#include
#include "PQLL_Mahato.h"
int main(int argc, char** argv) {
//create a new priority queue
Node* pq = newNode('B' , 1);
enqueue(&pq, 'C' , 2);
enqueue(&pq, 'D' , 3);
enqueue(&pq, 'A' , 0);
while (!isEmpty(&pq)) {
printf("%c ", peek(&pq));
dequeue(&pq);
}
printf("n");
return (EXIT_SUCCESS);
}
//Lower values indicate higher priority
int priority;
struct node* next;
} Node;
int peek(Node** head);
void dequeue(Node** head);
void enqueue(Node** head, char d, int p);
int isEmpty(Node** head);
Node* newNode(char d, int p);
#ifdef __cplusplus
}
#endif
#endif /* PQLL_MAHATO_H */

More Related Content

Similar to To change this license header, choose License Headers in P.docx

Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationAbdul Malik Ikhsan
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfanton291
 
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdfplease navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdfaioils
 
Write message.cpp and priorityq.cpp. The code in message.cpp and pri.pdf
Write message.cpp and priorityq.cpp. The code in message.cpp and pri.pdfWrite message.cpp and priorityq.cpp. The code in message.cpp and pri.pdf
Write message.cpp and priorityq.cpp. The code in message.cpp and pri.pdfeyeonsecuritysystems
 
Using C++I keep getting messagehead does not name a type.pdf
Using C++I keep getting messagehead does not name a type.pdfUsing C++I keep getting messagehead does not name a type.pdf
Using C++I keep getting messagehead does not name a type.pdfalokkesh1
 
Cambio de bases
Cambio de basesCambio de bases
Cambio de basesalcon2015
 
In C pls -- Write your name here -- Write the compiler used- Visual st.docx
In C pls -- Write your name here -- Write the compiler used- Visual st.docxIn C pls -- Write your name here -- Write the compiler used- Visual st.docx
In C pls -- Write your name here -- Write the compiler used- Visual st.docxBlake0FxCampbelld
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overviewstn_tkiller
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfudit652068
 
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdfajay1317
 
Please answer the 4 questions using C- The expected output is shown be.docx
Please answer the 4 questions using C- The expected output is shown be.docxPlease answer the 4 questions using C- The expected output is shown be.docx
Please answer the 4 questions using C- The expected output is shown be.docxcgraciela1
 
I need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdfI need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdfeyeonsecuritysystems
 
Automating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondAutomating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondNuvole
 
Implementing a basic directory-tree structure that is derived from a.pdf
Implementing a basic directory-tree structure that is derived from a.pdfImplementing a basic directory-tree structure that is derived from a.pdf
Implementing a basic directory-tree structure that is derived from a.pdffunkybabyindia
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdfadityastores21
 

Similar to To change this license header, choose License Headers in P.docx (20)

C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
 
Supermarket
SupermarketSupermarket
Supermarket
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept Implementation
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
 
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdfplease navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
 
Write message.cpp and priorityq.cpp. The code in message.cpp and pri.pdf
Write message.cpp and priorityq.cpp. The code in message.cpp and pri.pdfWrite message.cpp and priorityq.cpp. The code in message.cpp and pri.pdf
Write message.cpp and priorityq.cpp. The code in message.cpp and pri.pdf
 
Using C++I keep getting messagehead does not name a type.pdf
Using C++I keep getting messagehead does not name a type.pdfUsing C++I keep getting messagehead does not name a type.pdf
Using C++I keep getting messagehead does not name a type.pdf
 
C Programming Project
C Programming ProjectC Programming Project
C Programming Project
 
Framework Project Portfolio
Framework Project PortfolioFramework Project Portfolio
Framework Project Portfolio
 
Cambio de bases
Cambio de basesCambio de bases
Cambio de bases
 
In C pls -- Write your name here -- Write the compiler used- Visual st.docx
In C pls -- Write your name here -- Write the compiler used- Visual st.docxIn C pls -- Write your name here -- Write the compiler used- Visual st.docx
In C pls -- Write your name here -- Write the compiler used- Visual st.docx
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdf
 
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
 
Please answer the 4 questions using C- The expected output is shown be.docx
Please answer the 4 questions using C- The expected output is shown be.docxPlease answer the 4 questions using C- The expected output is shown be.docx
Please answer the 4 questions using C- The expected output is shown be.docx
 
I need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdfI need help completing this C++ code with these requirements.instr.pdf
I need help completing this C++ code with these requirements.instr.pdf
 
Automating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondAutomating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyond
 
Implementing a basic directory-tree structure that is derived from a.pdf
Implementing a basic directory-tree structure that is derived from a.pdfImplementing a basic directory-tree structure that is derived from a.pdf
Implementing a basic directory-tree structure that is derived from a.pdf
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
 
Start
StartStart
Start
 

More from adkinspaige22

. Review the three articles about Inflation that are found below thi.docx
. Review the three articles about Inflation that are found below thi.docx. Review the three articles about Inflation that are found below thi.docx
. Review the three articles about Inflation that are found below thi.docxadkinspaige22
 
.         Find an invertebrate that is endemic to Florida. Endem.docx
.         Find an invertebrate that is endemic to Florida. Endem.docx.         Find an invertebrate that is endemic to Florida. Endem.docx
.         Find an invertebrate that is endemic to Florida. Endem.docxadkinspaige22
 
. Read the Harvard Business Review article  Link3. View this ve.docx
. Read the Harvard Business Review article  Link3. View this ve.docx. Read the Harvard Business Review article  Link3. View this ve.docx
. Read the Harvard Business Review article  Link3. View this ve.docxadkinspaige22
 
. Go to a news site and look at the headlines of several articles. A.docx
. Go to a news site and look at the headlines of several articles. A.docx. Go to a news site and look at the headlines of several articles. A.docx
. Go to a news site and look at the headlines of several articles. A.docxadkinspaige22
 
-Describe the Plessy v. Ferguson Supreme Court Case of 1896; how was.docx
-Describe the Plessy v. Ferguson Supreme Court Case of 1896; how was.docx-Describe the Plessy v. Ferguson Supreme Court Case of 1896; how was.docx
-Describe the Plessy v. Ferguson Supreme Court Case of 1896; how was.docxadkinspaige22
 
-Do the schedule with Activity on Node and also draw the schedule.docx
-Do the schedule with Activity on Node and also draw the schedule.docx-Do the schedule with Activity on Node and also draw the schedule.docx
-Do the schedule with Activity on Node and also draw the schedule.docxadkinspaige22
 
.  Record your initial reaction to the work (suggested length of 1.docx
.  Record your initial reaction to the work (suggested length of 1.docx.  Record your initial reaction to the work (suggested length of 1.docx
.  Record your initial reaction to the work (suggested length of 1.docxadkinspaige22
 
-Describe the existing needs for cost information in healthcare firm.docx
-Describe the existing needs for cost information in healthcare firm.docx-Describe the existing needs for cost information in healthcare firm.docx
-Describe the existing needs for cost information in healthcare firm.docxadkinspaige22
 
--------250 words---------Chapter 18 – According to literatu.docx
--------250 words---------Chapter 18 – According to literatu.docx--------250 words---------Chapter 18 – According to literatu.docx
--------250 words---------Chapter 18 – According to literatu.docxadkinspaige22
 
-Please name the functions of the skeletal system.2-Where are lo.docx
-Please name the functions of the skeletal system.2-Where are lo.docx-Please name the functions of the skeletal system.2-Where are lo.docx
-Please name the functions of the skeletal system.2-Where are lo.docxadkinspaige22
 
-TOPIC= Civil Right Movement and Black Power Movement#St.docx
-TOPIC= Civil Right Movement and Black Power Movement#St.docx-TOPIC= Civil Right Movement and Black Power Movement#St.docx
-TOPIC= Civil Right Movement and Black Power Movement#St.docxadkinspaige22
 
- Wordcount 500 to 1000 words- Structure Cover, Table of Conte.docx
- Wordcount 500 to 1000 words- Structure Cover, Table of Conte.docx- Wordcount 500 to 1000 words- Structure Cover, Table of Conte.docx
- Wordcount 500 to 1000 words- Structure Cover, Table of Conte.docxadkinspaige22
 
-What benefits can a diverse workforce provide to an organization.docx
-What benefits can a diverse workforce provide to an organization.docx-What benefits can a diverse workforce provide to an organization.docx
-What benefits can a diverse workforce provide to an organization.docxadkinspaige22
 
-How would you define or describe the American Great Migration m.docx
-How would you define or describe the American Great Migration m.docx-How would you define or describe the American Great Migration m.docx
-How would you define or describe the American Great Migration m.docxadkinspaige22
 
- We learned from our readings that the use of mobile devices in our.docx
- We learned from our readings that the use of mobile devices in our.docx- We learned from our readings that the use of mobile devices in our.docx
- We learned from our readings that the use of mobile devices in our.docxadkinspaige22
 
- Goals (short and long term) and how you developed them; experience.docx
- Goals (short and long term) and how you developed them; experience.docx- Goals (short and long term) and how you developed them; experience.docx
- Goals (short and long term) and how you developed them; experience.docxadkinspaige22
 
- Pick ONE Theme for the 5 short stories (ex setting, character.docx
- Pick ONE Theme for the 5 short stories (ex setting, character.docx- Pick ONE Theme for the 5 short stories (ex setting, character.docx
- Pick ONE Theme for the 5 short stories (ex setting, character.docxadkinspaige22
 
- Briefly summarize the Modernization Theory (discuss all four stage.docx
- Briefly summarize the Modernization Theory (discuss all four stage.docx- Briefly summarize the Modernization Theory (discuss all four stage.docx
- Briefly summarize the Modernization Theory (discuss all four stage.docxadkinspaige22
 
+16159390825Whats app the test online on time .docx
+16159390825Whats app the test online on time .docx+16159390825Whats app the test online on time .docx
+16159390825Whats app the test online on time .docxadkinspaige22
 
(philosophy1. why is mills philosophy closely identified with.docx
(philosophy1. why is mills philosophy closely identified with.docx(philosophy1. why is mills philosophy closely identified with.docx
(philosophy1. why is mills philosophy closely identified with.docxadkinspaige22
 

More from adkinspaige22 (20)

. Review the three articles about Inflation that are found below thi.docx
. Review the three articles about Inflation that are found below thi.docx. Review the three articles about Inflation that are found below thi.docx
. Review the three articles about Inflation that are found below thi.docx
 
.         Find an invertebrate that is endemic to Florida. Endem.docx
.         Find an invertebrate that is endemic to Florida. Endem.docx.         Find an invertebrate that is endemic to Florida. Endem.docx
.         Find an invertebrate that is endemic to Florida. Endem.docx
 
. Read the Harvard Business Review article  Link3. View this ve.docx
. Read the Harvard Business Review article  Link3. View this ve.docx. Read the Harvard Business Review article  Link3. View this ve.docx
. Read the Harvard Business Review article  Link3. View this ve.docx
 
. Go to a news site and look at the headlines of several articles. A.docx
. Go to a news site and look at the headlines of several articles. A.docx. Go to a news site and look at the headlines of several articles. A.docx
. Go to a news site and look at the headlines of several articles. A.docx
 
-Describe the Plessy v. Ferguson Supreme Court Case of 1896; how was.docx
-Describe the Plessy v. Ferguson Supreme Court Case of 1896; how was.docx-Describe the Plessy v. Ferguson Supreme Court Case of 1896; how was.docx
-Describe the Plessy v. Ferguson Supreme Court Case of 1896; how was.docx
 
-Do the schedule with Activity on Node and also draw the schedule.docx
-Do the schedule with Activity on Node and also draw the schedule.docx-Do the schedule with Activity on Node and also draw the schedule.docx
-Do the schedule with Activity on Node and also draw the schedule.docx
 
.  Record your initial reaction to the work (suggested length of 1.docx
.  Record your initial reaction to the work (suggested length of 1.docx.  Record your initial reaction to the work (suggested length of 1.docx
.  Record your initial reaction to the work (suggested length of 1.docx
 
-Describe the existing needs for cost information in healthcare firm.docx
-Describe the existing needs for cost information in healthcare firm.docx-Describe the existing needs for cost information in healthcare firm.docx
-Describe the existing needs for cost information in healthcare firm.docx
 
--------250 words---------Chapter 18 – According to literatu.docx
--------250 words---------Chapter 18 – According to literatu.docx--------250 words---------Chapter 18 – According to literatu.docx
--------250 words---------Chapter 18 – According to literatu.docx
 
-Please name the functions of the skeletal system.2-Where are lo.docx
-Please name the functions of the skeletal system.2-Where are lo.docx-Please name the functions of the skeletal system.2-Where are lo.docx
-Please name the functions of the skeletal system.2-Where are lo.docx
 
-TOPIC= Civil Right Movement and Black Power Movement#St.docx
-TOPIC= Civil Right Movement and Black Power Movement#St.docx-TOPIC= Civil Right Movement and Black Power Movement#St.docx
-TOPIC= Civil Right Movement and Black Power Movement#St.docx
 
- Wordcount 500 to 1000 words- Structure Cover, Table of Conte.docx
- Wordcount 500 to 1000 words- Structure Cover, Table of Conte.docx- Wordcount 500 to 1000 words- Structure Cover, Table of Conte.docx
- Wordcount 500 to 1000 words- Structure Cover, Table of Conte.docx
 
-What benefits can a diverse workforce provide to an organization.docx
-What benefits can a diverse workforce provide to an organization.docx-What benefits can a diverse workforce provide to an organization.docx
-What benefits can a diverse workforce provide to an organization.docx
 
-How would you define or describe the American Great Migration m.docx
-How would you define or describe the American Great Migration m.docx-How would you define or describe the American Great Migration m.docx
-How would you define or describe the American Great Migration m.docx
 
- We learned from our readings that the use of mobile devices in our.docx
- We learned from our readings that the use of mobile devices in our.docx- We learned from our readings that the use of mobile devices in our.docx
- We learned from our readings that the use of mobile devices in our.docx
 
- Goals (short and long term) and how you developed them; experience.docx
- Goals (short and long term) and how you developed them; experience.docx- Goals (short and long term) and how you developed them; experience.docx
- Goals (short and long term) and how you developed them; experience.docx
 
- Pick ONE Theme for the 5 short stories (ex setting, character.docx
- Pick ONE Theme for the 5 short stories (ex setting, character.docx- Pick ONE Theme for the 5 short stories (ex setting, character.docx
- Pick ONE Theme for the 5 short stories (ex setting, character.docx
 
- Briefly summarize the Modernization Theory (discuss all four stage.docx
- Briefly summarize the Modernization Theory (discuss all four stage.docx- Briefly summarize the Modernization Theory (discuss all four stage.docx
- Briefly summarize the Modernization Theory (discuss all four stage.docx
 
+16159390825Whats app the test online on time .docx
+16159390825Whats app the test online on time .docx+16159390825Whats app the test online on time .docx
+16159390825Whats app the test online on time .docx
 
(philosophy1. why is mills philosophy closely identified with.docx
(philosophy1. why is mills philosophy closely identified with.docx(philosophy1. why is mills philosophy closely identified with.docx
(philosophy1. why is mills philosophy closely identified with.docx
 

Recently uploaded

Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 

Recently uploaded (20)

Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 

To change this license header, choose License Headers in P.docx

  • 1. /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ #include #include
  • 2. #include "PQLL_Mahato.h" int peek(Node** head) { return (*head)->data; } //Removes the element with the //highest priority from the list void dequeue(Node** head) { Node* temp = *head; (*head) = (*head)->next; free(temp);
  • 3. } // function to check is list is empty int isEmpty(Node** head) { return (*head) == NULL; } Node* newNode(char d, int p) { Node* temp = (Node*)malloc(sizeof(Node)); temp->data = d; temp->priority = p;
  • 4. temp->next = NULL; return temp; } // Function to enqueue according to priority void enqueue (Node** head, char d, int p) { Node* start = (*head); // Create new Node Node* temp = newNode(d, p); // special case: The head of list has lesser
  • 5. // priority than new node. So insert new // node before head node and change head node. if ((*head)->priority > p) { // Insert New node before head temp->next = *head; (*head) = temp; } else { // Traverse the list and find a // position to insert a new node while (start->next != NULL && start->next->priority < p){
  • 6. start = start->next; } // Either at the ends of the list // or at the required position temp->next = start->next; start->next = temp; } } /* * File: PQLL_Mahato.h * Author: Aaditya
  • 7. * * Created on April 7, 2020, 9:44 PM */ #ifndef PQLL_MAHATO_H #define PQLL_MAHATO_H #ifdef __cplusplus extern "C" { #endif ///Node typedef struct node { char data; /*
  • 8. * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: PQLLMain_Mahato.c * Author: Aaditya * * Created on April 8, 2020, 9:45 PM */ #include
  • 9. #include #include "PQLL_Mahato.h" int main(int argc, char** argv) { //create a new priority queue Node* pq = newNode('B' , 1); enqueue(&pq, 'C' , 2); enqueue(&pq, 'D' , 3); enqueue(&pq, 'A' , 0); while (!isEmpty(&pq)) { printf("%c ", peek(&pq)); dequeue(&pq);
  • 10. } printf("n"); return (EXIT_SUCCESS); } //Lower values indicate higher priority int priority; struct node* next; } Node; int peek(Node** head); void dequeue(Node** head); void enqueue(Node** head, char d, int p);
  • 11. int isEmpty(Node** head); Node* newNode(char d, int p); #ifdef __cplusplus } #endif #endif /* PQLL_MAHATO_H */