Hi All,
I was assigned to code a project which to some extend simulates timetable of an airport. This has to be implemented using linkedLists. The poject should consist of Node class and SLL (singly linked list) class. The logic of the project is like this: There should be a clock which ticks every 15 minutes in the main function; I created flight.h file and included all the information related to a flight within. What confuses me here is just some parts of the code related to mergeSort and quickSort.
The project asks to sort all the flights: 1. based on their departure time 2. bases on their departure city.
#include <iostream>
#include <string>
using namespace std;
//
#ifndef FLIGHT_H_
#define FLIGHT_H_
class Node
{
public:
enum flight_status {On_time, Delayed, Departed};
struct Time {int hour, minutes;};
// Default Constructor
Node () {next = NULL;}
string airLine;
int flightNum;
string city;
int gate;
struct Time time;
flight_status status;
Node *next;
};
//
class SLL // Singly Linked List
{
public:
// Default Constructor
SLL()
{
head = new Node;
head = tail = NULL;
size = 0;
}
// member functions
void push();
void print(Node *head);
void split(Node *head, int left, int right);
void mergeSort(Node *head, int left, int mid, int right);
void quickSort(Node *head, int left, int mid, int right);
private:
Node *head, *tail;
int size;
};
//
#endif /* FLIGHT_H_ */
I'm thinking about building the rest of the program on top of this declaration. what I want to make sure about is my approach to solve the sorting problem is good according to this implementation of classes.
Thanks in advance.