Swift 4+ 8. Create priority queue class. The add method added elements to the qu
ID: 3744961 • Letter: S
Question
Swift 4+
8. Create priority queue class. The add method added elements to the queue. The
first method returns the element with the highest priority. The removeFirst removes the
element with the highest priority and returns it. The queue needs to be able to hold Student
structs from problem 7.
Here's question 7 which it's already solved but it's related to this question.
7. Create a Student Struct that contains a name, student id, number of units taken and
GPA. The struct needs one method priority which returns the number of units taken times
the GPA.
We can use .sorted to solve this question and there is no need to implement the heap sort.
Explanation / Answer
#include struct student { char name[50]; int roll; float marks; } s; int main() { printf("Enter information: "); printf("Enter name: "); scanf("%s", s.name); printf("Enter roll number: "); scanf("%d", &s.roll); printf("Enter marks: "); scanf("%f", &s.marks); printf("Displaying Information: "); printf("Name: "); puts(s.name); printf("Roll number: %d ",s.roll); printf("Marks: %.1f ", s.marks); return 0; }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.