applicaiton problems-dfs using c

6
Sri Manakula vinayagar Engineering College Department of MCA I Year / I Semester MCA Data File Structures using C Lab Problem 1 The Bashemin parking Garage contains a single lane that holds up to ten cars. There is only a single entrance/exit to the garage at one end of the lane. If a customer arrives to pick up a car that is not nearest the exit, all cars blocking its path are moved out; the customer's cars driven out, and the other cars are restored in the same order that they were in originally. Write a program that processes a group of input lines. Each input line contains an 'A' for arrival or a 'D' for departure, and a license plate number. Cars are assumed to arrive and depart in the order specified by the input. The program should print a message whenever a car arrives or departs. When a car arrives, the message should specify whether or not there is room for the car in the garage. If there is no room, the car leaves without entering the garage. When a car departs, the message should include the number of times that the car was moved out of the garage to allow other cars to depart. Display the result including the details of car number, number of times moved out from the Garage, arrival time, departure time, time taken by the each car while it was in the Garage in a table form.

Upload: sakthi-vel

Post on 29-Nov-2014

198 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Applicaiton Problems-DFS Using C

Sri Manakula vinayagar Engineering College

Department of MCA

I Year / I Semester MCA Data File Structures using C Lab

Problem 1

The Bashemin parking Garage contains a single lane that holds up to ten cars.

There is only a single entrance/exit to the garage at one end of the lane. If a customer

arrives to pick up a car that is not nearest the exit, all cars blocking its path are moved

out; the customer's cars driven out, and the other cars are restored in the same order

that they were in originally.

Write a program that processes a group of input lines. Each input line contains

an 'A' for arrival or a 'D' for departure, and a license plate number. Cars are assumed

to arrive and depart in the order specified by the input. The program should print a

message whenever a car arrives or departs. When a car arrives, the message should

specify whether or not there is room for the car in the garage. If there is no room, the

car leaves without entering the garage. When a car departs, the message should

include the number of times that the car was moved out of the garage to allow other

cars to depart. Display the result including the details of car number, number of times

moved out from the Garage, arrival time, departure time, time taken by the each car

while it was in the Garage in a table form.

Problem 2

Scratchemup Parking Garage contains a single lane that holds up to ten cars.

Cars arrive at the south end of the garage and leave from the north end. If a customer

arrives to pick up a car that is not northern most, all cars all cars to the north of the

car are moved out, the cars driven out, and the other cars are restored in the same

order that they were in originally. Whenever a car leaves, all cars to the south are

moved forward so that at all times all the empty spaces are in the south part of the

garage.

Write a program that reads a group of input lines. Each line contains an 'A' for

arrival or a 'D' for departure, and a license plate number. Cars are assumed to arrive

and depart in the order specified by the input. The program should print a message

whenever a car arrives or departs. When a car arrives, the message should specify

Page 2: Applicaiton Problems-DFS Using C

whether or not there is a room for the car in the garage. If there is no room, the car

leaves without entering the garage. When a car departs, the message should include

the number of times that the car was moved out of the garage to allow other cars to

depart. Display the result including the details of car number, number of times moved

out from the Garage, arrival time, departure time, time taken by the each car while it

was in the Garage in a table form.

Problem 3

SINGLE LINKED LIST

Student admission systems using single linked list.

A student database contains maximum of 60 students. Students those who are

admitted are added in the list in an alphabetical order. Perform the following

operations using single linked list.

a. Construct a linear list by accepting the students’ details like register number,

name, age, sex, qualification etc.,

b. New student will be accepted and admitted anywhere (begin, middle or end) in

the list, so that the number of students should not exceed more than 60. After

each operation; list should be in the alphabetical order.

c. Deleting a student from the list can be performed anywhere (begin, middle or

end) in the list and after the operation the list should always in alphabetical

order.

d. Display the result contains the details of register number, name, age, sex,

qualification etc., in a tabular form and also give the details of the total number

of students admitted in the class, number of new students added & deleted in

the list.

Problem 4

Consider a restaurant having one general and another family dining hall with a

capacity of 50 and 20 respectively. The numbers of tables with sitting capacities in each

section are given below:

General Hall Family Hall

8 seaters 2 Nos. 6 seaters 1 No

6 seaters 2 Nos 4 seaters 3 No

Page 3: Applicaiton Problems-DFS Using C

4 seaters 3 Nos 2 seaters 1 No

2 seaters 5 Nos

Design and Develop an algorithm (or write a program) for the arrival of

customers at dinning, bill paying and departure.

Consider, there are 5 waiters who have to serve all the incoming customers, 4

washbasins and 1 bill paying counter. Generate the customers’ arrival time, the

number of customers arriving (whether family or individual or group) randomly. Take

appropriate time for dining, washing and bill payment. A family with maximum of 6

members and a group with maximum 8 members only can arrive. You are not suppose

to accommodate a group of family in different tables and can be given the nearest

maximum capacity table (say a group of 5 should only be given a 6 seaters table). In

all other situations the customers has to wait. Let the algorithm/program terminate

after serving 300 customers.

Problem 5

In a double-sided engine passenger’s train contain 10 compartments. Maximum

of 10 passengers are allowed to sit in each compartment and they are allowed to

choose the nearest compartment by accessing through either side of the engine. Read

the following conditions and write a ‘C’ program by using the suitable data structure.

(1) Less than 10 passengers in a particular compartment can be filled by the arrival of

new passengers but not more than 10 passengers are allowed to sit. Allow the

passengers to choose the nearest compartment if there is no enough space to sit in

the available one.

(2) If the number of passengers are more, than adding a new compartment anywhere

between the two engines are allowed to satisfy the passengers’ convenience.

(3) If no passengers are available than remove the particular compartment and make a

proper link to continue the journey.

(4) Allow the passengers to get down or get into any of these compartments at the

stoppages.

Page 4: Applicaiton Problems-DFS Using C

(5) List the number of passengers traveled in each compartment at the end of the

journey.

Problem 6

In a library management system contains the details of title of the book, accession no,

author name, cost of the book and date of purchase. Read the following conditions

and write a ‘C’ program by using the suitable data structure.

1. Arrange the books in alphabetical order and you are allowed to access the books

either by using accession number or by title of the book. The students are allowed to

search and take the book in either of the direction.

2. Purchase of new book will take the accession number followed by the previous

accession number and it will be placed only at the last place (No two books should

have the same accession number).

3. The books returned by the student can be inserted any where in the order either by

using the title of the book or by using accession number.

4. Students are allowed to take the books anywhere in the order but there should not

be any gape between the two books.

5. List the number of books issued on that particular date providing the details of

student name, accession number, title of the book, author name and cost of the book.