Vous êtes sur la page 1sur 5

Background

SoItware engineering is the study oI ways in which to create large and complex computer
applications and that generally involve many programmers and designers. At the heart oI
soItware engineering is with the overall design oI the applications and on the creation oI a design
that is based on the needs and requirements oI end users. While soItware engineering involves
the Iull liIe cycle oI a soItware project, is includes many diIIerent components - speciIication,
requirements gathering, design, veriIication, coding, testing, quality assurance, user acceptance
testing, production, and ongoing maintenance.Having an in-depth understanding on every
component oI soItware engineering is not mandatory, however, it is important to understand that
the subject oI data structures and algorithms is concerned with the coding phase. The use oI data
structures and algorithms is the nuts-and-blots used by programmers to store and manipulate
data.This article, along with the other examples in this section Iocuses on the essentials oI data
structures and algorithms. Attempts will be made to understand how they work, which structure
or algorithm is best in a particular situation in an easy to understand environment.
What is Data Structure and Algorithms?
A data structure is an arrangement oI data in a computer's memory or even disk storage.
An example oI several common data structures are arrays, linked lists, queues, stacks,
binary trees, and hash tables. Algorithms, on the other hand, are used to manipulate the
data contained in these data structures as in searching and sorting.
Many algorithms apply directly to a speciIic data structures. When working with certain
data structures you need to know how to insert new data, search Ior a speciIied item, and
deleting a speciIic item.

Commonly used algorithms include are useIul Ior:
Searching Ior a particular data item (or record).
Sorting the data. There are many ways to sort data. Simple sorting, Advanced
sorting
Iterating through all the items in a data structure. (Visiting each item in turn so as to
display it or perIorm some other action on these items)
Characteristics of Data Structures
Array:
Advantages
"uick Insert
Fast access iI index known
Drawbacks
Slow search
Slow deletes
Fixed size
Ordered Array:
Advantages
Faster search than unsorted array
Drawbacks
Slow inserts
Slow deletes
Fixed size
Stacks:
Advantage
Last-in, Iirst-out acces
Drawback
Slow access to other items
"ueue:
Advantage
First-in, Iirst-out access
Drawback
Slow access to other items
Linked LIsts:
Advantage
"uick inserts
"uick deletes
Drawback
Slow search
Binary Tree:
Advantage
"uick search
"uick inserts
"uick deletes
(If the tree remains balanced)
Drawback
Deletion algorithm is complex
Red-Black Tree
Advantage
"uick search
"uick inserts
"uick deletes
(Tree always remains balanced)
Drawback
Complex to implement
2-3-4 Tree:
Advantage
"uick search
"uick inserts
"uick deletes
(Tree always remains balanced)
(Similar trees good for disk storage)
Drawback
Complex to implement
Hash Table
Advantage
Very Iast access iI key is known
"uick inserts
Drawback
Slow deletes
Access slow iI key is not known
IneIIicient memory usage
Heap
Advantage
"uick inserts
"uick deletes
Access to largest item
Drawback
Slow access to other items
Graph
Advantage
Best models real-world situations
Drawback
Some algorithms are slow and very comples
What is Abstract Data Type?
An Abstract Data Type (ADT) is more a way oI looking at a data structure: Iocusing on
what it does and ignoring how it does its job. A stack or a queue is an example oI an ADT.
It is important to understand that both stacks and queues can be implemented using an
array. It is also possible to implement stacks and queues using a linked list. This
demonstrates the "abstract" nature oI stacks and queues: how they can be considered
separately Irom their implementation.
To best describe the term Abstract Data Type, it is best to break the term down into "data
type" and then "abstract".
data type
When we consider a primitive type we are actually reIerring to two things: a data
item with certain characteristics and the permissible operations on that data. An int
in Java, Ior example, can contain any whole-number value Irom -2,147,483,648 to
2,147,483,647. It can also be used with the operators , -, *, and /. The data type's
permissible operations are an inseparable part oI its identity; understanding the type
means understanding what operations can be perIormed on it.
In Java, any class represents a data type, in the sense that a class is made up oI data
(Iields) and permissible operations on that data (methods). By extension, when a
data storage structure like a stack or queue is represented by a class, it too can be
reIerred to as a data type. A stack is diIIerent in many ways Irom an int, but they are
both deIined as a certain arrangement oI data and a set oI operations on that data.
abstract
Now lets look at the "abstract" portion oI the phrase. The word abstract in our
context stands Ior "considered apart Irom the detailed speciIications or
implementation".
In Java, an Abstract Data Type is a class considered without regard to its
implementation. It can be thought oI as a "description" oI the data in the class and a
list oI operations that can be carried out on that data and instructions on how to use
these operations. What is excluded though, is the details oI how the methods carry
out their tasks. An end user (or class user), you should be told what methods to call,
how to call them, and the results that should be expected, but not HOW they work.
We can Iurther extend the meaning oI the ADT when applying it to data structures
such as a stack and queue. In Java, as with any class, it means the data and the
operations that can be perIormed on it. In this context, although, even the
Iundamentals oI how the data is stored should be invisible to the user. Users not
only should not know how the methods work, they should also not know what
structures are being used to store the data.
Consider Ior example the stack class. The end user knows that push() and pop()
(amoung other similar methods) exist and how they work. The user doesn't and
shouldn't have to know how push() and pop() work, or whether data is stored in an
array, a linked list, or some other data structure like a tree.
The Interface
The ADT speciIication is oIten called an interIace. It's what the user oI the class
actually sees. In Java, this would oIten be the public methods. Consider Ior
example, the stack class - the public methods push() and pop() and similar methods
Irom the interIace would be published to the end user

Vous aimerez peut-être aussi