Professional Documents
Culture Documents
2.)
3.)
4.)
ofstream
fstream
filebuf
5.)
fstreambase
(c.) #include<conio.h>
#include<fstream.h>
int main()
{
ofstream fout(info) ;
stream fout
char name[30], ch ;
int marks ;
fin.get(name,30) ;
//read name from info file
fin.get(ch) ;
//empty buffer
fin >>marks ;
//read marks from info file
fin.get(ch) ;
cout<<Name: <<name ;
//display contents of file
info
cout<<Marks: <<marks ;
fin.close() ;
//close the file
return 0;
}
----------------------------------------------------------------------------------------------
Q2. Write down the algorithm for BFS and DFS and dry
run it for the below mentioned graph.
Empty Queue is Q.
Now status of Queue Q is Q ={A}
// {=front of
queue and }=back
of queue
In given graph vertex dequeued is A and vertices
joining A are B,D,G
Now Q={B,D,G} Visited vertices :- A
NOW vertex dequeued =B Q={D,G,E,F} Visited
vertices :- A,B
THEN vertex dequeued =D Q={G,E,F} Visited
vertices :- A,B,D
THEN vertex dequeued =G Q={E,F} Visited vertices
:- A,B,D,G
THEN vertex dequeued =E Q={F} Visited vertices :A,B,D,G,E
THEN vertex dequeued =F Q={C} Visited vertices :A,B,D,G,E,F
THEN vertex dequeued =C Q={H} Visited vertices :A,B,D,G,E,F,C
THEN vertex dequeued =H Q={} Visited vertices :A,B,D,G,E,F,C,H
Queue is empty exiting.
5.)
Exit
------------------------------------------------------------------------------------------------------------