Mcqs Unit-3 3 Merged
Mcqs Unit-3 3 Merged
A queue is logically a First-In First-Out (FIFO) type of list. In our day to day life we come across
situations where we have to wait in a line for our turn. A new customer joins the queue from the rear end
whereas the ones who are done with the work leave the queue from the front end. This means that the
customers are attended in the order in which they arrive at the service center. i.e. first come first serve
(FCFS) type of service). This waiting queue is a Queue. Queue means a line. The above mentioned
characteristic applies to a Queue.
An example of a queue can be found in a time-sharing computer system where many users share the
system simultaneously. Since such a system typically has a single central processing unit (called the
processor) and one main memory, these resources must be shared by allowing one user’s program to
execute for a short time, followed by the execution of another user’s program, etc., until there is a return
to the execution of the initial user’s program. The user programs that are waiting to be processed form a
waiting queue. This queue may not strictly operate on a strictly first-in first-out basis, but on some
complex priority scheme based on such factors as what compiler is being used, the execution time
required, the number of print lines desired, etc. The resulting queue is sometimes called a priority queue.
Suppose that at a service center, t1 units of time is needed to provide a service to a single customer and
on an average a new customer arrives at service center in t2 units of time. Then there are following
possibilities that may arise:
1. If t1<t2 then the service counter will be free for some time before a new customer arrives at the
service counter. Hence there will be no customer standing at a particular time in the queue, or the
queue will be empty.
2. If t1>t2 then the service counter will be busy for some time even after the arrival of a new
customer. Therefore the new customers have to wait for some time. This procedure when
continues for some time gives rise to a queue.
3. If t1=t2 then as one customer leaves the counter other will arrive at the same instant, hence queue
will be single element long.
Stage-1
F/R=-1 0 1 2 3 4
Stage-2 5
F/R=-0 0 1 2 3 4
Stage-3 5 9
0 1 2 3 4
F=0 R=1
Stage-4 5 9 3
0 1 2 3 4
F=0 R=2
Stage-5 5 9 3 7
0 1 2 3 4
F=0 R=3
It is clear from the above example that whenever we insert an element in the queue, the value of REAR
is incremented by one i.e. Rear=Rear+1
Only during the insertion of the first element in the queue, we will always increment the FRONT by one
i.e. Front=Front+1. Thereafter the FRONT will not be changed during the entire addition operation.
Hence two pointers namely FRONT and REAR are used to indicate the two ends of the queue. For the
insertion of the next element, the pointer REAR will be the consultant and for deletion the pointer
FRONT will be the consultant.
Stage-1 5 9 3 7
0 1 2 3 4
F=0 R=3
Stage-2 9 3 7
0 1 2 3 4
F=1 R=3
Stage-3 3 7
0 1 2 3 4
F=2 R=3
Stage-4 7
0 1 2 3 4
F=3
R=3
Stage-5
F/R=-1 0 1 2 3 4
Implementation of Queue:
Queues can be implemented in two ways:
1. Static implementation using Arrays
2. Dynamic implementation using Pointers
If Queue is implemented using Arrays, we must be sure about the exact number of elements we want to
store in the Queue, because we have to declare the size of the array at design time or before the
processing starts. In this case, the beginning of the array will become the FRONT and the last location of
the array will be REAR for the queue. The total number of elements will be calculated as
FRONT-REAR+1
If Queue is implemented using pointers, the main disadvantage is that a node in a linked representation
occupies more memory space than a corresponding element in the array representation. The reason is
that there are at least two fields in each node, the data field and a field to store the address of next node
in the linked list. Whereas in an Array, only data field is there. It must be understood that the memory
space occupied by a node in a linked representation is not exactly twice the space used by an element of
array representation. The advantage is linked representation makes an effective utilization of memory.
Another advantage would be when an element is needed to be inserted/deleted from in between two
elements. In case of arrays, insertion/deletion in between two elements will require to shift the elements.
Also there is no space restriction with linked representation compared to Arrays where a fixed number
of elements are allowed.
Hence linked representation allows us to stress on our primary aim i.e. addition or deletion and not on
the overheads related to these processes, So the amount of work required is independent of the size of
the list.
For a linked representation, the addition of new node requires creating a new node, inserting in the
required position by adjusting two pointers and deletion requires adjusting pointers and pointing the
node to be deleted and free it.
Operations on a Queue:
There are two basic operations that can be performed on a Queue:
1. Insert an element in a Queue
2. Delete an element from the Queue
CIRCULAR QUEUE
A circular queue is one in which the insertion of a new element is put at the very first location of the
queue if the last location of the queue is full. In other words if we have a queue Q of n elements, then
after inserting an element last i.e. in the n-1th location of the array, the next element will be inserted at
the very first location i.e. location with subscript 0 of the array. It is possible to insert new elements if
and only if those locations are empty. A circular queue is one in which the first element comes just after
the last element. This technique essentially allows the queue to wrap around upon reaching the end of
the array. It can be viewed as a mesh or loop of wire, in which the two ends of the wire are connected
together. The circular queue is implemented by visualizing the one-dimensional array as circular queue.
A circular queue overcomes the problem of unutilized space in linear queues implemented as arrays. A
circular queue also has a Front and Rear to keep the track of the elements to be deleted and inserted and
therefore to maintain the unique characteristic of the queue. The following assumptions are made:
Fig. 1
1. Front will always be pointing to the first element (as in the linear queue)
2. If Front = Rear the queue will be empty
3. Each time a new element is inserted into the queue, the Rear is incremented by one.
Rear=Rear+1
4. Each time an element is deleted from the queue the value of Front is incremented by one.
Front=Front+1
Front Rear
deletion insertion
10 20 30 40 50
insertion deletion
Dq[0] Dq[1] Dq[2] Dq[3] Dq[4]
Since both insertion and deletion are performed from either end, it is necessary to design an algorithm to
perform the following four operations:
1. Insertion of an element at the Rear end of the queue
2. Deletion of an element From the Front end of the queue
3. Insertion of an element at the Front end of the queue
4. Deletion of an element from the Rear end of the queue
For an input-restricted deque only the operations specified in 1, 2, 3 and 4 are valid.
For an output-restricted deque only the operations specified in 1, 2 and 3 are valid.
Priority Queues
A priority queue is a collection of elements such that each element has been assigned a priority and the
order in which elements are deleted and processed comes from the following rules:
1. An element of higher priority is processed before any element of lower priority
2. Two elements with the same priority are processed according to the order in which they were
added to the queue
A queue in which we are able to insert items or remove items from any position based on some property
(such as priority of the task to be processed) is often referred to as a priority queue.
A prototype of priority is processed first, and programs with the same priority form a standard Queue.
Insertions in a Priority Queue need not occur at the absolute rear of the queue. Hence it is clear that an
array implementation may require moving a substantial number of data when an item is inserted at the
rear of one of the higher priorities. To avoid this, you can use a linked list to great advantage when
implementing a priority queue.
A collection of items into which items can be inserted arbitrarily and from which only the smallest item
can be removed is called Ascending Priority Queue.
In Descending Priority Queue only the largest item is deleted. The elements of Priority Queue need not
be numbers or characters that can be composed directly. They may be complex structures that are
ordered by one or several fields. Sometimes the field on which the element of a Priority Queue is
ordered is not even part of the elements themselves.
The Priority Queue is a data structure in which intrinsic ordering of the elements determines the result of
its basic operations.
An Ascending Priority Queue is a collection of items into which items can be inserted arbitrarily and
from which only the smallest item can be removed. On the other hand a Descending Priority Queue
allows only the largest item to be removed.
Insertion: The insertion in Priority Queues is the same as in non-priority queues.
Deletion: Deletion requires a search for the element of highest priority and deletes the element with
highest priority. The following methods can be used for deletion/removal from a given Priority Queue:
● An empty indicator replaces deleted elements
● After each deletion, elements can be moved up in the array decrementing the Rear
● The array in the queue can be maintained as an ordered circular array
Applications of Queues
1. Round robin technique for processor scheduling is implemented using queues.
2. All types of customer services (like railway ticket reservation) center software are designed
using queues to store and service customers information.
3. Printer server routines are designed using queues. A number of users share a printer using printer
server
Shree P.M.Patel College of Computer Science & Technology, Anand
BCA Semester-III
US03CBCA27 – System Analysis and Design
Unit-3
Input / Output Design and Fact Gathering Techniques
Reference Book : System Analysis and Design (S.Parthasarathy, B.W. Khalkar)
Input Design:
• Input design involves capturing (Catching) of data and inputting it to the computer.
• Input design consists,
1) Data capture
2) Data validation
1. Original Recording: This is the collection of data at its source. This involves clerical
preparation of source documents including manual checks.
For example: preparing an examination mark sheet.
2. Data Transmission: The data moves from the point of origin to the data processing center.
For example: the group of related mark list are bunched into batches and sent to data
processing center.
3. Data Preparation: The transcription (Record) of source document on to an input media
such as magnetic tape, magnetic disk etc is data preparation.
For example: in the offline system the transfer of data from mark list to magnetic floppy
disk is the case of data preparation.
4. Data Verification: It is a verification of transcription (Record), has been done correctly.
This is vital (essential) because if it can mislead, it can result in wrong output.
5. Sorting: Sorting is the process of arranging data into some desired sequence. Sorting may
be done manually or mechanically.
6. Control: Throughout all the stages listed above it is essential that checking, verifying and
validity controls are maintained. This is to ensure that all the data collected, transmitted
and input are correct.
7. Computer Input: The data is read by the input device like magnetic disk drive and
transferred to the internal store where it undergoes validity checks. Invalid data will pass
back to go through the entry stages again.
Data Validation:
• The objective of a data validation system is to detect errors at the earliest possible stage before
costly activities are performed on invalid data. Some data validation is done by way of manual
verification in data capture stage itself.
• In spite of this, still there may be incorrect batches of input data, missing data, duplicate data
and incorrect file records etc. It is necessary that before data is first input to the computer for
processing different checks are carried out.
• This check will classify valid and invalid data.
• This is generally done with the help of a DATA VET program. This is often referred to as DATA
VELIDATION Or DATA VET.
Validation Checks:
There are various categories of checks which can be applied to during a validation run.
A) Field Check: includes the following
1) Limit check: May be applied to each field (data item) of a record to ensure that its content
lie within predefined size. (For Example: the amount of salary can be form 00000.00 to
15000.00 for an employee. If the amount is beyond these limits then further corrections
becomes necessary.)
2) Picture check: May be applied to each field to detect entry of incorrect characters in the
field. (For Example: PIC of employ-no is AAA 9999. an EMPLOY-NO PRD24NG would be
rejected as there is a letter in the sixth position and this should be only numeric)
3) Valid code check: To validate input against predefined transaction codes. These predefined
codes may either be embedded in the programs or stored in files. (For Example: Contents
EMPLOYEE-CATEGORY field A, B, C, D, E are only valid and any other letter coming inthat
field will be rejected)
4) Check digit: It is used to detect transposition errors when recording “key” fields.
(For Example: 54786 is entered as 54768)
5) Arithmetic checks: It is used to ensure the validity of the results by performing arithmetic
operations in different ways.
6) Cross checks: It may be applied to verify fields appearing in different files to verify that
result fully.
Design of Output:
What is Design Output?
• The output generally refers to the result and information that are generated by the system.
• One of the most important features of an information system from the point of view of user is the
output it produces.
• If the output is of poor quality, the whole system is in peril (danger) because the users will then
avoid using it. Hence, the design of output assumes greater importance.
• In any system the output is largely dependent on input.
Output Objectives:
• Before designing output, the objectives of the output must be clear.
• The output reports are the attractive format and are produced by using latest technology.
• It must accomplish one or more of the following objectives.
An output must,
1) Convey information about
a. Past activity like personnel file, vendor history.
b. Current status like inventory on hand, cash on hand.
c. Future projections like sales or cost of manufacturing a new item.
2) Confirm task
It is used to know about the current status of given task.
3) Trigger an alarm
It is used whenever the market loss is there.
4) Signal Events
With the report provide the information lurking opportunities.
Types of Output:
There are various output required by most systems. The main types of output are as below:
1) External outputs: The report which are used outside the user’s organization. E.g.
Invoices Pay slips Tax returns etc.
2) Internal outputs: The output report used within the user’s organization.
e.g Inventory Report.
Output Considerations:
While designing output systems analyst must consider the following points:
1) Determine what information is to be present.
2) Decide whether to display, print the information and select the output medium.
3) Arrange the presentation of information in acceptable form.
4) Decide how to distribute the output to users.
Output Media:
There are different types of output media like
1) Printed output: The devise use for printed output may be line printer, dot matrix
printer, laser printer.
2) Visual outputs: Sometimes it is necessary used to show the output to the user through
the devices which can used CRT (Cathode Ray Tube).
For example, Airline and Hotel Reservation System.
3) Turnaround Document output: Based on the one created report decisions are taken
for the next report. E.g employee time cards.
4) Secondary storage output: The reports which are provided through magnetic disk,
magnetic tape.
5) Microfilm output: Microfilms are photographically reduced documents on films. Here
output is return on to the magnetic tape which is then fed into a machine called
Microform recorder.
6) Audio Response Outputs: Sometimes it is necessary to provide the output in the form
of sound. E.g. In the banking system customers can get balance in their accounts.
Advantages of Interview:
• Face to face Communication, many things are reveal through eye contacts and body
gesture.
• Quick response and collection of sufficient primary information
• Selection based process so less costly
• The questionnaires and forms can be filled at the time of interviews if so desired.
Disadvantages of Interview:
• No record maintenance
• Incomplete process
• Lack of attention
• Time consuming and costly
• Possibilities of biasness of Interviewer
• Not suitable for personal matters and may worse result if Interviewer has insufficient
knowledge of the matter or related subjects
2. Questionnaires:
• Questionnaires may be used as a supplement (enhancement) to interviews.
• More people can be reached and answers can be corroborated.
• The questionnaires can have open ended question like – what is the average value of
invoice in your department?
a) Less than Rs. 3000
b) Rs. 3000 to Rs. 5000
c) Rs. 5000 to Rs. 10000
d) Rs. 10000 and above.
• A respondent are selected carefully, and received responses are analyzed very carefully
without any bias
• A questionnaire can be considered as a structured interview form.
• Since the cost involved in developing and distributing is very high,
• The following points must be kept in mind while designing questionnaires:
1. The objective of the questionnaire must be clear.
2. The structure must be useful for the study.
3. Question must be easily and unambiguously understood.
Disadvantages of Questionnaire:
• Possibilities of dishonest answers
• Non-attempting of questions and interpretation problems
• Analysis issue
• Survey fatigue
• Accessibility issue
• Lack of Personalization
4. Observation:
• An analyst must always keep themselves alert
• Observation can bring in missed facts; new ways to improve the existing procedures,
duplicate work done in inadvertently etc.
• Observation can bring in what other fact finding methods cannot!
• This task is delicate because people do not like to be observed when they work.
Advantages of Observation:
• Simple and Universal method.
• Great accuracy in data collection
• Suitable tool in specific conditions like, collection of data from dumb, shy, illiterate person or
for whom those who does not understand the language of researchers.
• Very direct method for collecting data or information – best for the study of human
behavior.
• Data collected is very accurate in nature and also very reliable.
• Improves precision of the research results.
Disadvantages of Observation:
• Problems of the past cannot be studied by means of observation.
• Having no other option one has to depend on the documents available.
• Observations like the controlled observations require some especial instruments or tools for
effective working, which are very much costly
• One cannot study opinions by this means.
• Attitudes cannot be studied with the help of observations.
• Sampling cannot be brought into use.
• Time Consuming
• Complete answer to any problem or any issue cannot be obtained by observation alone.
Note:
This material is prepared for study purpose only. For detail study student have to refer
reference books.