Comprehensive Programming Assignment: Algorithm Design & Analysis
VerifiedAdded on 2024/05/21
|25
|3668
|173
AI Summary
This programming assignment solution provides a comprehensive overview of algorithm design, implementation, and debugging using Python. It covers various algorithm types, including recursive, backtracking, and dynamic programming approaches. The solution also delves into different programming paradigms such as procedural, object-oriented, and event-driven programming, highlighting their characteristics and differences. Furthermore, it explores the features of the IDLE development environment and provides a detailed walkthrough of the debugging process, including setting breakpoints and using the debugger. This document serves as a valuable resource for students seeking to understand and implement algorithms effectively in Python.

PROGRAMMING ASSIGNMENT
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

Contents
LO1:............................................................................................................................................................2
P1: ALGORITHM...................................................................................................................................2
M1: Pseudo Code:...................................................................................................................................4
LO2:............................................................................................................................................................5
P2:...........................................................................................................................................................5
PROCEDURAL PROGRAMMING:......................................................................................................5
OBJECT-ORIENTATED:.......................................................................................................................5
EVENT-DRIVEN:..................................................................................................................................6
M2:..........................................................................................................................................................8
FEATURES OF IDLE.............................................................................................................................8
LO3:............................................................................................................................................................9
P3:...........................................................................................................................................................9
M3:........................................................................................................................................................13
LO4:..........................................................................................................................................................14
P4: a) debugging process.......................................................................................................................14
P4-b) Coding Standards:........................................................................................................................19
M4:........................................................................................................................................................23
REFERENCES:.........................................................................................................................................24
1
LO1:............................................................................................................................................................2
P1: ALGORITHM...................................................................................................................................2
M1: Pseudo Code:...................................................................................................................................4
LO2:............................................................................................................................................................5
P2:...........................................................................................................................................................5
PROCEDURAL PROGRAMMING:......................................................................................................5
OBJECT-ORIENTATED:.......................................................................................................................5
EVENT-DRIVEN:..................................................................................................................................6
M2:..........................................................................................................................................................8
FEATURES OF IDLE.............................................................................................................................8
LO3:............................................................................................................................................................9
P3:...........................................................................................................................................................9
M3:........................................................................................................................................................13
LO4:..........................................................................................................................................................14
P4: a) debugging process.......................................................................................................................14
P4-b) Coding Standards:........................................................................................................................19
M4:........................................................................................................................................................23
REFERENCES:.........................................................................................................................................24
1

LO1:
P1: ALGORITHM
An algorithm is a procedure for solving the programs, it tells us about the specification of the
class program. Algorithms can perform mathematical operations, calculations, data processing
and tells us about the flow of the program and how the task is performing.
The algorithm starts from the initial stage and goes to the final stage. It tells us about the time
complexity and space complexity of the program.
Basically, there are 8 types of the algorithm:
1. Simple recursive algorithm: the Simple recursive algorithm is an algorithm in which repeat
itself. It divides the problem into simple subproblem.
2. Backtracking algorithm: It will backtrack the path for defining the best solution. If no
solution is given by backtracking, return failure.
3. Divide and Conquer: Divide and conquer algorithm consist of two parts:
-Divide: It divides the problem into the smaller subproblem.
-Conquer- It integrates the result of subproblem into the one for giving the solution to the
original problem.
4. Binary Tree lookup: In this, we look up the sorted binary tree, three cases
- If both the keys are equal, return success.
- If the key value is less than look up for left subtree.
-If the key value is greater than look up for right subtree.
Repeat the process till success is return.
5. Dynamic programming algorithm: In this algorithm, the old results are saved and the new
result is found using the old results.
6. Greedy Algorithm: the Greedy algorithm is used to find the best-optimized result, it works in
two-phase
- We will choose the best and proceed
- We find the local optimum and global optimum.
2
P1: ALGORITHM
An algorithm is a procedure for solving the programs, it tells us about the specification of the
class program. Algorithms can perform mathematical operations, calculations, data processing
and tells us about the flow of the program and how the task is performing.
The algorithm starts from the initial stage and goes to the final stage. It tells us about the time
complexity and space complexity of the program.
Basically, there are 8 types of the algorithm:
1. Simple recursive algorithm: the Simple recursive algorithm is an algorithm in which repeat
itself. It divides the problem into simple subproblem.
2. Backtracking algorithm: It will backtrack the path for defining the best solution. If no
solution is given by backtracking, return failure.
3. Divide and Conquer: Divide and conquer algorithm consist of two parts:
-Divide: It divides the problem into the smaller subproblem.
-Conquer- It integrates the result of subproblem into the one for giving the solution to the
original problem.
4. Binary Tree lookup: In this, we look up the sorted binary tree, three cases
- If both the keys are equal, return success.
- If the key value is less than look up for left subtree.
-If the key value is greater than look up for right subtree.
Repeat the process till success is return.
5. Dynamic programming algorithm: In this algorithm, the old results are saved and the new
result is found using the old results.
6. Greedy Algorithm: the Greedy algorithm is used to find the best-optimized result, it works in
two-phase
- We will choose the best and proceed
- We find the local optimum and global optimum.
2
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

7. Branch and bound method: used for the optimization problem, upper bound and lower
bound are constructed.
8. Brute force algorithm: This algorithm works till the satisfactory result is generated.
9. Randomized algorithm: Random value is used to make the decision.
ALGORITHM:
Step 1 : Start
Step 2: Array_Sum = 0
Step 3: for v in Arrays:
Array_Sum = Array_Sum+v
3
bound are constructed.
8. Brute force algorithm: This algorithm works till the satisfactory result is generated.
9. Randomized algorithm: Random value is used to make the decision.
ALGORITHM:
Step 1 : Start
Step 2: Array_Sum = 0
Step 3: for v in Arrays:
Array_Sum = Array_Sum+v
3
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

Step 4: return Array_Sum
Start 5: Stop
M1: Pseudo Code:
Pseudocode is an informal code or a description of a code written in a high-level language. It is
written for the human so that after reading this code they have the basic idea of the program and
start and programming accordingly.
The pseudo code consists of instructions; instruction means actions which are going to perform
in the program. Hence we can say that pseudo code is a detailed step of the programming
development.
It makes the task easy; we can easily convert the pseudocode into a programming language.
The pseudo code starts with the ‘begin’ and ends with the ‘end’ which specify the starting and
end of the programming. The pseudo code makes the programming easier. It is key to
developing the complex and long program, all the part of the program can be mentioned in the
pseudo code.
PSEUDO CODE FOR BOUNCING BALL:
STEP 1: BEGIN
STEP 2: Enter the height of the ball;
STEP 3: Assign count =0 ;
STEP 4: if ball_height>0.5
Then,
Ball_height= 0.75 * ball_height
STEP 5: count = count + 1;
While true (GOTO step 4);
STEP 6: print bounce of the ball i.e. count ;
STEP 7: END
4
Start 5: Stop
M1: Pseudo Code:
Pseudocode is an informal code or a description of a code written in a high-level language. It is
written for the human so that after reading this code they have the basic idea of the program and
start and programming accordingly.
The pseudo code consists of instructions; instruction means actions which are going to perform
in the program. Hence we can say that pseudo code is a detailed step of the programming
development.
It makes the task easy; we can easily convert the pseudocode into a programming language.
The pseudo code starts with the ‘begin’ and ends with the ‘end’ which specify the starting and
end of the programming. The pseudo code makes the programming easier. It is key to
developing the complex and long program, all the part of the program can be mentioned in the
pseudo code.
PSEUDO CODE FOR BOUNCING BALL:
STEP 1: BEGIN
STEP 2: Enter the height of the ball;
STEP 3: Assign count =0 ;
STEP 4: if ball_height>0.5
Then,
Ball_height= 0.75 * ball_height
STEP 5: count = count + 1;
While true (GOTO step 4);
STEP 6: print bounce of the ball i.e. count ;
STEP 7: END
4

LO2:
P2:
PROCEDURAL PROGRAMMING:
The procedural language also called “Imperative Language”. A procedural language is a
language which composed of well-structured series and procedures within its programming
module. It consists of methodical or organized functions, sub routines, operations and statements
that should be executed in computational tasks. We can define the procedural language as the
simple language where we just write the simple computer statement to execute. These statements
need to be organizing in particular formats. This is basically known as development of
subroutines. In an imperative language, these subroutines are known as ’procedures’. Procedures
are the small programs that can be called from any other programs. Procedures are intended to do
some specific tasks. Then the procedure is called the current execution of the program is stored
in the register and execution of the procedure takes place. After the execution of the procedure,
the execution returns to the line where the procedure is called. The procedure is used to reduce
the size of the program and the developer need not write the same code again and again. The
procedural language can be written using three things only:
• Sequence
• Selection statements, for example: if statement
• Iterative statements, for example, loops
AS the name procedural implies, it as predefined and well defined functions and procedures that
should be executed to reach the output. C/C++are the example of the procedural language.
In python, procedural language is one of its coding styles. In this task are treated as the iteration
and the common task are placed in the function which is called. This coding style includes
iteration, selection, modularization of code and statements (DeLine and Leino, 2005).
OBJECT-ORIENTATED:
Object-oriented programming concern about the modeling or objects rather than actions and data
rather than logic. In object-oriented programming, it takes care of the object than manipulate that
object.
In object-oriented programming, the initial step is to find the object and how they are related to
each other. This step is known as data modeling. After analyzing the objects, we generalized the
class that means we define the kind of data contains and the logical sequences. Logical
5
P2:
PROCEDURAL PROGRAMMING:
The procedural language also called “Imperative Language”. A procedural language is a
language which composed of well-structured series and procedures within its programming
module. It consists of methodical or organized functions, sub routines, operations and statements
that should be executed in computational tasks. We can define the procedural language as the
simple language where we just write the simple computer statement to execute. These statements
need to be organizing in particular formats. This is basically known as development of
subroutines. In an imperative language, these subroutines are known as ’procedures’. Procedures
are the small programs that can be called from any other programs. Procedures are intended to do
some specific tasks. Then the procedure is called the current execution of the program is stored
in the register and execution of the procedure takes place. After the execution of the procedure,
the execution returns to the line where the procedure is called. The procedure is used to reduce
the size of the program and the developer need not write the same code again and again. The
procedural language can be written using three things only:
• Sequence
• Selection statements, for example: if statement
• Iterative statements, for example, loops
AS the name procedural implies, it as predefined and well defined functions and procedures that
should be executed to reach the output. C/C++are the example of the procedural language.
In python, procedural language is one of its coding styles. In this task are treated as the iteration
and the common task are placed in the function which is called. This coding style includes
iteration, selection, modularization of code and statements (DeLine and Leino, 2005).
OBJECT-ORIENTATED:
Object-oriented programming concern about the modeling or objects rather than actions and data
rather than logic. In object-oriented programming, it takes care of the object than manipulate that
object.
In object-oriented programming, the initial step is to find the object and how they are related to
each other. This step is known as data modeling. After analyzing the objects, we generalized the
class that means we define the kind of data contains and the logical sequences. Logical
5
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

sequences are known as methods. Objects communicate with each other through messages.
Following are the characteristics of the object-oriented programming:
• We can make the subclasses of the class which shares the some or all characteristics of the
main class. This property of OOPS is known as inheritance. This basically reduces the
development time and provides efficient coding. There is various type of inheritance like single
inheritance, multiple inheritance, multipath inheritance, multilevel inheritance and hierarchical
inheritance.
• Only the necessary data is accessed, other data is hidden. This property is known as Data
Hiding. This basically increases the security of the code. Only public data member can be
accessed by the other functions. Private data members are limited to their scope.
• When only essential information is visible to the user and other information is hidden from
them. This property is known as Data Abstraction. This basically simplifies the software
development.
The user does not know about the hidden information.
• Binding of data and function into the single entity is another characteristic of the OOPS. This
property is known as Data Encapsulations. This safe the data from misuse.
• Poly refers to ‘many’ and morphism refers to ‘ways’. Hence polymorphism means ‘many
ways’. In object-oriented programming, different objects can respond to the same functions and
the behavior is identified at the runtime. This property is known as polymorphism. Function
overloading and operator overloading is used to achieve polymorphism.
In python, object-oriented programming coding style is used to reduce the code length and to
increase the reusability of the code (Smith, 2015).
EVENT-DRIVEN:
As the name suggest the program structure and execution depends upon the event in the program.
The handling of these events is required, the procedure Is known as event driven handling. We
can use any programming language to write event driven programming code.
6
Following are the characteristics of the object-oriented programming:
• We can make the subclasses of the class which shares the some or all characteristics of the
main class. This property of OOPS is known as inheritance. This basically reduces the
development time and provides efficient coding. There is various type of inheritance like single
inheritance, multiple inheritance, multipath inheritance, multilevel inheritance and hierarchical
inheritance.
• Only the necessary data is accessed, other data is hidden. This property is known as Data
Hiding. This basically increases the security of the code. Only public data member can be
accessed by the other functions. Private data members are limited to their scope.
• When only essential information is visible to the user and other information is hidden from
them. This property is known as Data Abstraction. This basically simplifies the software
development.
The user does not know about the hidden information.
• Binding of data and function into the single entity is another characteristic of the OOPS. This
property is known as Data Encapsulations. This safe the data from misuse.
• Poly refers to ‘many’ and morphism refers to ‘ways’. Hence polymorphism means ‘many
ways’. In object-oriented programming, different objects can respond to the same functions and
the behavior is identified at the runtime. This property is known as polymorphism. Function
overloading and operator overloading is used to achieve polymorphism.
In python, object-oriented programming coding style is used to reduce the code length and to
increase the reusability of the code (Smith, 2015).
EVENT-DRIVEN:
As the name suggest the program structure and execution depends upon the event in the program.
The handling of these events is required, the procedure Is known as event driven handling. We
can use any programming language to write event driven programming code.
6
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

Figure 1: Event driven programming
In event-driven programming, the schedule is a central element which receives a stream of
events and sends the events to the appropriate event handler. If there is no such event handler
than scheduler either ignore it or throw an exception. An event handler is responsible for the
execution of the events.
Characteristics of event-driven programming are as follows:
• Service-oriented: services run in the background of the OS. It consumes computer processing
power but does not slow down the computer.
• Time Driven: time driven means that the code runs at a specific time only, the time is
specified.
• Event handler: Event handler is used to run the specific event when the specific time is
triggered.
• Simplicity of programming: Even driven programming is simple and easy to develop as we
can use any programming language to write the event-driven programming. Easy for user to
insert the code into the pre-existing file.
Difference between event driven, OOPS and procedural language:
PROCEDURAL
LANGUAGE
OBJECT ORIENTED
PROGRAMMING
EVENT DRIVEN
PROGRAMMING
Structure of the program
define the execution of the
program
Objects are the major concern Event define the flow of the
program
Describe how Step by step
processing is done
Describe the interconnection
between different objects
Handles the external events
Example: FORTAN, COBOL Example: java, c++ Example: c, C#
7
In event-driven programming, the schedule is a central element which receives a stream of
events and sends the events to the appropriate event handler. If there is no such event handler
than scheduler either ignore it or throw an exception. An event handler is responsible for the
execution of the events.
Characteristics of event-driven programming are as follows:
• Service-oriented: services run in the background of the OS. It consumes computer processing
power but does not slow down the computer.
• Time Driven: time driven means that the code runs at a specific time only, the time is
specified.
• Event handler: Event handler is used to run the specific event when the specific time is
triggered.
• Simplicity of programming: Even driven programming is simple and easy to develop as we
can use any programming language to write the event-driven programming. Easy for user to
insert the code into the pre-existing file.
Difference between event driven, OOPS and procedural language:
PROCEDURAL
LANGUAGE
OBJECT ORIENTED
PROGRAMMING
EVENT DRIVEN
PROGRAMMING
Structure of the program
define the execution of the
program
Objects are the major concern Event define the flow of the
program
Describe how Step by step
processing is done
Describe the interconnection
between different objects
Handles the external events
Example: FORTAN, COBOL Example: java, c++ Example: c, C#
7

M2:
FEATURES OF IDLE
• This is cross-platform that means can be used on any platform like in UNIX and Windows.
• IDLE support multi-window text editor.
• It gives different colorizing, smart indent and call tips.
• Its supports the shell window i.e. have an interactive interpreter.
• It supports the powerful debugger.
• Provide Ease to navigate the code.
• Highlights the error.
• This IDE always reopens from the same state, when you left.
• This IDE supports the automatic code formatting, that means, know about the next line that
should be intended in the code. This is done by recognizing the colon at the end of the line.
8
FEATURES OF IDLE
• This is cross-platform that means can be used on any platform like in UNIX and Windows.
• IDLE support multi-window text editor.
• It gives different colorizing, smart indent and call tips.
• Its supports the shell window i.e. have an interactive interpreter.
• It supports the powerful debugger.
• Provide Ease to navigate the code.
• Highlights the error.
• This IDE always reopens from the same state, when you left.
• This IDE supports the automatic code formatting, that means, know about the next line that
should be intended in the code. This is done by recognizing the colon at the end of the line.
8
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

LO3:
P3:
9
P3:
9
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

10

11
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 25

Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.