Unit 2 -Procedural Programming Paradigms and Platforms
Unit 2 -Procedural Programming Paradigms and Platforms
The word Algorithm means ” A set of rules to be followed in calculations or other problem-solving
operations ” Or ” A procedure for solving a mathematical problem in a finite number of steps that
frequently involves recursive operations”
It can be understood by taking the example of cooking a new recipe. To cook a new recipe, one reads
the instructions and steps and executes them one by one, in the given sequence. The result thus
obtained is the new dish cooked perfectly. Every time you use your phone, computer, laptop, or
calculator you are using Algorithms. Similarly, algorithms help to do a task in programming to get the
expected output.
The Algorithm designed are language-independent, i.e. they are just plain instructions that can be
implemented in any language, and yet the output will be the same, as expected.
As one would not follow any written instructions to cook the recipe, but only the standard one.
Similarly, not all written instructions for programming is an algorithms. In order for some instructions
to be an algorithm, it must have the following characteristics:
Clear and Unambiguous: The algorithm should be clear and unambiguous. Each of its steps
should be clear in all aspects and must lead to only one meaning.
Well-Defined Outputs: The algorithm must clearly define what output will be yielded and it
should be well-defined as well.
Finite-ness: The algorithm must be finite, i.e. it should terminate after a finite time.
Feasible: The algorithm must be simple, generic, and practical, such that it can be executed
with the available resources. It must not contain some future technology or anything.
Properties of Algorithm:
It should be deterministic means giving the same output for the same input case.
Every step in the algorithm must be effective i.e. every step should do some work.
Types of Algorithms:
There are several types of algorithms available. Some important algorithms are:
1. Brute Force Algorithm: It is the simplest approach for a problem. A brute force algorithm is the
first approach that comes to finding when we see a problem.
3. Backtracking Algorithm: The backtracking algorithm basically builds the solution by searching
among all possible solutions. Using this algorithm, we keep on building the solution following criteria.
Whenever a solution fails we trace back to the failure point and build on the next solution and continue
this process till we find the solution or all possible solutions are looked after.
4. Searching Algorithm: Searching algorithms are the ones that are used for searching elements or
groups of elements from a particular data structure. They can be of different types based on their
approach or the data structure in which the element should be found.
5. Sorting Algorithm: Sorting is arranging a group of data in a particular manner according to the
requirement. The algorithms which help in performing this function are called sorting algorithms.
Generally sorting algorithms are used to sort groups of data in an increasing or decreasing manner.
6. Hashing Algorithm: Hashing algorithms work similarly to the searching algorithm. But they
contain an index with a key ID. In hashing, a key is assigned to specific data.
7. Divide and Conquer Algorithm: This algorithm breaks a problem into sub-problems, solves a
single sub-problem and merges the solutions together to get the final solution. It consists of the
following three steps:
Divide
Solve
Combine
8. Greedy Algorithm: In this type of algorithm the solution is built part by part. The solution of the
next part is built based on the immediate benefit of the next part. The one solution giving the most
benefit will be chosen as the solution for the next part.
9. Dynamic Programming Algorithm: This algorithm uses the concept of using the already found
solution to avoid repetitive calculation of the same part of the problem. It divides the problem into
smaller overlapping subproblems and solves them.
10. Randomized Algorithm: In the randomized algorithm we use a random number so it gives
immediate benefit. The random number helps in deciding the expected outcome.
To learn more about the types of algorithms refer to the article about “Types of Algorithms“.
Advantages of Algorithms:
It is easy to understand.
In Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for the
programmer to convert it into an actual program.
Disadvantages of Algorithms:
1. The problem that is to be solved by this algorithm i.e. clear problem definition.
2. The constraints of the problem must be considered while solving the problem.
The Flowchart is the most widely used graphical representation of an algorithm and procedural
design workflows. It uses various symbols to show the operations and decisions to be followed in a
program. It flows in sequential order.
Types of Flowchart
o Horizontal Flowchart
o Panoramic Flowchart
o Vertical Flowchart
o Architectural Flowchart
chart:
Flowchart symbols:
o Terminal Symbol: In the flowchart, it is represented with the help of a circle for denoting the
start and stop symbol. The symbol given below is used to represent the terminal symbol.
o Input/output Symbol: The input symbol is used to represent the input data, and the output
symbol is used to display the output operation. The symbol given below is used for representing
the Input/output symbol.
o Processing Symbol:It is represented in a flowchart with the help of a rectangle box used to
represent the arithmetic and data movement instructions. The symbol given below is used to
represent the processing symbol.
o Decision Symbol: Diamond symbol is used for represents decision-making statements. The
symbol given below is used to represent the decision symbol.
o Connector Symbol:The connector symbol is used if flows discontinued at some point and
continued again at another place. The following symbol is the representation of the connector
symbol.
o Flow lines: It represents the exact sequence in which instructions are executed. Arrows are
used to represent the flow lines in a flowchart. The symbol given below is used for representing
the flow lines:
o Hexagon symbol (Flat): It is used to create a preparation box containing the loop setting
statement. The symbol given below is used for representing the Hexagon symbol.
o On-Page Reference Symbol: This symbol contains a letter inside that indicates the flow
continues on a matching symbol containing the same letters somewhere else on the same page.
The symbol given below is used for representing the on-page reference symbol.
o Off-Page Reference: This symbol contains a letter inside indicating that the flow continues on
a matching symbol containing the same letter somewhere else on a different page. The symbol
given below is used to represent the off-page reference symbol.
o Delay or Bottleneck: This symbol is used for identifying a delay in a flowchart. The alternative
name used for the delay is the bottleneck. The symbol given below is used to represent the
delay or bottleneck symbol.
Advantages of Flowchart in C:
Disadvantages of Flowchart in C:
Here, we will show the comparison chart between the algorithm and flow chart on the basis of some
characteristics.
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step 5: Display sum
Step 6: Stop
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a > b
If a > c
Display a is the largest number.
Else
Display c is the largest number.
Else
If b > c
Display b is the largest number.
Else
Display c is the greatest number.
Step 5: Stop
Algorithm 3: Find Roots of a Quadratic Equation ax 2 + bx + c = 0
Step 1: Start
Step 2: Declare variables a, b, c, D, x1, x2, rp and ip;
Step 3: Calculate discriminant
D ← b2-4ac
Step 4: If D ≥ 0
r1 ← (-b+√D)/2a
r2 ← (-b-√D)/2a
Display r1 and r2 as roots.
Else
Calculate real part and imaginary part
rp ← -b/2a
ip ← √(-D)/2a
Display rp+j(ip) and rp-j(ip) as roots
Step 5: Stop
Algorithm 4: Find the factorial of a number
Step 1: Start
Step 2: Declare variables n, factorial and i.
Step 3: Initialize variables
factorial ← 1
i←1
Step 4: Read value of n
Step 5: Repeat the steps until i = n
5.1: factorial ← factorial*i
5.2: i ← i+1
Step 6: Display factorial
Step 7: Stop
Step 1: Start
Step 2: Declare variables n, i, flag.
Step 3: Initialize variables
flag ← 1
i←2
Step 4: Read n from the user.
Step 5: Repeat the steps until i=(n/2)
5.1 If remainder of n÷i equals 0
flag ← 0
Go to step 6
5.2 i ← i+1
Step 6: If flag = 0
Display n is not prime
else
Display n is prime
Step 7: Stop
Algorithm 6: Find the Fibonacci series till the term less than 1000
Step 1: Start
Step 2: Declare variables first_term,second_term and temp.
Step 3: Initialize variables first_term ← 0 second_term ← 1
Step 4: Display first_term and second_term
Step 5: Repeat the steps until second_term ≤ 1000
5.1: temp ← second_term
5.2: second_term ← second_term + first_term
5.3: first_term ← temp
5.4: Display second_term
Step 6: Stop
Example: algorithm to multiply 2 numbers and print the result:
Step 1: Start
Step 2: Get the knowledge of input. Here we need 3 variables; a and b will be the user input and c will
hold the result.
Step 3: Declare a, b, c variables.
Step 4: Take input for a and b variable from the user.
Step 5: Know the problem and find the solution using operators, data structures and logic
We need to multiply a and b variables so we use * operator and assign the result to c.
That is c <- a * b
Step 6: Check how to give output, Here we need to print the output. So write print c
Step 7: End
Example 1:
Design a flowchart for adding two numbers entered by the user.
Example 2:
Design a flowchart for finding the largest among three numbers entered by the user.
Design a flowchart for calculating the profit and loss according to the value entered by the
user.
Draw a flowchart to calculate the average of two numbers.
Design a flowchart for checking whether the number is positive or negative according to the
number entered by the user
Computer programming platforms
A platform is a group of technologies that are used as a base upon which other applications, processes
or technologies are developed.
In personal computing, a platform is the basic hardware (computer) and software (operating system)
on which software applications can be run. This environment constitutes the basic foundation upon
which any application or software is supported and/or developed.
Software Platforms
A software platform that encompasses all the necessary components, application programming
interfaces and libraries required by programmers and developers to author, compile, debug and
execute language-specific applications.
Platform is hardware and software architecture that acts as foundation or base upon which other
applications, processes, or technologies are developed. In computing, platform refers to basic
hardware i.e., computer system and software i.e., operating system on which software applications are
often run. An application also can serve as platform if it‟s base for other programs. For instance, the
web browsers that we use in our day to day life accept few third-party plugins, and hence browser
application becomes platform for interfacing.
In recent times, almost every software enterprise builds some quite „platform‟. Yet all platforms that
are created aren‟t same. Facebook, Amazon Web Services, Amazon Marketplace, Google
Search, Android, Uber are all platforms, but at same time, these platforms are very different in how
they create network effects, kind of interactions they allow, approaches they follow, strategies and
other methods.
Now let us discuss the various types of platforms. They are :
1. Utility Platforms:
Google Search, Bing, Kayak, Skyscanner are some examples of Utility Platforms. Utility
Platforms attract their users by providing useful and also usually free service. Once there‟s
certain mass of users using service, platform opens to second sort of participants, like
advertisers in case of Google Search, airlines in case of Kayak or Skyscanner. There is no
network effect within useful service itself. Users attract businesses, but businesses on platform
don‟t necessarily attract users. We attend Google Search trying to find information, to not see
ads.
2. Content Distribution Platforms :
Google AdSense, PropellerAds, and Millennial Media are samples of Content Distribution
Platforms. Such platforms connect owners with content who are wishing to deliver content (or
ads) to users. More content available on platform, more attractive platform becomes. User
reach and accuracy of content matching are two most important aspects of this platform.
3. Data Harvesting Platforms:
Google Maps, Waze, Salesforce, OpenSignal, and InsideSales are some examples of Data
Harvesting Platforms. These platforms offer useful services to users and generate data through
usage of platform services. Data collected from all users of platform is fed back to service, thus
making it more useful for users. Network effect on these platforms is connoted on data instead
of users. Usage of platform service generates data, which in turn makes platform more valuable
for users, which attracts more users, whose usage generates more data, and so on.
4. Interaction Networks:
Facebook, WeChat, Telegram, Ello, and Bitcoin are some examples of Interaction Networks.
These sorts of platforms facilitate interactions between specific participants (people and/or
businesses). Digital interactions can be in form of message, voice call, image, or money
transfer. Foundational characteristic of Interaction Networks is identity. All interactions on
platform are ground to specific accounts. Users join platform to interact with other users, and
thus first network effect is between users of platform. Users attract users, who attract more
users. Thus, platform may be one-sided platform connecting participants of similar kind.
5. Technology Platforms:
Amazon Web Services and Microsoft Azure are some examples of Technology Platforms.
Technology Platforms provide building blocks or services that are reused during sizable amount
of products. Technology Platforms are not two-sided markets. Technology Platforms generate
revenue by selling their services to developers and are typically invisible to top-level users (end
users). For instance, while OTT‟s like Netflix and Amazon Prime run its video streaming services
on top of Amazon Web Services platform (AWS), top-level users interact solely with Netflix and
Amazon Prime. In this type of platform, there are no implicit network effects. These platforms
grow with favorable reception by developers and do not rely on interaction between demand
side and supply side. As a result, Technology Platforms are much easier to launch than multi-
sided or peer-to-peer platforms.
6. Marketplaces:
Amazon, eBay, Flipkart, Kickstarter, or UpWork are some examples of Marketplaces. These are
two-sided platforms connecting supply with demand. Marketplaces enable transactions between
demand-side participants i.e., buyers, and supply-side participants i.e., sellers. In these
platforms, prices of products and offered services are set by sellers. Network effect in
Marketplaces is between demand-side participants and supply-side participants. Sellers attract
buyers with exciting offers, who in turn attract more sellers, and so on. Identity plays secondary
role in this platform. Buyers search for selected product or service but not for selected seller.
Products or services are offered by multiple sellers who compete on price, reputation etc.
7. On-demand Service Platforms :
Uber, DoorDash, Go-Mart, and Doz are samples of On-demand Service Platforms. These types
of platforms offer end-to-end services to be fulfilled by group of independent service providers
or contractors. On-demand Service Platforms incorporate processes of search, order, payment,
fulfillment, and confirmation of service under one roof. Price, quality standards, and fulfillment
processes are set and managed by platform. User or buyer usually has less freedom, in
selecting how service will be delivered and by whom.
8. Computing Platforms :
Apple iOS, Google Android are some examples of computing platforms. Computing Platforms
render interactions between platform users and third-party developers. In Computing Platforms,
connection between users and developers is established through an app store/marketplace.
These platforms tend to develop strong bi-directional network effects once platform reaches
certain mass of users. Users attract developers, developers make apps, apps attract users, and
users attract developers, and so on.
9. Content Crowdsourcing Platforms :
YouTube, Crackle, Twitch, and Yelp are some examples of Content Crowdsourcing Platforms.
These types of platforms collect content from users in form of videos, blog posts, reviews, etc,
and share this content with wide range of users. In Content Crowdsourcing Platforms users
interact with platform and interaction is ground to content. Network effect is observed between
content contributors i.e., creators, and content consumers i.e., viewers of platform. If more
content is available on platforms, more content consumers will join platform making it more
valuable for content contributors, who in turn generate more content.
Apart from the above Platforms, there are also eight types of Software Platforms :
Hardware Platform
In some cases, operating systems might be classified as hardware platforms. Technically, operating
systems are their own software programs that must be built for a hardware platform. For example, IBM
PC hardware is designed to run certian operating systems, while the Apple hardware platform runs
others.
IT professionals may refer to newer devices like smartphones and tablets as having their own
individual hardware platforms. With the rise of cloud hosting and Web-delivered services, the word
platform has also been used to refer to free-floating, or multiplatform, software platforms that use the
Internet rather than a specific hardware platform to connect with individual machines or work stations.
Server and cloud based
A cloud server is a pooled, centralized server resource that is hosted and delivered over a network—
typically the Internet—and accessed on demand by multiple users. Cloud servers can perform all the
same functions of a traditional physical server, delivering processing power, storage and applications.
Cloud servers can be located anywhere in the world and deliver services remotely through a cloud
computing environment. In contrast, traditional dedicated server hardware is typically set up on
premises for exclusive use by one organization.
A cloud server is powerful physical or virtual infrastructure that performs application- and information-
processing storage. Cloud servers are created using virtualization software to divide a physical (bare
metal) server into multiple virtual servers. Organizations use an infrastructure-as-a-service
(IaaS) model to process workloads and store information. They can access virtual server functions
remotely through an online interface.
Key features
Computing infrastructure that can be physical (bare metal), virtual, or a mix of the two
depending on use case
Has all the capabilities of an on-premises server
Enables users to process intensive workloads and store large volumes of information
Automated services are accessed on demand through an API
Gives users the choice of monthly or as-you-go payment
Users can opt for a shared hosting plan that scales depending on needs
Cost effectiveness
With cloud servers, organizations only pay for what they need and reduce the expense that comes with
maintaining server hardware.
Scalability
Users can scale computing and storage resources to meet changing needs. This is particularly helpful
for organizations with fluctuating needs.
Integration
An organization‟s cloud servers are networked to ensure uninterrupted communication and fast
deployment. A “single pane” enables complete control.
Discover cloud servers