sorting technique c/c++

Hello everyone i'm new to this kind of things plz help me to solve this , if anyone can post the c/c++ code also i shall be thankfull to you :)

An eccentric doctor visits his patients in order of decreasing age. Patients entering the waiting list specify not only their names but also their ages. Each time the doctor wants to visit a patient, the oldest is selected and removed from the list (so children may have to wait a very long time). Write a program, based on elementary sorting techniques to sort this list on first on Age and then on Patient ID, which this doctor can use.

[B]Before[/B]

[B]PatientID[/B] [B]Name[/B] [B]Age[/B]
P102 Arif Taj Mairza 50
P203 Sadar Khan 65
P546 Afsheen Bano 34
P605 Kai Whong 45
P340 Hanah Duong 23
P391 Usman Habib 65
P200 Alina Shah 34

[B]After[/B]
[B]PatientID[/B] [B][B]Name[/B][/B] [B]Age[/B]

P203 Sadar Khan 65
P391 Usman Habib 65
P102 Arif Taj Mairza 50
P605 Kai Whong 45
P200 Alina Shah 34
P546 Afsheen Bano 34
P340 Hanah Duong 23



Solve this problem by applying four different elementary sorting techniques that are

a) Selection sort
b) Bubble sort
c) Insertion sort
d) Shell sort

Comments

  • Can you do this using those methods on a simple group of numbers? If so, then you only really need to implement appropriate compare/swap functionality.

    You're not likely to get much help just by posting a set of requirements and then asking for the code.
  • Agreed with the previous poster, that you are not likely to get it all coded up for you.

    It APPEARS to me that your instructor wants you to use an array of structs for this; that is how I would do it, but I don't know if you have even learned about structs yet. If not, you might setup 2 arrays, one a string array containing the patient ID and the patient name, and an int array for the ages. Then write your sort routines where they take 2 arrays, a string array and an int array, and sort these in parallel, first by age in descending order, secondly by the string array in ascending order.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories