Programming
Programming
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)
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
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
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++
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
Figure 5:javascript
PHP
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING
Figure 6: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#
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.
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
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
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.
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.
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.
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.
Step 3 – Store: Read the value and store it in a variable called num1.
Step 5 – Store: Read the value and store it in a variable called num2.
Step 7 – Store: Read the value and store it in a variable called num3.
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.
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.
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.
Example of Flowchart
Flowchart to Calculate the Average of 3 Numbers
HIGHER NATIONAL DIPLOMA IN
SOFTWARE ENGINEERING
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
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
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.
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.
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.
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
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.
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
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! 1 6! 720
2! 2 7! 5,040
3! 6 8! 40,320
4! 24 9! 362,880
Programming process