Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Simple code for : An airport is developing a computer simulation of air traffic

ID: 3550374 • Letter: S

Question

Simple code for :

An airport is developing a computer simulation of air traffic control that maintains events such as landings and takeoffs. Each event has a time-stamp that denotes the time when the event occurs. Suppose the simulation program needs only to efficiently perform the following two fundamental operations: Insert a new event with a given time-stamp (that is, add a future event) Extract the even with the smallest time-stamp (which is the next event to process) Which data structure would you use for this problem? Justify your answer.

Explanation / Answer

#include<stdio.h> #include<conio.h>
int events[100]; int p=0; void insertevent(int time) { events[p]= time; p = (p%100)+1; } void extractevent() { int j=0,temp; temp =events[j]; while(events[j]) { if(temp>events[j]) temp=events[j];
j++; } printf(" event extracted : %d " ,temp); } void displayevent() { int j= 0; while(events[j]) { printf(" event %d : %d " ,j+1,events[j]); j++; } } int main(void) {
int i,time;
while(true) { printf(" enter appropriate option "); printf("1. CREATE EVENT "); printf("2. INSERT EVENT "); printf("3. EXTRACT EVENT "); printf("4. DISPLAY EVENTS "); printf("5. EXIT ");
scanf("%d",&i); switch (i) { case 1: printf("enter timestamp "); scanf("%d" , &time); break; case 2: insertevent(time); printf("event inserted "); break; case 3 : extractevent(); break; case 4: displayevent(); break; case 5: exit(0); break;
} } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote