WWW.VIRTUALeMEDIA.COM

CONTACT US  |  HOMEPAGE

VIRTUALeMEDIA                   SOFTWARE ENGINEERING
CLOTHING  ::  ELECTRONICS  ::  HARDWARE  ::  GIFTS  ::  BOOKS  ::  FINANCE  ::  SOFTWARE  ::  EMPLOYMENT ::   VIRTUAL OFFICES
COOL STUFF

AUDIO

COMPUTERS

NETWORKS

PDAs

SUPPLIES

TELEVISIONS

WIRELESS

TECHNOLOGY

ARTICLES

HARDWARE

SOFTWARE

PROGRAMMING

WEBMARKETING

WIRELESS


LINKS

 
 

FREELANCING

VIRTUALeOFFICES

TRADELINKS

 

GEMINISOFTWARE

 

 

 

 

 

 

 

Allume Systems Software     Record Streaming Video. CLICK HERE!          SnapDialer: use cellphone to connect PC to the web     GEAR CD/DVD Burning Software     

_________________________________________________________________________________________

LearnKey Training

___________________

 

Welcome to our website

 

{$U+,R+}


program trees(input,output,infile);


type
infotype = string[15];

ptrtype = ^nodetype;

nodetype = record
info : infotype;
left,right : ptrtype
end;


var
root : ptrtype;
student : infotype;
infile : text;
i : integer;
flag : boolean;

{********************************************************************}

procedure findandkill(var root : ptrtype; student : infotype);

var
back,p : ptrtype;

{--------------------------------------------------------------------}



procedure deletenode(var p : ptrtype);

var back, temp : ptrtype;

begin { deletenode }

temp := p;

if p^.right = nil then
p := p^.left

else

if p^.left = nil then
p := p^.right

else

begin
temp := p^.left;
back := p;

while temp^.right <> nil do
begin
back := temp;
temp := temp^.right
end; { While }

p^.info := temp^.info;

if back = p then
back^.left := temp^.left
else
back^.right := temp^.left
end;

dispose(temp)

end; { deletenode }


{--------------------------------------------------------------------}

begin { Findandkill }
p := root;
back := nil;
while p^.info <> student do
begin
back := p;
if p^.info > student then
p := p^.left
else
p := p^.right
end;
if p = root then
deletenode(root)
else
if back^.left = p then
deletenode(back^.left)
else
deletenode(back^.right)
end; { Findandkill }


{********************************************************************}


procedure insert(var root : ptrtype; var student : infotype);

var
newnode, p, back : ptrtype;


begin { Insert }
new(newnode); { Add new node. }
newnode^.left := nil; { Set pointer fields }
newnode^.right := nil; { to null. }
newnode^.info := student;
p := root; { Initialize pointers. }
back := nil; { *note: back connects the new node* }

while p <> nil do { When p = null, the insertion point }
begin { has been found. }
back := p; { Back catches up. }
if p^.info > student then { Advance p. }
p := p^.left
else
p := p^.right
end;

if back = nil then { If tree empty, then insert the }
root := newnode { first node.}
else { Attach new node to node(back). }
if back^.info > student then
back^.left := newnode
else
back^.right := newnode

end; { Insert }


{********************************************************************}



{********************************************************************}


procedure readfile(var infile : text; var student : infotype);

const blank = ' ';

var
astudent : string[55];
fname1,lname1,fname2,lname2,
i,blanks : integer;
lastname,firstname : infotype;


begin { Readfile }
blanks := 0;
i := 0;
readln(infile,astudent);
writeln(astudent);
fname1 := 6; { Name is found 6 spaces over. }

while blanks < 3 do
begin
i := i + 1;
if astudent[i] = blank then
begin
blanks := blanks + 1;
if blanks = 2 then
begin
lname1 := i - fname1;
fname2 := i + 1;
end
end; { If }
end; { while }
lname2 := i - fname2;
firstname := copy(astudent,fname1,lname1);
lastname := copy(astudent,fname2,lname2);
student := concat(lastname,',',firstname)
end;


{********************************************************************}

procedure printinorder(p : ptrtype);

begin { printinorder }
if p <> nil then
begin
printinorder(p^.left);
writeln(p^.info);
printinorder(p^.right)
end
end;

{********************************************************************}

begin { Main }
assign(infile,'lab4.dat');
reset(infile);
root := nil;
clrscr;
for i := 1 to 12 do
begin
readfile(infile,student);
insert(root,student)
end;
writeln;
writeln('Press enter to continue . .');
readln;
clrscr;
printinorder(root);
writeln;
writeln('Press enter to continue . .');
readln;
clrscr;
flag := false;

while not flag do
begin
write('Name of student to delete?');
writeln(' Press X to exit');
readln(student);
clrscr;
if student <> 'X' then
begin
findandkill(root,student);
printinorder(root);
writeln
end
else
if student = 'X' then
flag := true
end; { While }

close(infile);
end. { Main }

DATAFILE: LAB4.DAT

1235 Sam Smith 2.75 CS CS208 SOC100 EH205
3251 Mary Blake 3.32 MA MA251 MA 244
8724 Bob Williams 1.99 BYS BYS113 MA 154 COM113 EH 205
7765 Christine White 3.45 CSCS 308 CS209
2395 Richard Smith 3.87 PY PY100 EH102 HY102
1818 Debbie Blake 3.1 CS CS214 CS208 MA244 HY102
4905 Dick Brown 2.75 CH CH121 CH125 MA154
3875 Sue Jones 2.50 CS CS214
7788 Chris Christen 2.15 MA CS108 MA154 EH205
2947 Mike Smith 3.16 CH PY100 EH205 FH201
2325 Lane Mosley 3.25 PY CH121 CH124
4128 Missy Valves 2.78 BYS MA244 MA251 CS309

 

_________________________________________________________________________________________

 

 

 

 

 

 

About Us

Content provided by VirtualeCorporation

 
 

 

 

Google

GeminiSoftwareSystems     GeminiMalls     GeminiMagazine     TradeLinks

VirtualeCatalog     VirtualeCorporation     VirtualeDirectory     VirtualeJobs     VirtualeMedia     VirtualeOffices

_______________________________________________________________________________________

Give to Charities Click Here!

Michael J. Fox Parkinson's Website Click Here!

__________________________________________

Software including hosting, websites, graphics, development, office, security..Click Here!

 

________________________________________________________________________________________

Save up to 75% on software     CoffeeCup Software     GoToMyPC - Access Your PC From Anywhere     Students software at 50% off!     Get New Emoticons     www.ITCFonts.com

 

Buy Online at Autodesk

"Internet Security Systems' BlackICE Protection Products"

 Need to create a business plan now? Get OfficeReady Business Plans

 Kaspersky Anti-Virus Products

 Free Shipping when you spend $100 on Macromedia.com

 Convert paper and PDF into Documents you can edit, share and archive - Buy OmniPage Pro from ScanSoft.

 Broderbund Bargain Bin - All Titles Under $9.99! Plus FREE shipping with orders over $20!

GameFly® Video Game Rentals - Free Trial          Free Stuff     Aces High 88 Button          

_____________________

Simpson's Monopoly

 

 

 

Google

 

 

 

 

© COPYRIGHT 2002 ALL RIGHTS RESERVED YOURDOMAIN.COM

CLOTHING  ::  ELECTRONICS  ::  HARDWARE  ::  GIFTS  ::  BOOKS  ::  FINANCE  ::  SOFTWARE  ::  EMPLOYMENT     VIRTUAL OFFICES