Home‎ > ‎Assignments‎ > ‎

Multilinked List

Multi-Linked List

A multiply-linked list can be used for maintaining sublists within a larger list of data without having to actually duplicate records or physically store them in separate fiiles. Pointer variables are set up, one for each sublist to be maintained. These are stored within the record structure itself.

Write a program to produce a report listing, separately, all employees holding a particular JobTitle, all employees working in a prticular company Location, and all employees working in a particular Department, for all possible JobTitles, Locations, and Departments. Revise the data contained in the idprsnel.dat file (attached below) before using it as input to your program. The revised employee record (or, node) will have several additional pointer variables for maintaining the lists of interest. In addition, you will neeed the expernal pointers to the beginning of each list, including one for the "master" list of all records in sorted order (by ID number).

The master file is formatted as follows:

   ID#  LNAME  FNAME  MI  STREET  CITY  STATE  ZIP  HOME#  HOME2#  EMERGENCY  TITLE  LOC  DEPT  SAL  PROM  FIRST
 Example:  007511852  BOND  JAMES    122 GOLDFINGER  PERSONTOWN  NY  30022  5133759007    5137486007  CLERK  B  R&D  3124600  0188  1085
ID#: 9 spaces
NAMES: 21 spaces
ADDRESS: 32 spaces
PHONE#S: 30 spaces
JOB TITLE: 8 spaces
LOCATION: 1 space
DEPARTMENT: 5 spaces
ANNUAL SALARY: 7 spaces
LAST PROMOTED: 4 spaces
FIRST EMPLOYED: 4 spaces


Note that you can use the string functions getline and substr as follows (for example):
getline (infile,line);
id = line.substr (0,9);


Alternatively, for a simpler programming project, use the following streamlined data:

007511852 BOND      JAMES      CLERK   B R&D  

018647329 KENT      CLARK      MANAGER B R&D  

027602435 KRAMDEN   ALICE      ANALYST D MIS  

045828304 NORTH     JERRY     DESIGNER D R&D  

048111007 OLSEN     JIMMY      DESIGNER D PROD 

053939677 DREW      NANCY       CLERK   C PROD 

071918464 STEED     JOHN       DESIGNER C PROD 

081956797 WINE      MOSES       ANALYST B MIS  

096283018 CHAMBERS  DIANE     MANAGER C PROD 

097366399 FAWLTY    BASIL       ANALYST A PROD 

098480250 PETERSON  NORM       MANAGER A PROD 

107908321 WHITE     PERRY       MANAGER C PROD 

109094977 HOLCROFT  NOEL        MANAGER B PROD 

117308423 CHARLES   NORA        DESIGNER A PROD 

129275576 RHODENBARR BERNIE     MANAGER C MIS  

144936551 MUDD      HARRY       CLERK   B PROD 

154574105 MAVERICK  BRETT     CLERK   B R&D  

156533413 FLYNN     FRANCIS    DESIGNER B PROD 

164669628 STEELE    REMINGTON  ANALYST B MIS  

165245544 HARDY     FENTON      MANAGER B R&D  

175666707 VADER     DARTH       MANAGER D MIS  

197340858 LANE      LOIS       MANAGER B PROD 

231081163 STREET    DELLA      CLERK   A R&D  

243634844 KEATON    ALEX       CLERK   C MIS  

250141546 CANNON    FRANK       MANAGER C MIS  

265522806 SPENSER   HAWK        MANAGER D R&D  

279319399 HART      JENNIFER    DESIGNER A PROD 

297000324 MASON     PERRY       ANALYST C MIS  

315551263 HOLMES    SHERLOCK    ANALYST D R&D  

336345414 OHARA     SCARLET     MANAGER A R&D  

337510916 WOLFE     NERO        CLERK   A R&D  

351453116 CARTER    NICK        CLERK   D PROD 

358928785 KIRK      JAMES      DESIGNER A PROD 

360475339 CHARLES   NICK        MANAGER B R&D  

373603340 SHAYNE    MIKE       DESIGNER C PROD 

382547177 WEISER    MARION     MANAGER D R&D  

406725718 POIROT    HERCULE     DESIGNER D MIS  

412074985 DIAMOND   RICHARD     CLERK   C R&D  

412122593 FIELDING  DAN         CLERK   D MIS  

422375009 HAVELOCK  MICHAEL      ANALYST D MIS  

426743441 NASHE     HAMILTON   DESIGNER D R&D  

431815949 CARTWRIGHT BEN         DESIGNER B MIS  

434606028 UNGER     FELIX       CLERK   A PROD 

439348245 MAGNUM    THOMAS      DESIGNER D R&D  

454768105 MARTIN    ANGEL       DESIGNER D PROD 

467287118 NORTON    EDWARD      CLERK   B MIS  

498634876 POPPINS   MARY       CLERK   D PROD 

501620748 BUTLER    RHETT       ANALYST B PROD 

513351904 GUNN      PETER       CLERK   D R&D  

513789593 DILLON    MATT        MANAGER B PROD 

519251496 MUNROE    JESSICA     MANAGER A MIS  

525042311 CHAN      CHARLIE    CLERK   C MIS  

525416210 IRONSIDE  ROBERT     DESIGNER A R&D  

532859964 HELM      MATT       CLERK   C R&D  

547247690 DIPALMA   LOUIE       DESIGNER A MIS  

560874087 GOODWIN   ARCHIE      ANALYST A MIS  

575504962 PERRIN    REGINALD   CLERK   B R&D  

583532918 BERGERAC  CYRANO     ANALYST B MIS  

584836738 CARTWRIGHT HOSS        ANALYST A R&D  

594184602 MCMILLAN  SALLY       ANALYST C R&D  

602407060 TEMPLAR   SIMON       DESIGNER C MIS  

606984917 CLOUSSEAU INSPECTOR   ANALYST D MIS  

623541383 HOLMES    MYCROFT     DESIGNER A MIS  

629195747 FLETCHER  IRWIN      MANAGER C R&D  

634950378 TANNER    EVAN        MANAGER D PROD 

671920794 RANDALL   JOSH        ANALYST A R&D  

676865001 ROCKFORD  JAMES      DESIGNER B R&D  

678466125 REAGER    ALEX       CLERK   D PROD 

686944932 MARLOWE   PHILIP      CLERK   B MIS  

739096328 SMALL     DAVID     ANALYST A PROD 

740350623 SCUDDER   MATTHEW     MANAGER D R&D  

742201761 SPADE     SAM        CLERK   D MIS  

744146916 HARRISON  CHIP       ANALYST D PROD 

750855555 WALKER    AMOS        ANALYST B PROD 

751645142  SING      HOP         ANALYST B MIS  

761736932 NORTH     PAM        ANALYST C PROD 

764319959 PEEL      EMMA        ANALYST C MIS  

766688163 QUIXOTE   DON         ANALYST C R&D  

782667746 ED        MISTER     MANAGER B MIS  

783563314 BURKE     AMOS        CLERK   A MIS  

796681101 MCGEE     TRAVIS      DESIGNER D MIS  

812815428 HAMMER    MIKE        CLERK   C MIS  

815520270 WATSON    JOHN      CLERK   A MIS  

847258657 MALONE    SAM         ANALYST C PROD 

853600995 BOURNE    JASON      DESIGNER C MIS  

859673715 ARCHER    LEW        ANALYST A R&D  

875490775 VANCE     PHILO     DESIGNER C R&D  

885034483 SKYWALKER LUKE       CLERK   A R&D  

892369626 BRAGG     PETER       MANAGER D R&D  

897176599 JONES     BARNABY     ANALYST D PROD 

900619229 HOPE      MATTHEW     CLERK   C PROD 

909295632 IGNATOWSKI JIM         MANAGER B MIS  

940476548 DRAKE     JOHN        ANALYST D R&D  

949326445 REDDY     JASON       ANALYST D MIS  

961008182 MARPLE    JANE       MANAGER A R&D  

966456476 MCCOY     LEONARD     MANAGER A PROD 

986141483 CHAMBERS  PAT        ANALYST D PROD 

989000740 TORTELLI  CARLA       ANALYST B R&D  

993610980 MADISON   OSCAR       DESIGNER A MIS  

999410773 KRAMDEN   RALPH       CLERK   C R&D  


Part A:

The first part of this problem involves "creation" of the (logical) sublists as part of the master list. The creation algorithm will use the same ADD procedure that will be used to add new employees to the data set when it is updated.

 

Part B:

The second part of this problem involves updating this master multlinked list. Updates are done when new employees are hired (ADD), when employees leave or are fired (DELETE), and when employees are promoted or transferred to another location and/or department (CHANGE). The updates to be used in testing this program are in the transaction file trans.dat (attached below). To keep things simple, you may assume no errors in the update records.

Use functions, structs, classes, arrays, lists, etc. as appropriate.

 

Your output from this program might look something like this:

Multiple Sublists
Listing for Jobtitle Analyst
----------------------------
027602435 KRAMDEN ALICE
081956797 WINE MOSES
097366399 FAWLTY BASIL
...
...
Multiple Sublists
Listing for Jobtitle Clerk
----------------------------
007511852 BOND JAMES
053939677 DREW NANCY
...
...
Multiple Sublists
Listing for Jobtitle Designer
----------------------------
045828304 NORTH JERRY
048111007 OLSEN JIMMY
...
...
Multiple Sublists
Listing for Jobtitle Manager
----------------------------
018647329 KENT CLARK
096823018 CHAMBERS DIANE
...
...
Multiple Sublists
Listing for Location A
----------------------------
097366399 FAWLTY BASIL
098480250 PETERSON NORM
...
...

 

ċ
idprsnel.dat
(12k)
Linda Weiser Friedman,
Apr 9, 2014, 12:24 PM
ċ
trans.dat
(2k)
Linda Weiser Friedman,
Apr 9, 2014, 12:24 PM
Comments