0% found this document useful (0 votes)
65 views

Unit III Foc

The document discusses planning computer programs through problem solving. It explains the four main stages of problem solving as understanding the problem, analyzing the problem, developing a solution, and coding and implementation. For each stage, it provides details on the goals and processes. It also includes examples to illustrate understanding a problem of calculating average grades and developing an algorithm to display grades. The document further discusses algorithms, their characteristics, data flow, and provides an example algorithm for adding two numbers. Finally, it covers pseudocode, its definition and benefits for planning programs without strict syntax.

Uploaded by

bala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

Unit III Foc

The document discusses planning computer programs through problem solving. It explains the four main stages of problem solving as understanding the problem, analyzing the problem, developing a solution, and coding and implementation. For each stage, it provides details on the goals and processes. It also includes examples to illustrate understanding a problem of calculating average grades and developing an algorithm to display grades. The document further discusses algorithms, their characteristics, data flow, and provides an example algorithm for adding two numbers. Finally, it covers pseudocode, its definition and benefits for planning programs without strict syntax.

Uploaded by

bala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

UNIT – III

PROBLEM SOLVING AND OS BASICS

PLANNING A COMPUTER PROGRAM:

 A computer is a very powerful and versatile machine capable of performing a multitude


of different tasks, yet it has no intelligence or thinking power.
 In order to instruct a computer correctly, the user must have clear understanding of the
problem to be solved.

 In order to solve a problem by the computer, one has to pass though certain stages or
steps. They are

1. Understanding the problem

2. Analyzing the problem

3. Developing the solution

4. Coding and implementation.

1. Understanding the problem: Here we try to understand the problem to be solved in totally.
Before going to the next stage or step, we should be absolutely sure about the objectives of the
given problem.

Understanding the problem can be easily understood with the help of following Example:

Calculate the average grade for all students in a class.

You need to know:


 What input data/information is available ?
 What does it represent ?
 What format is it in ?
 Is anything missing ?
 Do I have everything that I need ?
 What output information am I trying to produce ?
 What do I want the result to look like … text, a picture, a graph … ?
 What am I going to have to compute ?

2. Analyzing the problem: After understanding thoroughly the problem to be solved, we look
different ways of solving the problem and evaluate each solution. The idea here is to search an
appropriate solution to the problem under consideration. The end result of this stage is a broad
overview of the sequence of operations that are to be carries out to solve the given problem. This
step can be understood with following example

In our example, we are going to compute the average of the incoming grades. So, we need to
know the model (or formula) for computing the average of a bunch of numbers. If there is no
such “formula”, we need to develop one. Often, however, the problem breaks down into simple
computations that we can understand easily.
3. Developing the solution: Here the overview of the sequence of operations that was the result
of analysis stage is expanded to form a detailed step by step solution to the problem under
consideration. This is done with the help of algorithm, pseudo code and flowcharts.
Here we have shown the use of algorithm for problem designing. An algorithm is a precise
sequence of instructions for solving a problem.

Example :

Algorithm: DisplayGrades

1. set the sum of the grade values to 0.


2. load all grades x1 … xn from file.
3. repeat n times {
4. get grade xi
5. add xi to the sum
}
6. compute the average to be sum / n.
7. print the average.

4. Coding and implementation: The last stage of the problem solving is the conversion of the
detailed sequence of operations into a language that the computer can understand. Here each step
is converted to its equivalent instruction or instructions in the computer language that has been
chosen for the implantation.

We now have to transform the algorithm from step 3 into a set of instructions that can be
understood by the computer. Writing a program is often called "writing code" or“implementing
an algorithm”. So the code (or source code) is actually the program itself. Without much of an
explanation, below is a program (written in processing) that implements our algorithm for
finding the average of a set of grades. Notice that the code looks quite similar in structure,
however, the processing code is less readable and seems somewhat more mathematical:
int sum = 0;

byte[] x = loadBytes("numbers");
for (int i=0; i<x.length; i++)

sum = sum + x[i];


int avg = sum / x.length;

print(avg);

/* code to find the average */


After coding, the source code is converted into machine code with the help of specialized
software : interpreters and compilers
ALGORITHMS:
What is an Algorithm?

An algorithm is a process or a set of rules required to perform calculations or some other problem-solving
operations especially by a computer. The formal definition of an algorithm is that it contains the finite set
of instructions which are being carried in a specific order to perform the specific task. It is not the
complete program or code; it is just a solution (logic) of a problem, which can be represented either as an
informal description using a Flowchart or Pseudocode.

Characteristics of an Algorithm

The following are the characteristics of an algorithm:

o Input: An algorithm has some input values. We can pass 0 or some input value to an algorithm.
o Output: We will get 1 or more output at the end of an algorithm.
o Unambiguity: An algorithm should be unambiguous which means that the instructions in an
algorithm should be clear and simple.
o Finiteness: An algorithm should have finiteness. Here, finiteness means that the algorithm should
contain a limited number of instructions, i.e., the instructions should be countable.
o Effectiveness: An algorithm should be effective as each instruction in an algorithm affects the
overall process.
o Language independent: An algorithm must be language-independent so that the instructions in an
algorithm can be implemented in any of the languages with the same output.

Dataflow of an Algorithm
o Problem: A problem can be a real-world problem or any instance from the real-world problem for
which we need to create a program or the set of instructions. The set of instructions is known as an
algorithm.
o Algorithm: An algorithm will be designed for a problem which is a step by step procedure.
o Input: After designing an algorithm, the required and the desired inputs are provided to the
algorithm.
o Processing unit: The input will be given to the processing unit, and the processing unit will
produce the desired output.
o Output: The output is the outcome or the result of the program.

Why do we need Algorithms?

We need algorithms because of the following reasons:

o Scalability: It helps us to understand the scalability. When we have a big real-world problem, we
need to scale it down into small-small steps to easily analyze the problem.
o Performance: The real-world is not easily broken down into smaller steps. If the problem can be
easily broken into smaller steps means that the problem is feasible.

Let's understand the algorithm through a real-world example. Suppose we want to make a lemon juice, so
following are the steps required to make a lemon juice:

Step 1: First, we will cut the lemon into half.

Step 2: Squeeze the lemon as much you can and take out its juice in a container.

Step 3: Add two tablespoon sugar in it.

Step 4: Stir the container until the sugar gets dissolved.

Step 5: When sugar gets dissolved, add some water and ice in it.

Step 6: Store the juice in a fridge for 5 to minutes.

Step 7: Now, it's ready to drink.

The above real-world can be directly compared to the definition of the algorithm. We cannot perform the
step 3 before the step 2, we need to follow the specific order to make lemon juice. An algorithm also says
that each and every instruction should be followed in a specific order to perform a specific task.

Now we will look an example of an algorithm in programming.

We will write an algorithm to add two numbers entered by the user.

The following are the steps required to add two numbers entered by the user:

Step 1: Start

Step 2: Declare three variables a, b, and sum.

Step 3: Enter the values of a and b.

Step 4: Add the values of a and b and store the result in the sum variable, i.e., sum=a+b.

Step 5: Print sum

Step 6: Stop

PSEUDOCODE:
What is Pseudocode?
Pseudocode literally means ‘fake code’. It is an informal and contrived way of writing programs in
which you represent the sequence of actions and instructions (aka algorithms) in a form that humans can
easily understand.
You see, computers and human beings are quite different, and therein lies the problem.

The language of a computer is very rigid: you are not allowed to make any mistakes or deviate from the
rules. Even with the invention of high-level, human-readable languages like JavaScript and Python, it’s
still pretty hard for an average human developer to reason and program in those coding languages.

With pseudocode, however, it’s the exact opposite. You make the rules. It doesn’t matter what language
you use to write your pseudocode. All that matters is comprehension.

In pseudocode, you don't have to think about semi-colons, curly braces, the syntax for arrow functions,
how to define promises, DOM methods and other core language principles. You just have to be able to
explain what you're thinking and doing.

Benefits of Writing Pseudocode


When you're writing code in a programming language, you’ll have to battle with strict syntax and rigid
coding patterns. But you write pseudocode in a language or form with which you're very familiar.

Since pseudocode is an informal method of program design, you don’t have to obey any set-out rules. You
make the rules yourself.
Pseudocode acts as the bridge between your brain and computer’s code executor. It allows you to plan
instructions which follow a logical pattern, without including all of the technical details.

Pseudocode is a great way of getting started with software programming as a beginner. You won’t have to
overwhelm your brain with coding syntax.

In fact, many companies organize programming tests for their interviewees in pseudocode. This is because
the importance of problem solving supersedes the ability to ‘hack’ computer code.

You can get quality code from many platforms online, but you have to learn problem solving and practice
it a lot.

Planning computer algorithms with pseudocode makes you meticulous. It helps you explain exactly what
each line in a software program should do. This is possible because you are in full control of everything,
which is one of the great features of pseudocode.

Example of Pseudocode
Pseudocode is a very intuitive way to develop software programs. To illustrate this, I am going to refer
back to a very simple program I wrote in my last article:
When a user fills in a form and clicks the submit button, execute a ValidateEmail function. What should
the function do?

1. Derive an email regular expression (regex) to test the user's email address against.

2. Access the user's email from the DOM and store it in a variable. Find and use the right DOM
method for that task.
3. With the email value now accessed and stored, create a conditional statement:

 If the email format doesn’t match the rule specified by the regex, access the element with
the myAlert id attribute and pass in the “Invalid Email” message for the user to see.
 Else, if the above condition isn’t true and the email address format actually matches with the
regex, check to see if the database already has such an email address. If it already does, access the
element with the myAlert id attribute and pass in the “Email exists!” message for the user to see.

 Now, if both of these conditions aren’t met, (that is the email format matches the regex and the
database doesn’t have such an email address stored yet), push the users email address into the
database and pass in the “Successful!” message for the user to see.

FLOWCHARTS:
Flowchart is a diagrammatic representation of sequence of logical steps of a program. Flowcharts use
simple geometric shapes to depict processes and arrows to show relationships and process/data flow.
Flowchart Symbols
Here is a chart for some of the common symbols used in drawing flowcharts.

Symbol Symbol Name Purpose

Used at the beginning and end of the algorithm to


Start/Stop
show start and end of the program.

Indicates processes like mathematical operations.


Process

Input/ Output Used for denoting program inputs and outputs.

Stands for decision statements in a program, where


answer is usually Yes or No.
Decision

Shows relationships between different shapes.


Arrow

Connects two or more parts of a flowchart, which


On-page Connector are on the same page.
Connects two parts of a flowchart which are spread
Off-page Connector over different pages.

Guidelines for Developing Flowcharts


These are some points to keep in mind while developing a flowchart −
 Flowchart can have only one start and one stop symbol
 On-page connectors are referenced using numbers
 Off-page connectors are referenced using alphabets
 General flow of processes is top to bottom or left to right
 Arrows should not cross each other
Example Flowcharts
Here is the flowchart for going to the market to purchase a pen.

Here is a flowchart to calculate the average of two numbers.


Rules For Creating Flowchart :

A flowchart is a graphical representation of an algorithm.it should follow some rules while


creating a flowchart
Rule 1: Flowchart opening statement must be ‘start’ keyword.
Rule 2: Flowchart ending statement must be ‘end’ keyword.
Rule 3: All symbols in the flowchart must be connected with an arrow line.
Rule 4: The decision symbol in the flowchart is associated with the arrow line.

Advantages of Flowchart:

Flowcharts are a better way of communicating the logic of the system.


Flowcharts act as a guide for blueprint during program designed.
Flowcharts help in debugging process.
With the help of flowcharts programs can be easily analyzed.
It provides better documentation.
Flowcharts serve as a good proper documentation.
Easy to trace errors in the software.
Easy to understand.
The flowchart can be reused for inconvenience in the future.
It helps to provide correct logic.
Disadvantages of Flowchart:

It is difficult to draw flowcharts for large and complex programs.


There is no standard to determine the amount of detail.
Difficult to reproduce the flowcharts.
It is very difficult to modify the Flowchart.
Making a flowchart is costly.
Some developer thinks that it is waste of time.
It makes software processes low.
If changes are done in software, then the flowchart must be redrawn
APPLICATION SOFTWARE PACKAGES:
What is application software?
The answer to ‘what is application software' is that it's a program that performs specific functions,
which typically follow a manufacturer's design, to complete the task a user wants. Most people
refer to this software as an application, an app or an end-user program. The term 'end-users' often
applies directly to application software while 'first-users' relates to system software.

This application can exist as a single program or a collection of programs. Usually, you can access
it online or install it on your computer. In addition, most apps can often perform simple and
complex functions.

Functions of application software


The following are some functions an application can perform:

 enterprise resource management


 customer relationship management
 project management
 text messages, emails, videos and audio chats
 document management
 business process management
 the creation and processing of healthcare applications
 human resource management
 teaching and training
 data and information management

7 major types of application software
There are several types of application software. Below are seven of the major types:

1. Presentation software
Presentation software allows you to share your ideas visually by using slideshows. You can
typically add text, pictures, videos or graphics to your slides based on your preferences and the
purpose of the presentation. This type of application usually has three major components that
perform distinct functions. First, the text editor allows the user to input and format their written
content. Second, the sideshow allows users to display their information. The third component lets
users insert pictures, videos and graphics.

2. Web browsers
A web browser is an application you can also refer to as a browser or an internet browser. These
applications communicate across the internet to identify and retrieve information from websites,
so they can display the content on the user's computer or mobile device. When working, browsers
typically retrieve information from web servers each time a user searches for something. These
applications usually are essential for viewing web pages, so it's important to install one.

3. Word processing software


Word processors allow users to create many documents, such as letters and memos and complete
forms for taxes and other purposes. The software has a variety of features, such as font styles and
sizes, that allow you to format your text based on your preferences. Many word processors can
look for grammar, spelling and word choice issues. Some of them have features that provide
synonym and antonym options. Furthermore, they typically allow you to insert symbols and
equations.

4. Database software
Database applications or database management systems help users organise their data. The
database usually stores information so it can retrieve it later. Once you instruct the database to
recall the information, you can modify it and save it back to the database.

5. Spreadsheet software
Spreadsheet applications can perform calculations for users. They typically store data in rows and
columns that intersect to create cells. These cells distinguish inputs like text, numbers, dates and
time. Users can use this software to present data with graphs or charts. Additionally, the software
allows users to use formulas that can perform complex calculations.

6. Simulation software
Simulation software typically allows you to interact with a physical environment considered
hazardous or inaccessible. The software often creates a realistic imitation that mimics the
behaviour and function of that environment. It can let users observe a process virtually and is
useful in sectors like education, industrial training, engineering, economics and agriculture.

7. Multimedia software
Multimedia software allows users to create audio, text and graphics. Some programs also allow
users to edit these files. Other programs offer users the ability to create animations. You can often
find this software in the education, business and entertainment industries.
COMPUTER NETWORK TYPES
A computer network is a group of computers linked to each other that enables the computer to
communicate with another computer and share their resources, data, and applications.

A computer network can be categorized by their size. A computer network is mainly of four types:

o LAN(Local Area Network)


o PAN(Personal Area Network)
o MAN(Metropolitan Area Network)
o WAN(Wide Area Network)

LAN(Local Area Network)


o Local Area Network is a group of computers connected to each other in a small area such as
building, office.
o LAN is used for connecting two or more personal computers through a communication medium
such as twisted pair, coaxial cable, etc.
o It is less costly as it is built with inexpensive hardware such as hubs, network adapters, and
ethernet cables.
o The data is transferred at an extremely faster rate in Local Area Network.
o Local Area Network provides higher security.
PAN(Personal Area Network)
o Personal Area Network is a network arranged within an individual person, typically within a range
of 10 meters.
o Personal Area Network is used for connecting the computer devices of personal use is known as
Personal Area Network.
o Thomas Zimmerman was the first research scientist to bring the idea of the Personal Area
Network.
o Personal Area Network covers an area of 30 feet.
o Personal computer devices that are used to develop the personal area network are the laptop,
mobile phones, media player and play stations.
Examples Of Personal Area Network:
o Body Area Network: Body Area Network is a network that moves with a person. For example, a
mobile network moves with a person. Suppose a person establishes a network connection and then
creates a connection with another device to share the information.
o Offline Network: An offline network can be created inside the home, so it is also known as
a home network. A home network is designed to integrate the devices such as printers, computer,
television but they are not connected to the internet.
o Small Home Office: It is used to connect a variety of devices to the internet and to a corporate
network using a VPN

MAN(Metropolitan Area Network)


o A metropolitan area network is a network that covers a larger geographic area by interconnecting a
different LAN to form a larger network.
o Government agencies use MAN to connect to the citizens and private industries.
o In MAN, various LANs are connected to each other through a telephone exchange line.
o The most widely used protocols in MAN are RS-232, Frame Relay, ATM, ISDN, OC-3, ADSL,
etc.
o It has a higher range than Local Area Network(LAN).

Uses Of Metropolitan Area Network:


o MAN is used in communication between the banks in a city.
o It can be used in an Airline Reservation.
o It can be used in a college within a city.
o It can also be used for communication in the military.

WAN(Wide Area Network)


o A Wide Area Network is a network that extends over a large geographical area such as states or
countries.
o A Wide Area Network is quite bigger network than the LAN.
o A Wide Area Network is not limited to a single location, but it spans over a large geographical
area through a telephone line, fibre optic cable or satellite links.
o The internet is one of the biggest WAN in the world.
o A Wide Area Network is widely used in the field of Business, government, and education.

Examples Of Wide Area Network:


o Mobile Broadband: A 4G network is widely used across a region or country.
o Last mile: A telecom company is used to provide the internet services to the customers in
hundreds of cities by connecting their home with fiber.
o Private network: A bank provides a private network that connects the 44 offices. This network is
made by using the telephone leased line provided by the telecom company.
Advantages Of Wide Area Network:

Following are the advantages of the Wide Area Network:

o Geographical area: A Wide Area Network provides a large geographical area. Suppose if the
branch of our office is in a different city then we can connect with them through WAN. The
internet provides a leased line through which we can connect with another branch.
o Centralized data: In case of WAN network, data is centralized. Therefore, we do not need to buy
the emails, files or back up servers.
o Get updated files: Software companies work on the live server. Therefore, the programmers get
the updated files within seconds.
o Exchange messages: In a WAN network, messages are transmitted fast. The web application like
Facebook, Whatsapp, Skype allows you to communicate with friends.
o Sharing of software and resources: In WAN network, we can share the software and other
resources like a hard drive, RAM.
o Global business: We can do the business over the internet globally.
o High bandwidth: If we use the leased lines for our company then this gives the high bandwidth.
The high bandwidth increases the data transfer rate which in turn increases the productivity of our
company.

Disadvantages of Wide Area Network:

The following are the disadvantages of the Wide Area Network:

o Security issue: A WAN network has more security issues as compared to LAN and MAN network
as all the technologies are combined together that creates the security problem.
o Needs Firewall & antivirus software: The data is transferred on the internet which can be
changed or hacked by the hackers, so the firewall needs to be used. Some people can inject the
virus in our system so antivirus is needed to protect from such a virus.
o High Setup cost: An installation cost of the WAN network is high as it involves the purchasing of
routers, switches.
o Troubleshooting problems: It covers a large area so fixing the problem is difficult.
COMPUTER NETWORK TOPOLOGIES

A Network Topology is the arrangement with which computer systems or network devices are connected
to each other. Topologies may define both physical and logical aspect of the network. Both logical and
physical topologies could be same or different in a same network.

Point-to-Point
Point-to-point networks contains exactly two hosts such as computer, switches or routers, servers
connected back to back using a single piece of cable. Often, the receiving end of one host is connected to
sending end of the other and vice-versa.

If the hosts are connected point-to-point logically, then may have multiple intermediate devices. But the
end hosts are unaware of underlying network and see each other as if they are connected directly.
Bus Topology
In case of Bus topology, all devices share single communication line or cable.Bus topology may have
problem while multiple hosts sending data at the same time. Therefore, Bus topology either uses
CSMA/CD technology or recognizes one host as Bus Master to solve the issue. It is one of the simple
forms of networking where a failure of a device does not affect the other devices. But failure of the shared
communication line can make all other devices stop functioning.
Both ends of the shared channel have line terminator. The data is sent in only one direction and as soon as
it reaches the extreme end, the terminator removes the data from the line.
Star Topology
All hosts in Star topology are connected to a central device, known as hub device, using a point-to-point
connection. That is, there exists a point to point connection between hosts and hub. The hub device can be
any of the following:

 Layer-1 device such as hub or repeater


 Layer-2 device such as switch or bridge
 Layer-3 device such as router or gateway

As in Bus topology, hub acts as single point of failure. If hub fails, connectivity of all hosts to all other
hosts fails. Every communication between hosts, takes place through only the hub.Star topology is not
expensive as to connect one more host, only one cable is required and configuration is simple.
Ring Topology
In ring topology, each host machine connects to exactly two other machines, creating a circular network
structure. When one host tries to communicate or send message to a host which is not adjacent to it, the
data travels through all intermediate hosts. To connect one more host in the existing structure, the
administrator may need only one more extra cable.

Failure of any host results in failure of the whole ring.Thus, every connection in the ring is a point of
failure. There are methods which employ one more backup ring.
Mesh Topology
In this type of topology, a host is connected to one or multiple hosts.This topology has hosts in point-to-
point connection with every other host or may also have hosts which are in point-to-point connection to
few hosts only.
Hosts in Mesh topology also work as relay for other hosts which do not have direct point-to-point links.
Mesh technology comes into two types:

 Full Mesh: All hosts have a point-to-point connection to every other host in the network.
Thus for every new host n(n-1)/2 connections are required. It provides the most reliable
network structure among all network topologies.
 Partially Mesh: Not all hosts have point-to-point connection to every other host. Hosts
connect to each other in some arbitrarily fashion. This topology exists where we need to
provide reliability to some hosts out of all.
Tree Topology
Also known as Hierarchical Topology, this is the most common form of network topology in use
presently.This topology imitates as extended Star topology and inherits properties of bus topology.
This topology divides the network in to multiple levels/layers of network. Mainly in LANs, a network is
bifurcated into three types of network devices. The lowermost is access-layer where computers are
attached. The middle layer is known as distribution layer, which works as mediator between upper layer
and lower layer. The highest layer is known as core layer, and is central point of the network, i.e. root of
the tree from which all nodes fork.

All neighboring hosts have point-to-point connection between them.Similar to the Bus topology, if the
root goes down, then the entire network suffers even.though it is not the single point of failure. Every
connection serves as point of failure, failing of which divides the network into unreachable segment.
Hybrid Topology
A network structure whose design contains more than one topology is said to be hybrid topology. Hybrid
topology inherits merits and demerits of all the incorporating topologies.
The above picture represents an arbitrarily hybrid topology. The combining topologies may contain
attributes of Star, Ring, Bus, and Daisy-chain topologies. Most WANs are connected by means of Dual-
Ring topology and networks connected to them are mostly Star topology networks. Internet is the best
example of largest Hybrid topology

You might also like