0% found this document useful (0 votes)
2 views46 pages

Programming

The document provides an overview of programming and algorithms, detailing the process of writing code, the various programming languages, and their specific features. It explains the structure and function of algorithms, their applications in technology, and the principles of creating effective algorithms. Additionally, it outlines the steps involved in designing an algorithm and emphasizes the importance of correctness, efficiency, simplicity, and security.

Uploaded by

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

Programming

The document provides an overview of programming and algorithms, detailing the process of writing code, the various programming languages, and their specific features. It explains the structure and function of algorithms, their applications in technology, and the principles of creating effective algorithms. Additionally, it outlines the steps involved in designing an algorithm and emphasizes the importance of correctness, efficiency, simplicity, and security.

Uploaded by

diffnikadiffni
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

HIGHER NATIONAL DIPLOMA IN

SOFTWARE ENGINEERING

Activity 01
Programming
Programming is writing computer code to create a program, to solve a problem. Programs
are created to implement algorithms. Algorithms can be represented as pseudocode or a
flow chart, and programming is the translation of these into a computer program.
To tell a computer to do something, a program must be written to tell it exactly what to do
and how to do it. If an algorithm has been designed, the computer program will follow
this algorithm, step-by-step, which will tell the computer exactly what it should do.

Programming language
A programming language is an artificial language that a computer understands. The
language is made up of series of statements that fit together to form instructions.
These instructions tell a computer what to do. (BBC Bitesize, 2024)

Figure 1:programming language

There are many different programming languages, some more complicated and complex
than others. Programming languages are designed to be easy for a human to understand
and write in. These are known as high-level languages.

However, a computer cannot run programs written in these languages directly. Most
programming languages have to be translated into machine code before the computer can
execute the instructions.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

There are many different programming languages, some more complicated and complex
than others. Among the most popular languages are:
Python
Java
C++
JavaScript
PHP
C#
BASIC
Scratch

Different programming languages work in different ways to give instructions to a


computer. For example, in Python programs are built by writing instructions in
abbreviated sentences using lowercase words.
Other languages, like Scratch, don't use words at all for the instructions. Instead, Scratch
uses colourful blocks and diagrams to build programs. To build a program, the user drags
and drops blocks to create actions, like telling a character to move or speak. Each block is
like a piece of a puzzle, and when connected, they show the flow of the program.

Python
Python is an interpreted, object-oriented, high-level programming language with dynamic
semantics. Its high-level built in data structures, combined with dynamic typing and
dynamic binding, make it very attractive for Rapid Application Development, as well as
for use as a scripting or glue language to connect existing components together. Python's
simple, easy to learn syntax emphasizes readability and therefore reduces the cost of
program maintenance. Python supports modules and packages, which encourages
program modularity and code reuse. The Python interpreter and the extensive standard
library are available in source or binary form without charge for all major platforms, and
can be freely distributed.
Often, programmers fall in love with Python because of the increased productivity it
provides. Since there is no compilation step, the edit-test-debug cycle is incredibly fast.
Debugging Python programs is easy: a bug or bad input will never cause a segmentation
fault. Instead, when the interpreter discovers an error, it raises an exception. When the
program doesn't catch the exception, the interpreter prints a stack trace. A source level
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

debugger allows inspection of local and global variables, evaluation of arbitrary


expressions, setting breakpoints, stepping through the code a line at a time, and so on.
The debugger is written in Python itself, testifying to Python's introspective power. On
the other hand, often the quickest way to debug a program is to add a few print statements
to the source: the fast edit-test-debug cycle makes this simple approach very effective.
(Python Software Foundation, 2025)

Figure 2:python

Java

Figure 3:java

Java was created at Sun Microsystems, Inc., where James Gosling led a team of
researchers in an effort to create a new language that would allow consumer electronic
devices to communicate with each other. Work on the language began in 1991, and before
long the team’s focus changed to a new niche, the World Wide Web. Java was first
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

released in 1995, and Java’s ability to provide interactivity and multimedia showed that it
was particularly well suited for the Web.

The difference between the way Java and other programming languages worked was
revolutionary. Code in other languages is first translated by a compiler into instructions
for a specific type of computer. The Java compiler instead turns code into something
called Bytecode, which is then interpreted by software called the Java Runtime
Environment (JRE), or the Java virtual machine. The JRE acts as a virtual computer that
interprets Bytecode and translates it for the host computer. Because of this, Java code can
be written the same way for many platforms (“write once, run anywhere”), which helped
lead to its popularity for use on the Internet, where many different types of computers
may retrieve the same Web page. (Britannica, 2019)

C++

C++ is a statically typed, compiled, general-purpose, case-sensitive, free-form


programming language that supports procedural, object-oriented, and generic
programming.
C++ is regarded as a middle-level language, as it comprises a combination of both high-
level and low-level language features.

Figure 4:C++
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

C++ was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in Murray Hill,
New Jersey, as an enhancement to the C language and originally named C with Classes
but later it was renamed C++ in 1983.
C++ is a superset of C, and that virtually any legal C program is a legal C++ program.

(points, 2020)

JavaScript

JavaScript (JS) is a lightweight interpreted (or just-in-time compiled) programming


language with first-class functions. While it is most well-known as the scripting language
for Web pages, many non-browser environments also use it, such as [Link], Apache
CouchDB and Adobe Acrobat. JavaScript is a prototype-based, garbage-collected,
dynamic language, supporting multiple paradigms such as imperative, functional, and
object-oriented.

Figure 5:javascript

JavaScript's dynamic capabilities include runtime object construction, variable parameter


lists, function variables, dynamic script creation (via eval), object introspection (via
for...in and Object utilities), and source-code recovery (JavaScript functions store their
source text and can be retrieved through toString()). (MDN Contributors, 2023)

PHP
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Figure 6:PHP

PHP is an open-source, server-side programming language that can be used to create


websites, applications, customer relationship management systems and more. It is a
widely-used general-purpose language that can be embedded into HTML. This
functionality with HTML means that the PHP language has remained popular with
developers as it helps to simplify HTML code.
PHP can do many other things. For example, it is excellent at collecting form data,
encrypting user data and sending and receiving cookies. One of the major features of PHP

that makes it so usable is that it is compatible with all major operating systems so you can
code no matter what tech you are using. (Toal, 2014)

C#

C# (C-sharp) is a modern, object-oriented language created by Microsoft in 2000 as part


of the .NET framework. It is used to build Windows applications, web services and more.
C# combines the power of C/C++ with the simplicity of Java and Visual Basic.
Used to build dynamic websites, RESTful APIs, and web services using frameworks like

Figure 7:C#
[Link] and [Link] Core.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Widely used in the Unity Engine, one of the most popular platforms for developing 2D,
3D, AR, and VR games.
Supports building Windows desktop applications using WPF and WinForms, as well as
cross-platform mobile apps with Xamarin and .NET MAUI.
Commonly used for developing scalable cloud applications and enterprise software,
especially on platforms like Microsoft Azure. GeeksforGeeks (2018)

Algorithm
Introduction
An algorithm is a set of defined steps designed to perform a specific objective. This can
be a simple process, such as a recipe to bake a cake, or a complex series of operations
used in machine learning to analyze large datasets and make predictions. In the context of
machine learning, algorithms are vital as they facilitate the learning process for machines,
helping them to identify patterns and make decisions based on data. (Team, 2023)

Algorithms Explained
Algorithms are structured sets of instructions designed to solve specific problems or
perform particular tasks. They function through a series of well-defined steps, each
contributing to the ultimate goal. Here, we break down the typical stages involved in the
functioning of an algorithm:

Input. The first step involves defining the inputs that the algorithm will use. Inputs are the
data on which the algorithm will operate. It could be anything from a single value to a
complex data structure.
Processing. This is the core phase where the algorithm performs operations on the inputs
using a series of computational steps. This phase is guided by logical and arithmetic
calculations to process the data effectively. Within the processing phase, there are often
crucial substeps:
 Decision making. At various points during processing, decisions need to be made
based on certain conditions. This substep involves directing the flow of the
algorithm based on conditional statements, leading to different paths in the
algorithm.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

 Looping. For many algorithms, certain steps need to be repeated multiple times
until a specific condition is met. Looping allows the algorithm to execute the same
steps repeatedly, optimizing the process and saving time.
Output. After processing the inputs through various computational and conditional steps,
the algorithm produces an output. This output is the result of the algorithm’s operations
and is used to solve the problem or perform the task at hand.
Termination. An algorithm must have a defined stopping point to ensure it doesn’t run
indefinitely. Once all the steps are executed successfully, and the output is produced, the
algorithm reaches its termination point.

Uses of Algorithms
Algorithms are the silent powerhouses behind many technologies and services that we use
daily. They have a wide array of applications, enhancing efficiency and personalizing
experiences in various fields.

In the realm of navigation, algorithms work tirelessly in GPS applications to analyze real-
time data on traffic and road conditions, helping to find the quickest route to your
destination. Their role is pivotal in online shopping platforms as well, where they analyze
your browsing and purchasing history to suggest products that align with your
preferences, facilitating a personalized shopping experience.

The banking sector leverages algorithms to maintain security and prevent fraud. By
scrutinizing transaction patterns, algorithms can flag unusual activities, helping to identify
and prevent fraudulent transactions before they occur.

Social media platforms are another area where algorithms play a crucial role. They
analyze a plethora of data, including your interactions, the content you like, and the
people you follow, to curate a feed that is tailored to your interests, keeping you engaged
for longer periods.

Furthermore, they are instrumental in the functioning of search engines, helping to sift
through vast amounts of information on the internet to find the most relevant results for
your queries.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

In essence, algorithms are the backbone of modern technology, working behind the
scenes to make our lives easier, safer, and more enjoyable by offering tailored solutions
and optimizing processes in various industries. Their applications are virtually limitless.

Types of Algorithm
Understanding the different types of algorithms can help in selecting the most appropriate
one for solving a specific problem. Broadly, we can categorize algorithms based on their
use cases and their structural or problem-solving strategies:
Search algorithms. Designed to retrieve information stored within some data structure,
e.g., binary search algorithm used to find a particular item in a sorted list.
Sorting algorithms. They rearrange the elements of a dataset in a specified order, like
quicksort and mergesort, which are efficient for sorting large datasets.
Graph algorithms. These deal with graphs, which are mathematical structures used to
represent pairwise relations between objects, e.g. Dijkstra's algorithm finds the shortest
path between nodes in a graph.

Structural or Problem-solving Strategies


1. Dynamic programming algorithms. Implemented to solve problems by breaking
them down into smaller subproblems, dynamic processing algorithms avoid
redundant work by remembering past results, which is a technique called
memoization.
2. Brute force algorithms. By trying all possible solutions until the correct one is
found, brute force algorithms can be effective, but time-consuming for complex
problems.
3. Recursive algorithms. These algorithms call themselves with smaller input values
and use the results of these calls to solve the current problem. A classic example is
the factorial function, where the factorial of a number n is calculated as n
multiplied by the factorial of (n-1).
4. Greedy Algorithms. Greedy algorithms make locally optimal choices at each step
with the hope of finding the global optimum. One example is the Huffman coding
algorithm, used for lossless data compression.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

5. Divide and conquer algorithms. These algorithms divide the problem into smaller
subproblems, solve them independently, and then combine their solutions to solve
the original problem. The mergesort algorithm is a classic example of a divide and
conquer strategy.
6. Backtracking algorithms. They work by trying different solutions and
backtracking to find the correct solution when a dead end is reached. Sudoku
solvers often use backtracking algorithms.
7. Randomized algorithms. Randomized algorithms use random numbers to make
decisions during the execution, which means they can give different outputs on
different runs. QuickSort is an example where randomization can be used to
improve performance on average.

Good Algorithm
In the world of computing and data science, creating a good algorithm is a fundamental
goal. A well-crafted algorithm can significantly enhance the efficiency and effectiveness
of a system. There are several principles that underpin whether an algorithm is effective
and fit for use:
 Correctness. Foremost, a good algorithm must be correct, meaning it should
always produce the right output for any given input. It should be free of errors and
bugs to ensure reliable performance.
 Efficiency. Efficiency is a critical aspect of a good algorithm. It refers to the
optimal use of computational resources, including time and memory. An efficient
algorithm performs tasks swiftly, saving both time and energy.
 Simplicity. A good algorithm should be simple and straightforward, avoiding
unnecessary complexity. Simplicity facilitates easier understanding,
implementation, and maintenance, making the algorithm more user-friendly.
 Flexibility. Flexibility is the ability of an algorithm to adapt to changes and
varying conditions. A flexible algorithm can accommodate different inputs and
adjust to modifications without compromising its performance.
 Robustness. Robustness refers to the algorithm's ability to handle errors
gracefully. A robust algorithm can manage unexpected inputs or conditions
without crashing, providing stable and reliable performance.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

 Stability. Stability is crucial; it ensures that the algorithm performs reliably and
consistently under various conditions, maintaining its accuracy and reliability over
time, even with varied inputs.
 Maintainability. Maintainability is about how easily an algorithm can be updated
or modified. A maintainable algorithm allows for smooth updates and alterations,
ensuring it remains up-to-date and functional over time.
 Documentation. Good algorithms come with comprehensive documentation that
outlines how the algorithm works, its limitations, and how to use it effectively.
Well-documented algorithms are easier to use and integrate into different systems.
 Security. In the current digital age, security is a paramount concern. A good
algorithm should be designed with security in mind, ensuring that it protects
sensitive data and resists attacks from malicious entities.

Create an Algorithm
Creating an algorithm can be a meticulous process that involves a deep understanding of
the problem at hand and the available computational resources. Here are the detailed steps
along with the tools and technologies that can be employed to create a successful
algorithm:
 Identify the problem. Clearly define the problem you want to solve. It is essential
to understand the problem's intricacies and requirements to develop an effective
algorithm.
 Analyze the problem. Dive deep into the problem to gather all necessary
information. Utilize analytical tools such as Python libraries (like NumPy and
pandas) for data analysis to understand the data structure and patterns better.
 Design the algorithm. Create a step-by-step procedure to solve the problem. At
this stage, you can use flowchart software like Lucidchart or Microsoft Visio to
visually map out the algorithm's flow and structure. Developing a pseudocode can
also be beneficial, as it allows you to outline the algorithm's logic in a simplified
manner.
 Select appropriate tools and technologies. Depending on the complexity of the
algorithm, you might need to employ advanced tools and technologies. IDEs like
PyCharm or Visual Studio can be useful for coding the algorithm. Moreover,
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

leveraging machine learning frameworks such as TensorFlow or Scikit-learn can


aid in developing sophisticated algorithms.
 Implement the algorithm. Translate your design into a working algorithm using a
programming language suitable for your project. Common choices include
Python, Java, or C++. Ensure to follow best coding practices for readability and
maintainability.
 Test the algorithm. Rigorously test the implemented algorithm using various
testing tools like JUnit for Java or PyTest for Python. Verify the algorithm with
different inputs to ensure it produces the correct output consistently.
 Optimize the algorithm. Post-testing, analyze the algorithm's performance and
optimize it for better efficiency. Profiling tools, such as Python’s cProfile, can
help identify bottlenecks, guiding improvements
 Document the algorithm. Document the algorithm comprehensively, explaining
each step and its function. Tools like Doxygen can generate documentation
automatically from source code, facilitating understanding for other developers.
 Deploy the algorithm. Deploy the algorithm in a real-world environment.
Depending on the application, use cloud platforms like AWS or Azure for
deployment to ensure scalability and accessibility
 Maintain and update the algorithm. Post-deployment, maintain the algorithm,
updating it as necessary to adapt to changing conditions and requirements. Use
version control systems like Git to manage updates efficiently

Advantages of Algorithms
1. It provides a clear, step-by-step outline of how to solve a specific problem, making it
easy to grasp.
2. An algorithm follows a specific set of procedures.
3. It is independent of any programming language, making it accessible to those without
programming experience.
4. Each step in an algorithm follows a logical order, which simplifies the debugging
process.
5. By utilizing an algorithm, the problem is divided into smaller, manageable steps,
making it easier for a programmer to translate it into a functioning program.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Disadvantages of Algorithms
1. Algorithms is Time consuming.
2. Difficult to show Branching and Looping in Algorithms.
3. Big tasks are difficult to put in Algorithms.
4. Complexity in Implementation
5. Resource Intensive
6. Rigidity
7. Requires Expertise
8. Potential for Errors

Way of express an Algorithm


1. Natural Language: Written in plain English. Easy to describe, but can be unclear
for complex problems.
2. Flowchart: Graphical representation of steps. Easier to visualize than natural
language.
3. Pseudocode: Text-based, code-like instructions without language syntax.
Best way to express an algorithm.
Understandable even to beginners with basic knowledge.

Natural Language
Natural language processing (NLP) is a subset of artificial intelligence, computer science,
and linguistics focused on making human communication, such as speech and text,
comprehensible to computers.
NLP is used in a wide variety of everyday products and services. Some of the most
common technologies that use NLP are voice-activated digital assistants on smartphones,
email-scanning programs used to identify spam, and translation apps that decipher foreign
languages. (Coursera Staff, 2023)

NLP benefits
Whether it’s being used to quickly translate a text from one language to another or
producing business insights by running sentiment analysis on hundreds of reviews, NLP
provides both businesses and consumers with a variety of benefits.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

 The ability to analyze both structured and unstructured data, such as speech, text
messages, and social media posts.
 Improving customer satisfaction and experience by identifying insights using
sentiment analysis.
 Reducing costs by employing NLP-enabled AI to perform specific tasks, such as
chatting with customers via chatbots or analyzing large amounts of text data.
 Better understanding a target market or brand by conducting NLP analysis on
relevant data like social media posts, focus group surveys, and reviews.

NLP limitations
NLP can be used for a wide variety of applications, but it's far from perfect. In fact, many
NLP tools struggle to interpret sarcasm, emotion, slang, context, errors, and other types of
ambiguous statements. This means that NLP is mostly limited to unambiguous situations
that don't require a significant amount of interpretation.

Natural language processing examples


Although natural language processing might sound like something out of a science fiction
novel, the truth is that NLP examples already exist in your everyday life as you interact
with countless NLP-powered devices and services every day.

Online chatbots, for example, use NLP to engage with consumers and direct them toward
appropriate resources or products. While chatbots can’t answer every question that
customers may have, businesses like them because they offer cost-effective ways to
troubleshoot common problems or questions that consumers have about their products.

Another common use of NLP is for text prediction and autocorrect, which you’ve likely
encountered many times before while messaging a friend or drafting a document. This
technology allows texters and writers alike to speed up their writing process and correct
common typos.

Natural language processing applications


NLP has a wide array of applications across various sectors, such as finance, insurance,
and health care. Prominent applications for NLP technology include voice-activated
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

assistants, machine translation, sentiment analysis, chatbots, virtual customer support,


classification and categorization, content recommendation systems, text summarization,
speech recognition, and natural language generation. Here are just some of the ways
natural language processing is used in the real world: (Coursera Staff, 2023)

1. Voice-activated assistants
NLP powers virtual assistants, so if you ever use Apple’s Siri, Amazon’s Alexa, and
IBM’s watsonx Assistant, you’ve already experienced NLP. This technology enables
them to understand and respond to voice commands. It allows you to interact with your
device using natural language to perform tasks, search for information, and control smart
home devices.

2. Machine translation
NLP is the driving force behind machine translation services such as Google Translate. It
allows for the automatic translation of text and speech between languages, making global
communication more accessible. NLP allows an online translator to understand the
individual rules of grammar and language structure between two languages and
effectively decode one into the other.

3. Sentiment analysis
Your business can use NLP for sentiment analysis to gauge a customer’s opinion, their
satisfaction, and the market’s response to your products by analyzing social media posts,
customer reviews, and survey responses. This can help your company make better
decisions, especially when formulating future strategies.

4. Chatbots and virtual customer support


NLP enables chatbots to understand and respond to customers' questions and comments
in a conversational manner. This application is widely used in customer service to provide
instant assistance, book appointments, and resolve common issues.

5. Content recommendation systems


HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Platforms like T-Mobile, Spotify, and Disney+ use NLP-based recommendation systems
to analyze user preferences and provide personalized content suggestions based on
previous interactions and the content's textual data. Using sentiment analysis—also
powered by natural language processing—recommendation systems can even recommend
movies, music, or other media based on how users have reviewed those products.

6. Speech recognition
Speech recognition assists with converting spoken language into text in real-time, which
is essential for dictation software, hands-free computing, and real-time transcription
services. Everybody talks a little differently: At different speeds, in varying tones, with
accents and regional dialects, and with differing pronunciations. After the speech
recognition software transcribes your words, natural language processing analyzes
those words, determines the meaning behind them, and then formulates an
appropriate response.

7. Natural language generation (NLG)


This involves using NLP to generate natural language text from data, enabling
applications like automated report generation, personalized content creation, and article
writing. NLG can also craft stories. With natural language generation, you can ask an AI
language model like Amazon’s Alexa or Apple’s Siri a question as if speaking to another
person. The model will respond similarly.
These applications demonstrate the versatility and impact of NLP in simplifying
interactions, enhancing accessibility, and providing deeper insights from textual data
across diverse domains.

Example of natural language


Algorithm to Calculate the Average of 3 Numbers

Step 1 – Start: Begin the algorithm.

Step 2 – Input: Prompt the user to enter the first number.

Step 3 – Store: Read the value and store it in a variable called num1.

Step 4 – Input: Prompt the user to enter the second number.


HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Step 5 – Store: Read the value and store it in a variable called num2.

Step 6 – Input: Prompt the user to enter the third number.

Step 7 – Store: Read the value and store it in a variable called num3.

Step 8 – Calculate Average:

 Use the formula: Average = (num1 + num2 + num3) / 3


 Store the result in a variable called average.

Step 9 – Output: Display the value of average.

Step 10 – End: Terminate the algorithm.

Flowcharts
A Flowchart is a diagram that visually represents a process or an algorithm in a sequential
or chronological order. A Flowchart uses defined flowchart shapes to depict each step of
the process and connectors to achieve uniform representation worldwide.
Other ways people refer to flowcharts include flow chart, process flowchart, functional
flowchart, process map, process chart, functional process chart, business process model,
process model, process flow diagram, workflow diagram, and business flow diagram. (A,
2023)
Uses of flowcharts
A flowchart is a visual representation of a process or workflow that uses standard
symbols to illustrate steps, decisions, and outcomes. Understanding what a flowchart is
and its applications can improve clarity, efficiency, and decision-making in any
organization.

Use Case Description Benefit

Visualizing Represents steps in a process with Makes complex procedures


Processes symbols and arrows easy to understand
Problem-Solving Maps out processes to identify Helps teams pinpoint issues
bottlenecks quickly
Decision Making Shows possible outcomes based Supports informed and
on decisions clear decision-making
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Training and Provides step-by-step workflow Reduces onboarding time


Documentation guides for new employees
Process Highlights redundancies and Streamlines operations and
Optimization inefficiencies saves resources
Communication Acts as a universal visual Ensures alignment between
Across Teams language technical and non-technical
teams
Table 1:Uses of flowchart

Visualizing Processes and Workflows


The main use of a flowchart is to visualize processes. By representing steps in a process
with standardized symbols like rectangles for tasks, diamonds for decisions, and arrows
for direction, a flowchart transforms complex procedures into a simple, easy-to-follow
flow diagram. This helps anyone understand how a process works from start to finish.
Problem-Solving and Decision Making
Flowcharts are valuable tools for problem-solving. When there is a bottleneck or
inefficiency, creating a flowchart makes it easier to identify exactly where the issues
occur. Whats a flowchart used for in decision-making? Flowcharts show possible
outcomes based on decisions at each step, helping teams make informed choices with
clarity.
Training and Documentation
Flowcharts are useful for training and documentation. New employees can quickly learn
complex workflows without reading long manuals. Whether it is a software development
pipeline, business approval process, or customer support procedure, a flowchart provides
a step-by-step guide that is easy to follow.
Process Optimization
Flowcharts help with process optimization. By laying out every step visually,
organizations can identify redundancies, remove unnecessary steps, and streamline
operations. This can save both time and resources while improving efficiency.
Communication Across Teams
A flowchart also acts as a universal language in organizations. Technical and non-
technical team members can follow a flow diagram, reducing misunderstandings and
keeping everyone aligned. This is especially helpful in project planning, software
development, and operational management.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Types of flowcharts
Flowcharts can be of different types based on their purpose and complexity. Here are
some of the commonly used flowcharts based on its application along with some example
flowcharts. (A, 2023)
Process Flowcharts
Process Flowcharts illustrates the sequence of steps and activities involved in a process. It
provides a clear and detailed overview of how a particular task or system works, from the
beginning to the end. Process flowcharts are widely used in various industries, including
manufacturing, business processes, software development, and more.
Architecture Diagrams
An architectural diagram serves as a visual representation encapsulating all the integral
elements that collectively constitute a segment or the entirety of a system. Its principal
objective is to enhance understanding for engineers, designers, stakeholders, and all
involved participants in the project. They can be further specialized as cloud architecture
diagrams, network architecture diagrams, software architecture diagrams, etc.
User Flow Diagrams
A user flow diagram is a chart or diagram illustrating the steps a user takes within an
application to complete a task. These visual representations are valuable tools for
modeling and understanding the interactions that users have with a software.
Data Flow Diagrams (DFD)
A Data Flow Diagram (DFD) is a graphical representation that illustrates how data moves
through a system, emphasizing the flow of information and processes. DFDs are
commonly used in system analysis and design to visualize and describe the data
processing within a system. They are a part of structured analysis and design methods and
are valuable tools for understanding, modeling, and communicating complex systems.
Swimlane Flowcharts
A Swimlane Flowchart is a type of process flowchart that organizes information based on
the responsible or accountable parties involved in each step of a process. The term
"swimlane" refers to the visual division of the flowchart into parallel lanes, each
representing a specific participant, department, or functional area within an organization.
Swimlane flowcharts are particularly useful for illustrating and understanding the
interactions and responsibilities across different entities in a process.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Workflow Diagrams
A workflow diagram illustrates the sequence of steps, tasks, or activities involved in a
process or workflow. It provides a clear and detailed overview of how work progresses
from initiation to completion, including the interactions between different components,
participants, or systems.
System Flowcharts
A system flowchart is a visual representation that illustrates the sequence of operations or
processes within a system. This type of flowchart focuses on the flow of data and control
between various components of a system, providing a detailed overview of how
information is processed, stored, and transferred.
Document Flowcharts
A document flowchart illustrates the flow of documents or information within a system or
a specific business process. This type of flowchart is designed to show how documents
move through various stages, departments, or individuals within an organization.
Document flowcharts are particularly useful for analyzing, documenting, and improving
processes related to the handling of paperwork, forms, or electronic documents.
Business Process Model and Notation (BPMN) Diagrams
Business Process Model and Notation (BPMN) is a standard graphical notation for
representing business processes in a visual and easily understandable manner. BPMN
diagrams provide a standardized way to model and document business processes, making
them accessible to both technical and non-technical stakeholders. BPMN is widely used
in business process management (BPM) and system analysis.
Hierarchy Flowcharts
A hierarchy flowchart, also known as an organizational chart or hierarchy chart,
represents the structure and relationships within an organization or a specific system. It
illustrates the hierarchy of different levels of entities, such as departments, roles, or
individuals, and their relationships to one another. The chart typically uses a tree-like
structure to showcase the levels of authority and reporting relationships.
Mind Maps
A mind map is a diagram that visually outlines information using branches, colors,
keywords, and images to represent relationships between different concepts. Mind maps
are commonly used for brainstorming, note-taking, problem-solving, and organizing
thoughts in a creative and non-linear way.
Audit Flowcharts
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Audit flowcharts are widely employed in internal and external auditing, compliance
audits, financial audits, and other types of audit activities. They contribute to the
efficiency and effectiveness of the audit process by providing a clear and standardized
representation of the steps involved.

Shapes for a Flow Chart and Their Description


Oval (Terminator)
 Description: This shape is used for both the start and end of a flowchart and is
almost always labeled with a word like "Start" or "End".
 Usage: Use this shape to indicate where the process starts and where it ends.
Rectangle (Process)
 Description: It represents a process, action step, or operation. The text inside
usually describes the action, such as "Edit Video" or "Submit Form".
 Usage: This is one of the shapes most frequently used in flowcharts to represent
tasks or operations.
Diamond (Decision)
 Description: It is used to indicate a point in the process where a decision has to be
made. There are usually two or more arrows leading out from it, indicating
different paths that one could take, depending on the decision made—for instance,
"Yes" or "No.".
 Usage: This is the type of shape most used when establishing flowcharts using
logic that involves branching.
Parallelogram (Input/Output)
 Description: Represents an input to or output from a process, designating data
input or results shown.
 Usage: Use this shape when you need to show that data is being input or output
from a process.
Arrow (Flow Line)
 Description: Arrows are used to indicate the direction of flow between shapes.
They guide the reader through a series of steps in a process.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

 Usage: Used to connect different shapes and for representing the order of
operations.
Circle (Connector)
 Description: A connector that is commonly used for showing a jump in the
flowchart flow, especially when the flowchart contains more than one page.
 Usage: This linking of different parts enables the flowchart to remain clear, even
in a complex flowchart.

Figure 8:shapes for a flowchart

Example of Flowchart
Flowchart to Calculate the Average of 3 Numbers
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Figure 9:flowchart to calculate the average of


3number

Pseudocode
Pseudocode is a step-by-step description of an algorithm written in simple English using a
code-like structure. It is designed for human understanding, not for machine execution,
and does not follow the syntax of any programming language. (GeeksforGeeks, 2022)
Uses of Pseudocode
 Helps programmers plan the solution before writing actual code
 Makes the logic easy to understand for others reading the solution
 Bridges the gap between algorithm design and coding
 Reduces logical errors before implementation

Figure 10:pseudocode

Main Constructs of Pseudocode


Basically, pseudocode is the capability for representing six programming constructs—
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

they are always written in uppercase: SEQUENCE, CASE, WHILE, REPEAT-UNTIL,


FOR, and IF-THEN-ELSE. These constructs, otherwise known as keywords, are used to
outline the control flow of an algorithm.
1. SEQUENCE: It can be considered as a series of linear tasks that get executed one after
the other.
2. WHILE: It is a loop with a condition at the beginning.
3. REPEAT-UNTIL: This is also a loop, but with a condition at the bottom.
4. FOR: This is another way of looping.
5. IF-THEN-ELSE: This is a kind of conditional statement that alters the algorithm flow.
6. CASE: The CASE construct is the generalization form of IF-THEN-ELSE.

Methods to Write Pseudocode


Before writing the pseudocode of any algorithm the following points must be kept in
mind.
 Organize tasks logically and write steps in sequence.
 Define the goal first.
Example:
This program prints the first N Fibonacci numbers.
 Use standard programming constructs:
IF–ELSE
FOR
WHILE
 Indent blocks properly to improve readability and clarity.
 Use clear and meaningful names for variables and steps.
 Write keywords in CAPITAL letters (IF, ELSE, WHILE).
 Ensure the pseudocode is:
Complete
Finite
Easy to understand
Avoid writing actual programming syntax—keep it simple and language-independent.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Difference between Flowchart and Pseudocode


Flowchart Pseudocode

A Flowchart is pictorial representation of A Pseudocode is a step-by-step


flow of an algorithm. description of an algorithm in code like
structure using plain English text.
A Flowchart uses standard symbols for Pseudocode uses reserved keywords like
input, output decisions and start stop if-else, for, while, etc.
statements. Only uses different shapes like
box, circle and arrow.
This is a way of visually representing These are fake codes as the word pseudo
data, these are nothing but the graphical means fake, using code like structure but
representation of the algorithm for a better plain English text instead of programming
understanding of the code language
Flowcharts are good for documentation Pseudocode is better suited for the
purpose of understanding

Table 2:Different between flowchart and pseudocode

Example of Pseudocode
Pseudocode to Calculate the Average of 3 Numbers:
Begin
Function calculate_average (num1, num2, num3)
Return (num1 + num2 + num3) / 3
End function

Prompt "Enter the first number: "


Read num1 AS float

Prompt "Enter the second number: "


Read num2 AS float

Prompt "Enter the third number: "


HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Read num3 AS float


Set average to calculate_average (num1, num2, num3)
Print "The average is " + Format (average, ".2f")
END

Good Algorithm
A "good" algorithm is one that effectively and efficiently solves a given problem while
adhering to certain desirable characteristics. The definition of a good algorithm can vary
depending on the context and specific requirements of the problem at hand. However,
several universal qualities are generally accepted as markers of a good algorithm:
(gurus, 2024)

Correctness
 Definition: The algorithm must produce the correct output for all possible valid
inputs.
 Importance: Ensures reliability and accuracy, which are critical for any
application or system.
 Example: Dijkstra’s Algorithm correctly finds the shortest path in a graph with
non-negative edge weights.
Efficiency
 Time Complexity: Measures how the running time increases with the size of the
input.
Example: Binary Search has a time complexity of O(log n), making it highly
efficient for searching in sorted arrays.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

 Space Complexity: Measures the amount of memory the algorithm uses relative to
the input size.
Example: In-Place QuickSort has a space complexity of O(log n) due to its
recursive stack usage.
 Why It’s Good: Efficient algorithms optimize resource usage, making them
suitable for large-scale or real-time applications.
Scalability
 Definition: The algorithm can handle increasing amounts of data or more complex
inputs without a significant drop in performance.
 Importance: Critical for applications that grow over time or operate in dynamic
environments.
 Example: MergeSort maintains a time complexity of O(n log n) regardless of the
input size, making it scalable for large datasets.
Simplicity and Clarity
 Definition: The algorithm is easy to understand, implement, and maintain.
 Importance: Simplifies debugging, enhances collaboration, and reduces the
likelihood of errors.
 Example: Insertion Sort is straightforward to implement, making it ideal for
educational purposes and small datasets.
Robustness
 Definition: The algorithm can handle unexpected or edge-case inputs gracefully
without failing.
 Importance: Enhances the reliability and resilience of software systems.
 Example: A robust binary search algorithm includes checks for empty arrays and
handles out-of-bound indices appropriately.
Flexibility and Adaptability
 Definition: The algorithm can be easily modified or extended to solve related
problems.
 Importance: Increases the algorithm’s utility across different scenarios and
reduces the need to develop new solutions from scratch.
 Example: The A* (A-Star) algorithm can be adapted for various pathfinding and
graph traversal problems by modifying its heuristic function.
Optimality
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

 Definition: The algorithm finds the best possible solution according to a defined
criterion (e.g., shortest path, minimum cost).
 Importance: Ensures that the solution is not just feasible but also the most
effective.
 Example: Dynamic Programming solutions, like the Knapsack Problem, find the
optimal subset of items that maximize value without exceeding weight limits.
Examples of Good Algorithms
QuickSort
 Type: Divide and Conquer
 Time Complexity: Average O(n log n); Worst O(n²)
 Space Complexity: O(log n)
 Why It’s Good: Highly efficient for large datasets with good cache performance
and in-place sorting capabilities.

MergeSort
 Type: Divide and Conquer
 Time Complexity: O(n log n) consistently
 Space Complexity: O(n)
 Why It’s Good: Stable sort, excellent for linked lists, and consistently performs
well regardless of input distribution.
Dijkstra’s Algorithm
 Type: Greedy
 Time Complexity: O(V log V + E) with a priority queue
 Space Complexity: O(V + E)
 Why It’s Good: Efficiently finds the shortest path in weighted graphs with non-
negative edges, widely used in networking and navigation.
Binary Search
 Type: Divide and Conquer
 Time Complexity: O(log n)
 Space Complexity: O(1)
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

 Why It’s Good: Extremely efficient for searching in sorted arrays, with minimal
memory usage.
A (A-Star) Algorithm*
 Type: Heuristic Search
 Time Complexity: Depends on the heuristic; O(E) in the best case
 Space Complexity: O(V)
 Why It’s Good: Combines the strengths of Dijkstra’s Algorithm with heuristics to
efficiently find the shortest path, particularly in AI and game development.
Dynamic Programming Solutions (e.g., Knapsack, Longest Common Subsequence)
 Type: Dynamic Programming
 Time Complexity: Varies (often O(n²))
 Space Complexity: Varies (can be optimized to O(n))
 Why It’s Good: Efficiently solves optimization problems by breaking them down
into overlapping subproblems and storing intermediate results.

Hash Tables (e.g., HashMap in Java, Dictionary in Python)


 Type: Data Structure
 Time Complexity: Average O(1) for insertions, deletions, and lookups
 Space Complexity: O(n)
 Why It’s Good: Provides fast access to data through key-value pairs, essential for
implementing efficient lookup tables, caches, and associative arrays.
Breadth-First Search (BFS)
 Type: Graph Traversal
 Time Complexity: O(V + E)
 Space Complexity: O(V)
 Why It’s Good: Ideal for finding the shortest path in unweighted graphs, level-
order traversal in trees, and solving puzzles like mazes.
Depth-First Search (DFS)
 Type: Graph Traversal
 Time Complexity: O(V + E)
 Space Complexity: O(V)
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

 Why It’s Good: Useful for tasks like cycle detection, topological sorting, and
solving puzzles by exploring as far as possible along each branch before
backtracking.
Fast Fourier Transform (FFT)
 Type: Divide and Conquer
 Time Complexity: O(n log n)
 Space Complexity: O(n)
 Why It’s Good: Efficiently computes the Discrete Fourier Transform, essential in
signal processing, image analysis, and various engineering applications.
Choose a Good Algorithm for a Problem
Understand the Problem Requirements:
 Determine what the problem is asking for, including inputs, outputs, and any
specific constraints.
Analyze Input Size and Constraints:
 Consider the maximum possible size of the input. Larger inputs typically require
more efficient algorithms.
Evaluate Time and Space Complexity:
 Choose an algorithm whose time and space complexity align with the problem’s
constraints.
Consider Stability and Order:
 If maintaining the relative order of equal elements is important (e.g., in sorting),
select a stable algorithm like MergeSort.
Assess Implementation Difficulty:
 Balance between the algorithm’s efficiency and the complexity of implementing
it. Sometimes a slightly less efficient but simpler algorithm is preferable for ease
of implementation and debugging.
Leverage Existing Libraries:
 Utilize well-tested and optimized library functions where possible to save time
and reduce the risk of errors.
Mastering Good Algorithms
 Practice Regularly: Consistent problem-solving helps reinforce your
understanding and improve your ability to recognize which algorithm to apply.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

 Understand the Theory: Grasp the underlying principles and mechanics of each
algorithm rather than just memorizing code.
 Implement from Scratch: Writing algorithms yourself deepens your
comprehension and prepares you for situations where built-in functions aren’t
available.
 Analyze and Compare: After solving a problem, compare your solution with
others to learn different approaches and optimizations.
 Stay Updated: Keep learning about new algorithms and advancements in the field
to continuously enhance your problem-solving toolkit.

Process for building an application


Process for building an application. The same application is built differently depending
on the requirements, technology, and methodology used. Listed below are the general
steps followed in the creation of an application.
 Idea and Problem Definition.
 Planning the solution
 Development and Coding.
 Testing the Application

 Documenting the program.


Describe the process for building an application.
1. Define the problem The first thing in creating any application is finding a problem it
should fix or a need it's supposed to fill. This includes doing thorough research on what
the eventual users experience in terms of problems. A clear problem statement is
important since it helps in directing the whole proceedings.
2. General analysis and requirements gathering In the process of software development, it
is during this stage that the needs, which are sought for designing the products, should be
looked upon. This becomes the sole focus of most projects. Interested stakeholders and
project managers get together, sit down, and sort out the requirements. Some of the
questions that are usually asked are: "Who uses the product? Product usage, what kind of
data is input in the product? What kind of information does the product give out as
output? ” Are all answered in this step. After gathering requirements and answering
questions such as the one above comes condition analysis. The possibility of putting the
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

assembled elements in the final product is taken into consideration and studied in detail.
A document based on the requirements specification is drawn. Once the analysis of a
requirement is complete, the development team then goes ahead to the next level of
coming up with a product design to be followed throughout the development process of
the product. (Manifera, 2017)
3. Designing the Application This is the step at which the design of the product is made
based on the requirements document. The design of the product helps in the specification
of hardware required to run the product, hence deployment. It also helps in outlining the
overall structure of the product, showing which software modules will be developed and
how they relate to each other.
It is also time to choose a development platform: for example, .NET, Java, Laravel, Ruby
on Rails, FileMaker, and others. The selection would depend on the requirements
themselves but also relate to which platform is commonly used within the company.
(Manifera, 2017)
5 stages of the Software Design process
Understanding software project requirements
Research and Analysis
Software design
Software prototyping
Software inspection
4. Coding the program
After the product design phase, the development team proceeds with the implementation
or coding phase. When the requirement specification and the design documents are
available to the development team, the software developers begin coding. Along with
coding, the development teams are also involved in the unit or module testing part in this
phase, aiming to detect problems as early as possible in the development cycle. Some
companies outsource their coding work, and often the previous stage of Product Design,
as well, to a third-party software application development company. The reasons for this
vary from not having the required resources or expertise to wanting to free up their own
staff to focus on the core offerings of the company. (Manifera, 2017)
5. Testing the program After the phase of coding and implementation would come
integration and validation testing. Service teams for software development continuously
get involved in the deployment software process for a variety of applications serving
different purposes. It finds its necessity because this process is so crucial as the product
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

needs to be tested against all available parameters rigorously. In this stage, any bugs
within the product would be realized, which are fixed afterwards if present. This also
means that the software product acts as risk assessment during this phase. As mentioned
earlier, the software developers will perform unit or module testing. The next stage in
testing is Integration testing, where interactions among individual modules and/or other
external systems are to be put under scrutiny. After Integration testing, there will be the
Validation testing, where the final software product will be tested with respect to the
specified requirements and its UI/UX design, from an end-user perspective. Another way
of testing is referred to as Test-Driven Development, TDD. In utilizing this process,
software developers first write a test script for certain requirements, and then they create
the code to supposedly fulfill the requirements. Then, after that, a test is run, and code is
changed until such time the test is passed. (Manifera, 2017)
6. Debugging Debugging is the process of finding and fixing the bugs present within the
source code of any available software. When some particular software does not act the
way, it should, computer programmers review and examine the code in order to trace why
those certain errors have occurred. They use debugging tools that allow running in a
controlled environment, checking the code step by step, analyzing, and fixing it.
7. Documenting the program Documentation in program building is described as the
creation of written materials accounting for different parts of the software. It is very
important documentation serving many purposes for both the development team and the
end users. Types of Software Documentation
• System Documentation
• User Documentation
• Developer Documentation
• Requirements Documentation
Benefits of Software Documentation Good documentation helps the users to know how to
use the software, how it works, important for complex applications when several teams
are working on it. In the software development lifecycle, documentation plays an
important role. It serves as a tracker, helps in bug fixing, and aids in future updates. In
modular programming, where different teams may work on different parts, clear
documentation will help all team members understand how to put their work together.
Good user documentation would really help to enhance the user experience with clear
instructions and tips for problem solving.
8. Deployment of a programming
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

The software product can then be released after testing. When the product is ready, the
first version is released into the public domain. This is usually known as Beta testing.
Any changes at this stage of software development may be made here in case there is any
customer feedback, and/or bugs that were not discovered during testing appear.
Deployment typically involves the creation of a 'Production' server, on which the software
will reside. It could be one of the servers of the company or even in the 'cloud' using
services like Amazon Web Services or Microsoft Azure. (Manifera, 2017)
9. Maintenance and Operations After passing all the steps described above and finally
releasing a software product to the market, a product must be kept operational and
maintained, which means debugging all the issues raised and updating the system
regularly with the latest operating system patches or updates up taken of third-party
software used in dependence. This is because, in the event of a large increase in the
number of users of the software product, it may be necessary to scale up by adding more
processing power, memory, or database capacity for smooth operation. (Manifera, 2017)

Fibonacci series
Fibonacci Number
A Fibonacci number is known to be a series of numbers where each of the Fibonacci
numbers is found by adding the two preceding numbers. It also means that the next
number in the series is the addition of the two previous numbers. Let us take the first two
numbers in the series as 0 and 1. So by adding 0 and 1, we will get the third number as 1,
and by adding the second and the third number which is 1 and 1, we get the fourth
number to be 2, and likely, the process goes on and on.
So, we get the Fibonacci series as 0, 1, 1, 2, 3, 5, 8, ……. Therefore, the obtained series is
called to be the Fibonacci number series. (Vedantu, 2020)
Fibonacci Series
The list of the numbers of Fibonacci Sequence is given below. This list is created by
using the Fibonacci formula, which is also mentioned in the above definition.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

The Fibonacci sequence is a set of the numbers that starts with a one or a zero, which are
followed by a one, and then proceeds based on the rule that each of the numbers (called a
Fibonacci number) equals to the sum of the preceding two numbers. If the Fibonacci
sequence is put up as F (n), where n is the first term in the sequence, so the following
equation obtains for n = 0, where the first two terms are put up as 0 and 1 by the
convention.
Fibonacci Series Formula
F (0) equals 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ...
In some of the texts, it is mandatory to use n = 1. So, the first two terms are defined as 1
and 1 by default, and we see:
F (1) equals 1, 1, 2, 3, 5, 8, 13, 21, 34 …
Fibonacci Numbers, Fibonacci Formula
The sequence of the Fibonacci numbers can be written as:
Fn = Fn-1 + Fn-2
Where Fn is the nth term or the number
Fn-1 is the (n-1)th term
Fn-2 is the (n-2)th term
From the equation above, we can also write up the definition as the next number in the
sequence, and is the sum of the previous two numbers which are present in the sequence,
starting from 0 and 1.

Fibonacci Series List

Fn-1 Fn-2 Fn

0 1 1

1 1 2

1 2 3

2 3 5
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

3 5 8

5 8 13

8 13 21

13 21 34

21 34 55

34 55 89

Table 3:Fibonacci series list

Fibonacci Number Properties


The following points below are the properties for the Fibonacci numbers:
 In the Fibonacci series, let us take any of the three consecutive numbers and add
those numbers. When we divide the result by 2, we will get the three numbers.
Example, let’s take 3 consecutive numbers like 1, 2, 3. when we add these
numbers that are 1+ 2+ 3 = 6. When 6 is divided by 2, the result will be 3.
 Take four of the consecutive numbers other than “0” in the Fibonacci series. Then
multiply the outer number and also then multiply the inner number. When we
subtract these numbers, we will get the difference “1”. For example, if we take 4
consecutive numbers like 2, 3, 5, 8. Multiply the outer numbers (i.e) 2(8) and then
multiply the inner number which is 3(5). Now we subtract these two numbers 16-
15 =1. So, the difference is 1.
Applications for the Fibonacci numbers will also include the computer algorithms like the
Fibonacci search technique and then the Fibonacci heap data structure, and the graphs
called as Fibonacci cubes which are used for interconnecting the parallel and distributed
systems. (Vedantu, 2020)

Algorithm for Fibonacci series


Step 1 - Start: Begin the algorithm.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Step 2 - Input: Read an integer (n) from the user, which represents the number of terms in
the Fibonacci sequence.
Step 3 - Check Input:
If (n <= 0):
Output "Please enter a positive integer".
Go to Step 8 (End).
If (n = 1):
Output the sequence [0].
Go to Step 8 (End).
If (n = 2):
Output the sequence [0, 1].
Go to Step 8 (End).
Step 4 - Initialize Sequence: Create a list ‘sequence’ and initialize it with the first two
Fibonacci numbers: [0, 1].
Step 5 - Loop: For (I) from 2 to (n-1):
Calculate next_value as sequence[i-1] + sequence[i-2].
Append next_value to sequence.
Step 6 - Output: Print the sequence.
Step 7 - End: Terminate the algorithm.

Pseudo code for Fibonacci series


Start
Input n
Input n
Check if n is a non-positive integer
If n <= 0 Then
Output error message and terminate
Output "Please enter a positive integer"
End
End If
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Check if n is 1
If n == 1 Then
Output the first Fibonacci number and terminate
Output [0]
End
End If
Check if n is 2
If n == 2 Then
Output the first two Fibonacci numbers and terminate
Output [0, 1]
End
End If
Initialize the Fibonacci sequence for n > 2
Initialize sequence = [0, 1]
Generate the Fibonacci sequence
For i from 2 to n-1 Do
next_value = sequence[i-1] + sequence[i-2]
Append next_value to sequence
End For
Output the generated Fibonacci sequence
Output sequence
END

Flowchart for Fibonacci series


HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Figure 11:flowchart for Fibonacci series


HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Python code for Fibonacci series

Figure 12:python code for Fibonacci sequence

Figure 13:python code output for Fibonacci sequence


HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Factorial series
The factorial of a given number is calculated by multiplying all the natural numbers less
than or equal to that number and the last number should be 1. The factorial of a number is
expressed by the symbol ‘!’ placed after the number. For example, the factorial of 5 is
expressed by the symbol 5! (chandni, 2024b)
Let’s explore the factorial formula.
The formula of factorial number ‘n’ is expressed below.
n! = n x (n-1) x (n-2) x (n-3) …….. 3 x 2 x 1
Therefore, the value of factorial 5 will be: 5! = 5 x 4 x 3 x 2 x 1 = 120
Calculating Factorial Using Previous Value
Wondering how to calculate factorial more efficiently? The factorial discussed adiscussed
above shows something interesting: a number's factorial is found by multiplying it with
the factorial of the number before it.
In other words, n! = n x (n-1)!
For example, 8! = 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 8 x 7!
Again, it also helps to calculate the factorial of a number if the factorial of its successor is
known.
The formula will be: n! = (n+1)!/(n+1)
For example, 4! = 5!/5 = (5 x 4 x 3 x 2 x 1)/5 = 4 x 3 x 2 x 1 = 24
Factorial of One
The factorial of 1 is expressed as 1! =1 as per the factorial formula. It can also be
explained differently. In permutations, the number of ways of arranging ‘n’ different
things can be obtained by the value of n! Since 1 can be arranged in only one way, it
explains the value of factorial one as 1.
Factorial of Zero
The factorial of zero can be calculated by the formula: n! = (n+1)!/(n+1)
We can write, 0! = 1!/1 = 1/1 = 1
So, the factorial of zero is 1, which is the same as the factorial of 1.
Factorial of Negative Numbers
The factorial of negative numbers is undefined . This can be explained in the following
way.
We know that n! = (n+1)!/(n+1)
If we want to find the value of (1)! The calculation will be:
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

(-1)! = 0!/0 = 1/0, but anything divided by zero is undefined.


So, the factorial of a negative number can’t be defined.
Factorial Values Examples
Number(n) Factorial(n!) Number(n) Factorial(n!)

1! 1 6! 720

2! 2 7! 5,040

3! 6 8! 40,320

4! 24 9! 362,880

5! 120 10! 3,628,800

Table 4:factorial values examples

Algorithm for Factorial series


Step 1: Start: Begin the algorithm.
Step 2: Input: Read the integer n (the upper limit for the sum).
Step 3: Base Case Check:
if n is less than or equal to ():
Return () (since the sum of natural numbers up to () is ().
Step 4: Recursive Case:
if n is greater than ():
Calculate the sum by adding n to the result of the function called
with n-1 (i.e., sum_n (n-1)).
Step 5: Return Result: Return the computed sum.
Step 6: Output: Print the result showing the sum of natural numbers up to n.
Step 7: End: Terminate the algorithm.
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Pseudo code for Factorial series


Start
Define the function ‘fac_iterative’
FUNCTION fac_iterative(n):
Initialize the variable ‘result’ to 1 SET result TO 1
Loop from 2 to n (inclusive) to calculate the factorial
FOR i FROM 2 TO n:
Multiply the current `result` by the current value of ‘i’ result = result * i
After the loop ends, return the factorial result
RETURN result
Set the variable ‘num’ to 7 (or any other desired value)
SET num TO 7
Call the ‘fac_iterative’ function with the value of ‘num’
SET factorial_value TO fac_iterative(num)
Print the result in a formatted string
PRINT “The factorial of”, num, “is”, factorial_value
END
Flowchart for Factorial series

Figure 14:flowchart for factorial series


HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Python code for Factorial series

Figure 15:python code for factorial series

Figure 16:python code output for factorial series


HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Dry run and test


The dry run is a type of test that is usually done in programming, which manually
executes a program without the use of a computer. In this test, one follows the algorithm
in detail while recording the value of variables after each step in tabular form.
This testing is useful because it enables one to comprehend the working of the program
and detect any mistakes in logic that might be found. Such dry run tests prove especially
effective in debugging loops, conditions, and calculations.
Dry run test for Fibonacci series
Program name – Fibonacci series
Language – Python
Iteration Terms f1 f2 n Output
0 5 0 1 - -
1 5 0 1 0 1
2 5 1 1 0,1 1
3 5 1 2 0,1,1 2
4 5 2 3 0,1,1,2 3
5 5 3 5 0,1,1,2,3 5
Table 5:dry run test for Fibonacci series

Dry run test for Factorial series


Program name – Factorial series
Language – Python
Step Input Num I Factorial Output
1 5 - 1 -
2 5 1 1 -
3 5 2 2 -
4 5 3 6 -
5 5 4 24 -
6 5 5 120 120
Table 6:dry run test for factorial series
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING

Programming process

You might also like