ProductsLogo
LogoStudy Documents
LogoAI Grader
LogoAI Answer
LogoAI Code Checker
LogoPlagiarism Checker
LogoAI Paraphraser
LogoAI Quiz
LogoAI Detector
PricingBlogAbout Us
logo

Algorithms and Data Structures

Verified

Added on  2020/06/04

|33
|6268
|63
AI Summary
This assignment delves into the world of algorithms and data structures. It explores different types of algorithms, their applications in solving various problems, and the role of data structures in optimizing algorithm performance. Students are tasked with analyzing existing algorithms, understanding their complexities, and applying them to solve specific problems presented in the document.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Programming algorithms
Page 1 of 34

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
CONTENTS
Table of Contents
1.0 INTRODUCTION.....................................................................................................................................................
2.0 Table of Contents:.....................................................................................................................................................
3.0 Difference between Algorithm and Code..................................................................................................................
4.0 Characteristics of code.............................................................................................................................................
5.0 Implementation........................................................................................................................................................
6.0 Review and reflection:............................................................................................................................................
7.0 Conclusion.............................................................................................................................................................
Page 2 of 34
Document Page
Introduction
An algorithm specifies a series of steps that perform a particular computation or task.
Algorithms were originally born as part of mathematics – the word “algorithm” comes from the
Arabic writer Muḥammad ibn Mūsā al-Khwārizmī, – but currently the word is strongly
associated with computer science.
LO1
Define basic algorithms to carry out an operation and outline the process of programming an
application
Algorithm definition:
A sorting algorithm is an algorithm made up of a series of instructions that takes an array as
input, performs specified operations on the array, sometimes called a list, and outputs a sorted
array. Sorting algorithms are often taught early in computer science classes as they provide a
straightforward way to introduce other key computer science topics like Big-O notation, divide-
and-conquer methods, and data structures such as binary trees, and heaps. There are many
factors to consider when choosing a sorting algorithm to use.
Heap Sort is a popular and efficient sorting algorithm in computer programming. Learning how
to write the heap sort algorithm requires knowledge of two types of data structures - arrays
and trees.
The initial set of numbers that we want to sort is stored in an array e.g. [10, 3, 76, 34, 23,
32] and after sorting, we get a sorted array [3,10,23,32,34,76]
Heap sort works by visualizing the elements of the array as a special kind of complete binary
tree called heap.
Procedures to follow for Heapsort
Since the tree satisfies Max-Heap property, then the largest item is stored at the root node.
Remove the root element and put at the end of the array (nth position) Put the last item of the
tree (heap) at the vacant place.
Page 3 of 34
Document Page
Reduce the size of the heap by 1 and heapify the root element again so that we have highest
element at root.
The process is repeated until all the items of the list is sorted.
// Java program for implementation of Heap Sort
public class HeapSort
{
public void sort(int arr[])
{
int n = arr.length;
// Build max heap
for (int i = n / 2 - 1; i >= 0; i--) {
heapify(arr, n, i);
}
// Heap sort
for (int i=n-1; i>=0; i--)
{
int temp = arr[0];
arr[0] = arr[i];
arr[i] = temp;
Page 4 of 34

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
// Heapify root element
heapify(arr, i, 0);
}
}
void heapify(int arr[], int n, int i)
{
// Find largest among root, left child and right child
int largest = i;
int l = 2*i + 1;
int r = 2*i + 2;
if (l < n && arr[l] > arr[largest])
largest = l;
if (r < n && arr[r] > arr[largest])
largest = r;
// Swap and continue heapifying if root is not largest
if (largest != i)
{
int swap = arr[i];
arr[i] = arr[largest];
arr[largest] = swap;
Page 5 of 34
Document Page
heapify(arr, n, largest);
}
}
static void printArray(int arr[])
{
int n = arr.length;
for (int i=0; i < n; ++i)
System.out.print(arr[i]+" ");
System.out.println();
}
public static void main(String args[])
{
int arr[] = {1,12,9,5,6,10};
HeapSort hs = new HeapSort();
hs.sort(arr);
System.out.println("Sorted array is");
printArray(arr);
}
}
Page 6 of 34
Document Page
Difference between Algorithm and Code
An algorithm is a well defined sequence of steps that provides a solution for a given problem,
while a code is one of the methods that can be used to represent an algorithm. While
algorithms can be written in natural language, code is written in a format that is closely related
to high level programming language structures. But code does not use specific programming
language syntax and therefore could be understood by programmers who are familiar with
different programming languages. Additionally, transforming an algorithm presented in code to
programming code could be much easier than converting an algorithm written in natural
language.
Preprocessor is a program that processes its input data to produce output that is used as input
to another program. The output is said to be a preprocessed form of the input data, which is
often used by some subsequent programs like compilers. The amount and kind of processing
done depends on the nature of the preprocessor; some preprocessors are only capable of
performing relatively simple textual substitutions and macro expansions, while others have the
power of full-fledged programming languages.
A compiler is a special program that processes statements written in a particular programming
language and turns them into machine language or "code" that a computer's processor uses.
Typically, a programmer writes language statements in a language such as Pascal or C one line
at a time using an editor. The file that is created contains what are called the source
statements. The programmer then runs the appropriate language compiler, specifying the
name of the file that contains the source statements.
Linker is a program that makes executable files. The linker resolves linkage issues, such as the
use of symbols or identifiers which are defined in one translation unit and are needed from
other translation units. Symbols or identifiers which are needed outside a single translation unit
have external linkage. In short, the linker's job is to resolve references to undefined symbols by
finding out which other object defines a symbol in question, and replacing placeholders with
the symbol's address. Of course, the process is more complicated than this; but the basic ideas
apply.
An interpreter translates high-level instructions into an intermediate form, which it then
executes. In contrast, a compiler translates high-level instructions directly into machine
language. Compiled programs generally run faster than interpreted programs. The advantage of
an interpreter, however, is that it does not need to go through the compilation stage during
which machine instructions are generated. This process can be time-consuming if the program
is long. The interpreter, on the other hand, can immediately execute high-level programs. For
Page 7 of 34

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
this reason, interpreters are sometimes used during the development of a program, when a
programmer wants to add small sections at a time and test them quickly. In addition,
interpreters are often used in education because they allow students to program interactively.
LO2 Explain the characteristics of procedural, object-orientated and event driven
programming. Conduct an analysis of a suitable Integrated Development Environment (IDE)
Characteristics of code:
A data type defines what kind of value a column can hold: integer data, character data,
monetary data, date and time data, binary strings, and so on. Such as Boolean, Numbers, String
values, Arrays, Objects, NULL, MISSING, Collation, Date, Binary.
A constant is an identifier (name) for a simple value. As the name suggests, that value cannot
change during the execution of the script (except for magic constants, which aren't actually
constants). A constant is case-sensitive by default. By convention, constant identifiers are
always uppercase.
A variable is any factor, trait, or condition that can exist in differing amounts or types. An
experiment usually has three kinds of variables: independent, dependent, and controlled. The
independent variable is the one that is changed by the scientist.
Method is a procedure, technique, or way of doing something, especially in accordance with a
definite plan. a manner or mode of procedure, especially an orderly, logical, or systematic way
of instruction, inquiry, investigation, experiment, presentation, etc.
Page 8 of 34
Document Page
A control structure is a block of programming that analyzes variables and chooses a direction in
which to go based on given parameters. The term flow control details the direction the program
takes (which way program control "flows").
Iteration is the act of repeating a process, either to generate an unbounded sequence of
outcomes, or with the aim of approaching a desired goal, target or result. Each repetition of the
process is also called an "iteration", and the results of one iteration are used as the starting
point for the next iteration.
Scope is an object that refers to the application model. It is an execution context for
expressions. Scopes are arranged in hierarchical structure which mimic the DOM structure of
the application. Scopes can watch expressions and propagate events.
Parameter passing The mechanism used to pass parameters to a procedure (subroutine) or
function. The most common methods are to pass the value of the actual parameter (call by
value), or to pass the address of the memory location where the actual parameter is stored (call
by reference).
In object-oriented programming, a class is an extensible program-code-template for creating
objects, providing initial values for state (member variables) and implementations of behavior
(member functions or methods).
In object-oriented programming, inheritance is the concept that when a class of objects is
defined, any subclass that is defined can inherit the definitions of one or more general classes.
This means for the programmer that an object in a subclass need not carry its own definition of
data and methods that are generic to the class (or classes) of which it is a part. This not only
speeds up program development; it also ensures an inherent validity to the defined subclass
object (what works and is consistent about the class will also work for the subclass).
Page 9 of 34
Document Page
Events enable a class or object to notify other classes or objects when something of interest
occurs. The class that sends (or raises) the event is called the publisher and the classes that
receive (or handle) the event are called subscribers. 1
In a typical C# Windows Forms or Web application, you subscribe to events raised by controls
such as buttons and list boxes. You can use the Visual C# integrated development environment
(IDE) to browse the events that a control publishes and select the ones that you want to handle.
The IDE automatically adds an empty event handler method and the code to subscribe to the
event.
An Integrated Development Environment (IDE) is an application that facilitates application
development. In general, an IDE is a graphical user interface (GUI)-based workbench designed
to aid a developer in building software applications with an integrated environment combined
with all the required tools at hand.
Most common features, such as debugging, version control and data structure browsing, help a
developer quickly execute actions without switching to other applications. Thus, it helps
maximize productivity by providing similar user interfaces (UI) for related components and
reduces the time taken to learn the language. An IDE supports single or multiple languages.
An integrated development environment (IDE) is an application that facilitates application
development. IDEs are designed to encompass all programming tasks in one application.
Therefore, IDEs offer a central interface featuring all the tools a developer needs, including the
following:
Code editor: This feature is a text editor designed for writing and editing source code. Source
code editors are distinguished from text editors because they enhance or simplify the writing
and editing of code.
Compiler: This tool transforms source code written in a human readable/writable language into
a form executable by a computer.
Debugger: This tool is used during testing to help debug application programs.
Page 10 of 34

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Build automation tools: These tools automate common developer tasks.
In addition, some IDEs might also include the following:
Class browser: This tool is used to examine and reference the properties of an object-oriented
class hierarchy.
Object browser: This feature is used to examine the objects instantiated in a running
application program.
Class hierarchy diagram: This tool allows the programmer to visualize the structure of object-
oriented programming code.
Typical integrated development tools:
o editor (with auto-indent, auto-completion, colorization, …) ;
o version control ;
o compiler/builder ;
o documentation extractor ;
o debugger ;
o testing tools ;
o Refactoring tools.
Page 11 of 34
Document Page
LO3 Implement basic algorithms in code using an IDE
Implementation:
Investigational Device Exemption (IDE) Submission Checklist
Please check ()
1. Cover Letter
Statement that submission is an original IDE application
Sponsor Information (Name, Address)
Sponsor Contact (Name, Telephone Number, Fax)
Device Name and Intended Use
Manufacturer Information (Name, Address)
Manufacturer Contact (Name, Telephone Number, Fax)
If an investigation involves an exception from informed consent for emergency research, state in
the Cover Letter that the investigation is subject to 21 CFR 50.24 requirements.
Other Information in Cover Letter (as appropriate):
Pre-IDE/Pre-IDE meetings: Describe your contacts with the FDA review division. If a Pre-IDE
document was submitted, state the Pre-IDE number and name of FDA contact, if known, who
reviewed the Pre-IDE. If a Pre-IDE meeting occurred, give name of FDA contact person and copy of
meeting minutes.
Waiver Requests: Identify any requests for waivers and include a justification for the waiver.
Referenced Files: Identify any files by reference (for example, approved PMA, 510(k), IDE, Device
Master File).
Note: If you are not the holder of these referenced files, include a letter from the holder of the
files, which grants FDA permission to reference the files in its review of your current application.
2. Table of Contents
Provide a detailed Table of Contents page
Page 12 of 34
Document Page
Investigational Device Exemption (IDE) Submission Checklist
Please check ()
3. Report of Prior Investigations
Report of all prior clinical, animal and laboratory testing
Bibliography of all relevant publications, whether adverse or supportive
Copies of all published and unpublished adverse information.
Summary of all other relevant unpublished information
Statement that non-clinical tests comply with 21 CFR 58, GLP regulation
Note: If any studies were not conducted in compliance with the GLP regulation, a brief statement
of the reason for the noncompliance must be provided. Failure or inability to comply with this
requirement does not justify failure to provide information on a relevant non-clinical test study.
4. Investigational Plan (Purpose)
Name and intended use of the device
Objectives of the investigation
Duration of the investigation (specify in months and years)
5. Written Protocol
Objectives, hypothesis or question to be answered
Description of type of study
Description of study conduct
Description of statistical methodology to be used
Case reports forms
6. Risk Analysis
Description and analysis of all increased risks to the research subjects
Manner in which risks will be minimized
Justification for the investigation
Page 13 of 34

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Investigational Device Exemption (IDE) Submission Checklist
Please check ()
Description of patient population, including number, age, sex and condition
7. Description of the Device
Description of each important component, ingredient and property
Principle of operation of the device
Description of any anticipated changes in the device during the investigation
8. Monitoring Procedures
Written procedure(s) for monitoring the investigation
Name and address of the Monitor
9. Manufacturing Information – (methods, facilities and controls)
Manufacturing
Processing
Packing
Storage
Installation
Note: This section must provide enough information for FDA to evaluate the quality control of the
device (e.g., that the device will meet the intended specifications).
10. Investigator Information
An example of an Investigator agreement
The Investigator's curriculum vitae
Where applicable, a statement of the Investigator's relevant experience (including the dates,
location, extent and type of experience)
If the Investigator was involved in an investigation or other research that was terminated, an
explanation of the circumstances that led to termination
Page 14 of 34
Document Page
Investigational Device Exemption (IDE) Submission Checklist
Please check ()
Conduct the investigation in accordance with the agreement, the investigational plan, all
applicable FDA regulations, and conditions of approval imposed by the reviewing IRB and FDA
Supervise all testing of the device involving human subjects
Ensure that the requirements for obtaining informed consent are met.
Certification that all participating Investigators have signed the agreement and that no Investigator
will be added until the agreement is signed
Name and address of Investigators who have signed the agreement
11. IRB Information
Name, address and chairperson of each IRB
Certification of the action taken by each IRB, (i.e., approval)
Number of IRBs that have approved the investigation
Number of IRBs that are currently reviewing the investigation
Number of IRBs expected to review it in the future
Any other institutions not listed above but participating in the investigation
12. Sales Information
Statement as to whether the device is to be sold to Investigators
If YES, provide the amount to be charged
Explanation why sale does not constitute commercialization
Note: 21 CFR 812.7(b) prohibits the commercialization of an investigational device by charging
subjects or Investigators for a device a price larger than necessary to recover costs of manufacture,
research, development, and handling.
13. Labeling
Copies of all labeling for the device must be provided
Page 15 of 34
Document Page
Investigational Device Exemption (IDE) Submission Checklist
Please check ()
Labeling must include the following:
"CAUTION-Investigational Device. Limited by Federal (or United States) Law to Investigational
Use."
Adequate information for the purposes of the investigation, including the name and place of
business of the manufacturer, packer, or distributor, the quantity of contents, and a description of
all relevant contraindications, hazards, adverse effects, interfering substances or devices,
warnings, and precautions
Labeling does not promote device as safe and effective for the investigational use
Note: 21 CFR 812.7(d) prohibits the representation of an investigational device as safe and
effective for the purposes for which it is being investigated.
14. Informed Consent Materials
All informed consent forms contain required and appropriate optional elements
Copies of all forms and informational materials to be presented to subject included
15. Environmental Impact Assessment
Note: If applicable, you must make a claim for categorical exclusion from submission of an
environmental assessment. If the product meets the exclusion requirements, state “I claim
categorical exclusion under 21 CFR 34 (g), and devices shipped under the IDE are intended to be
used for clinical studies in which waste will be controlled or the amount of waste expected to
enter the environment may reasonably be expected to be nontoxic. To my knowledge, no
extraordinary circumstances exist.”
16. Other Information
Note: Provide additional information supportive of the investigation and any information FDA has
identified through previous contact or through guidance documents, as required.
17. Format
Use paper with nominal dimensions of 8 ½ by 11 inches
Use at least a 1½ inch wide left margin to allow for binding into jackets
Page 16 of 34

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Investigational Device Exemption (IDE) Submission Checklist
Please check ()
Use 3-hole punched paper to allow for binding into jackets
If submission exceeds 2-inch thickness, separate into volumes, identify volume number
Clearly and prominently identify new submissions: “Original IDE application”
All copies of each submission must be identical
Note: Do not combine submissions
Provide a detailed table of contents
Sequentially number the pages, and use tabs to identify each section
State on the outside wrapper what the submission is: “Original IDE Application”
All submissions, in triplicate, should be addressed to:
LO4 determine the debugging process and explain the importance of a coding standard
Review and reflection:
Page 17 of 34
Document Page
Debugging is the routine process of locating and removing bugs, errors or abnormalities from
programs. It’s a must have skill for any Java developer because it helps to find subtle bug that
are not visible during code reviews or that only happens when a specific condition occurs. The
Eclipse Java IDE provides many debugging tools and views grouped in the Debug Perspective to
help the you as a developer debug effectively and efficiently.
There are many improvements included in the latest Eclipse Java Development Tools
(JDT) release included in the Eclipse Oxygen Simultaneous Release. This article will start with a
beginner’s guide to start you with debugging. In the second part of the article, you will find a
more advanced guide to debugging and you’ll discover what’s new for debugging in Eclipse
Oxygen.
Beginner’s Guide to Quick Start Debugging
Here are some quick tips and tools that will help you get started quickly with debugging your
Java project.
1. Launching and Debugging a Java program
A Java program can be debugged simply by right clicking on the Java editor class file from
Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D,
J instead.
Page 18 of 34
Document Page
Either actions mentioned above creates a new Debug Launch Configuration and uses it to start
the Java application.
Page 19 of 34

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
In most cases, users can edit and save the code while debugging without restarting the
program.This works with the support of HCR (Hot Code Replacement), which has been
specifically added as a standard Java technique to facilitate experimental development and to
foster iterative trial-and-error coding.
2. Breakpoints
A breakpoint is a signal that tells the debugger to temporarily suspend execution of your
program at a certain point in the code.
To define a breakpoint in your source code, right-click in the left margin in the Java editor and
selectToggle Breakpoint. Alternatively, you can double-click on this position.
Page 20 of 34
Document Page
The Breakpoints view allows you to delete and deactivate Breakpoints and modify their
properties.
All breakpoints can be enabled/disabled using Skip All Breakpoints. Breakpoints can also be
imported/exported to and from a workspace.
3. Debug Perspective
The debug perspective offers additional views that can be used to troubleshoot an application
like Breakpoints, Variables, Debug, Console etc. When a Java program is started in the debug
mode, users are prompted to switch to the debug perspective.
Debug view – Visualizes call stack and provides operations on that.
Breakpoints view – Shows all the breakpoints.
Variables/Expression view – Shows the declared variables and their values.
Press Ctrl+Shift+d orCtrl+Shift+i on a selected variable or expression to show its value. You can
Page 21 of 34
Document Page
also add a permanent watch on an expression/variable that will then be shown in
the Expressions view when debugging is on.
Display view – Allows to Inspect the value of a variable, expression or selected text during
debugging.
Console view – Program output is shown here.
4.Stepping commands
The Eclipse Platform helps developers debug by providing buttons in the toolbar and key
binding shortcuts to control program execution.
Page 22 of 34

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
For more information about debugging visit: Eclipse Stepping Commands Help
Advanced Tools to Debug Complex Scenarios
This section will give you more advanced tips and tricks to help you debug your Java project.
The Eclipse Oxygen release includes many great improvements for Java debugging. Here’s a
quick overview.
1. Watchpoints, Exception Breakpoints, Conditional Breakpoints
a. Watchpoints - A watchpoint is a special breakpoint that stops the execution of an application
whenever the value of a given expression/field changes, without specifying where it might
occur. User can specify by Breakpoint Properties… if they want the execution to stop when the
watch expression isAccessed, Modified or both.
b. Exception Breakpoints – An exception breakpoint is specified for thrown exception using Add
Java Exception Breakpoint.
Page 23 of 34
Document Page
Breakpoint for NullPointerException will halt whenever/wherever this exception is thrown.
c. Condition Breakpoints – Eclipse users can create conditions to restrict the activation of
breakpoints.
Breakpoint will be activated only if value of Boolean b is true. Hit count can be provided to halt
the execution at nth hit of the breakpoint. The breakpoint is disabled until either it is re-
enabled or its hit count is changed or the program ends.
2. Remote Debugging
– The Eclipse IDE allows you to debug applications that runs on another Java Virtual Machine
(JVM) or even on another machine. You can create a new debug configuration of the Remote
Java Applicationtype. To enable remote debugging you need to start your Java application with
certain flags. Connection Type can be specified as a Socket Attach or Socket Listen. Socket
Listen supports multiple incoming connections.
Page 24 of 34
Document Page
New Features in Eclipse Oxygen
Here are the new features that have been added to the latest Eclipse Java IDE release.
1. Tracepoints
A new feature in the Eclipse Platform that allows users to creates conditional breakpoints to
print out messages without halting at the breakpoints and cluttering the code base.
Page 25 of 34

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
The Eclipse Platform created tracepoint with systrace template.
2. Trigger Point
Now users can activate Trigger Point. A set of trigger points can be defined for the breakpoints
in a workspace.
All the other breakpoints that are initially suppressed by triggers will be hit only after any of the
all Trigger Points have been hit. All the triggers are disabled after a Trigger Point is hit and will
be re-enabled after the run.
Page 26 of 34
Document Page
Any breakpoint can be set as a trigger point by using Breakpoint Properties via the dialog or the
detail pane of the Breakpoints view.
Triggers are rendered with an overlay of "T" and the breakpoints suppressed by the triggers are
rendered with an overlay of "T" with a cut.
2. Logical Structures
In the Variables view, collection objects directly show their contained elements instead of their
internal structure. Logical structures are now activated by default in the Oxygen release. Show
Logical Structurecan be turned off to show the internal structure.
The Show Logical Structure context menu lets you create, choose or edit the representation.
Page 27 of 34
Document Page
3. Method Result After Step Operation
Also new to the Oxygen release are Method Results. During debugging, the last method result
(per return or throw) that was observed during Step Into, Step Over or Step Return, is shown as
first line in the Variables view.
4. Launch Group
Also new in Oxygen, Launch Group launch configuration type allows you to launch multiple
other launch configurations sequentially, with configurable actions after launching each group
member. New launch groups can be created via the Run → Run Configurations... or Run →
Debug Configurations... dialogs.
Page 28 of 34

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Breakpoints Grouping and Sorting
Eclipse users can now group the breakpoints by different categories in Eclipse Oxygen.
Breakpoint Working Sets defines a group of breakpoints. User can perform actions like
enable/disable on a working set.
Page 29 of 34
Document Page
Breakpoints are sorted by Name by default, sorting order can be changed to Creation Time.
For more information about debugging visit: Eclipse Remote Debugging Help
Coding Techniques
Coding techniques incorporate many facets of software development and, although they
usually have no impact on the functionality of the application, they contribute to an improved
comprehension of source code. For the purpose of this document, all forms of source code are
considered, including programming, scripting, markup, and query languages.
The coding techniques defined here are not proposed to form an inflexible set of coding
standards. Rather, they are meant to serve as a guide for developing a coding standard for a
specific software project.
Page 30 of 34
Document Page
The coding techniques are divided into three sections:
o Names
o Comments
o Format
Names
Perhaps one of the most influential aids to understanding the logical flow of an application is
how the various elements of the application are named. A name should tell "what" rather than
"how." By avoiding names that expose the underlying implementation, which can change, you
preserve a layer of abstraction that simplifies the complexity. For example, you could
use GetNextStudent() instead ofGetNextArrayElement().
A tenet of naming is that difficulty in selecting a proper name may indicate that you need to
further analyze or define the purpose of an item. Make names long enough to be meaningful
but short enough to avoid being wordy. Programmatically, a unique name serves only to
differentiate one item from another. Expressive names function as an aid to the human reader;
therefore, it makes sense to provide a name that the human reader can comprehend. However,
be certain that the names chosen are in compliance with the applicable language's rules and
standards.
Following are recommended naming techniques:
Routines
Avoid elusive names that are open to subjective interpretation, such as Analyze() for a routine,
or xxK8 for a variable. Such names contribute to ambiguity more than abstraction.
In object-oriented languages, it is redundant to include class names in the name of class
properties, such as Book.BookTitle. Instead, use Book.Title.
Use the verb-noun method for naming routines that perform some operation on a given object,
such as CalculateInvoiceTotal().
In languages that permit function overloading, all overloads should perform a similar function.
For those languages that do not permit function overloading, establish a naming standard that
relates similar functions.
Variables
Page 31 of 34

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Append computation qualifiers (Avg, Sum, Min, Max, Index) to the end of a variable name
where appropriate.
Use customary opposite pairs in variable names, such as min/max, begin/end, and open/close.
Since most names are constructed by concatenating several words together, use mixed-case
formatting to simplify reading them. In addition, to help distinguish between variables and
routines, use Pascal casing (CalculateInvoiceTotal) for routine names where the first letter of
each word is capitalized. For variable names, use camel casing (documentFormatType) where
the first letter of each word except the first is capitalized.
Boolean variable names should contain Is which implies Yes/No or True/False values, such
as fileIsFound.
Avoid using terms such as Flag when naming status variables, which differ from Boolean
variables in that they may have more than two possible values. Instead of documentFlag, use a
more descriptive name such as documentFormatType.
Even for a short-lived variable that may appear in only a few lines of code, still use a meaningful
name. Use single-letter variable names, such as i, or j, for short-loop indexes only.
If using Charles Simonyi's Hungarian Naming Convention, or some derivative thereof, develop a
list of standard prefixes for the project to help developers consistently name variables. For
more information, see "Hungarian Notation."
For variable names, it is sometimes useful to include notation that indicates the scope of the
variable, such as prefixing a g_ for global variables and m_ for module-level variables in
Microsoft Visual Basic®.
Constants should be all uppercase with underscores between words, such
as NUM_DAYS_IN_WEEK. Also, begin groups of enumerated types with a common prefix, such
as FONT_ARIAL and FONT_ROMAN.
Tables
When naming tables, express the name in the singular form. For example,
use Employee instead of Employees.
When naming columns of tables, do not repeat the table name; for example, avoid having a
field called EmployeeLastName in a table called Employee.
Do not incorporate the data type in the name of a column. This will reduce the amount of work
needed should it become necessary to change the data type later.
Page 32 of 34
Document Page
Microsoft SQL Server
Do not prefix stored procedures with sp_, because this prefix is reserved for identifying system-
stored procedures.
Miscellaneous
Minimize the use of abbreviations. If abbreviations are used, be consistent in their use. An
abbreviation should have only one meaning and likewise, each abbreviated word should have
only one abbreviation. For example, if using min to abbreviate minimum, do so everywhere and
do not later use it to abbreviate minute.
o When naming functions, include a description of the value being returned, such
as GetCurrentWindowName().
o File and folder names, like procedure names, should accurately describe what purpose
they serve.
o Avoid reusing names for different elements, such as a routine called ProcessSales() and
a variable called iProcessSales.
o Avoid homonyms when naming elements to prevent confusion during code reviews,
such as write and right.
o When naming elements, avoid using commonly misspelled words. Also, be aware of
differences that exist between American and British English, such as color/colour and
check/cheque.
o Avoid using typographical marks to identify data types, such as $ for strings or % for
integers.
Conclusion
The different algorithms that people study are as varied as the problems that they solve.
However, chances are good that the problem you are trying to solve is similar to another
problem in some respects. By developing a good understanding of a large range of algorithms,
you will be able to choose the right one for a problem and apply it properly. Furthermore,
solving problems like those found in TopCoder’s competitions will help you to hone your skills
in this respect. Many of the problems, though they may not seem realistic, require the same set
of algorithmic knowledge that comes up every day in the real world.
Page 33 of 34
1 out of 33
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]