Data Structures And Abstract Data Types Computer Science Essay

Published: November 9, 2015 Words: 1132

J. Hunter (1998) states that the use of data structures and algorithms is the fundamentals used by programmers to store and manipulate data. He has also stated that though knowledge of every part of software engineering is not compulsory, it is important to understand that the subject of data structures and algorithms is concerned with the coding phase.

According to Robert Lafore (2008), data structure is an arrangement of data in a computer's memory and Algorithms manipulate the data in these structures in various ways.

According to the site under Data-structures-and-algorithms.psexam.com, Data struc­ture is a way of stor­ing and orga­niz­ing data in a com­puter's memory or in a disk to be used effi­ciently. Data struc­tures enable a pro­gram­mer to men­tally struc­ture large amounts of data into man­age­able relationships.

All the above definitions tell us that Data structures are designed to arrange data in the computer's memory location to manipulate when necessary to achieve maximum performance in computer applications.

Data struc­tures will enable to do more or could be used less. For example, carry out fast search­ing or sort­ing of data or in a limited form.

Some common data structures are arrays, linked lists, queues, stacks, binary trees and hash files. But there are data structures that can be thought of as Abstract data types as well, the given examples above can be considered as ADTs except arrays. All most all data structures have both advantages and disadvantages.

When a data struc­ture pro­vides oper­a­tions, we can call the data struc­ture an abstract data type (ADT).

Algorithms are used to manipulate the data contained in these data structures as in searching and sorting. Many algorithms apply directly to a specific data structures. To work with certain data structures it is required to know how to insert new data, search or delete a specified item.

Algorithms are commonly useful for:

Searching for 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 perform some other action on these items)

Characteristics of Data Structures

Data Structure

Advantages

Disadvantages

Array

Quick inserts

Fast access if index known

Slow search

Slow deletes

Fixed size

Ordered Array

Faster search than unsorted array

Slow inserts

Slow deletes

Fixed size

Stack

Last-in, first-out access

Slow access to other items

Queue

First-in, first-out access

Slow access to other items

Linked List

Quick inserts

Quick deletes

Slow search

Binary Tree

Quick search

Quick inserts

Quick deletes

(If the tree remains balanced)

Deletion algorithm is complex

Red-Black Tree

Quick search

Quick inserts

Quick deletes

(Tree always remains balanced)

Complex to implement

2-3-4 Tree

Quick search

Quick inserts

Quick deletes

(Tree always remains balanced)

(Similar trees good for disk storage)

Complex to implement

Hash Table

Very fast access if key is known

Quick inserts

Slow deletes

Access slow if key is not known

Inefficient memory usage

Heap

Quick inserts

Quick deletes

Access to largest item

Slow access to other items

Graph

Best models real-world situations

Some algorithms are slow and very complex

NOTE: The data structures shown above (with the exception of the array) can be thought of as Abstract Data Types (ADTs).

Table 1.1

Source Author Jeff Hunter

Abstract Data Types

According to J. Hunter (1998), An Abstract Data Type (ADT) is a way of looking at a data structure on what it does and not how it does its job. Examples of ADT are stacks and queues. 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 of stacks and queues: how they can be considered separately from their implementation.

According to Nell Dale et al (1996), an abstract data type is a set of operations that are defined in a certain level without getting any limitations from operational details.

To describe the term Abstract Data Type better, we could break the term into "data type" and "abstract".

Data type - is an item with certain characteristics and the permissible operations and what operations can be performed on it.

Abstract - The word abstract in this context stands for "considered apart from the detailed specifications or implementation".

An Abstract Data Type is a "description" of the data and a list of operations that can be carried out on that data and instructions on how to use these operations. What is excluded is the details of how the methods carry out their tasks. For example an end user should be told what methods to call, how to call them, and the results that should be expected, but not HOW they work.

Further extension of the meaning of 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 data and the operations that can be performed on it. Therefore, even the basics of 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.

Example for the stack class, the end user knows that push() and pop() (among other similar methods) are available 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.

Abstract Data Type (ADT) makes it easy to spec­i­fy an algo­rithm if the operations needed could be indicated with­out hav­ing to think at the same time, about how the oper­a­tions are per­formed. Since there are usu­ally many ways to execute an ADT, it might be use­ful to write an algo­rithm that can be used with any of the pos­si­ble imple­men­ta­tions. Well-known ADTs, like the Stack ADT, are often imple­mented for it to be writ­ten once and used by many programmers.

The oper­a­tions on ADTs pro­vide a com­mon high-level lan­guage for spec­i­fy­ing and talk­ing about algo­rithms. For ADTs, we often differentiate the code that uses the ADT, called the client code, from the code that imple­ments the ADT, called provider code as it pro­vides a stan­dard set of ser­vices. One of the basic goals of an ADT is to sep­a­rate the inter­ests of the provider, who writes the code that imple­ments the ADT, and the client, who uses the ADT. The provider only has to worry about whether the imple­men­ta­tion is correct-according to the spec­i­fi­ca­tion of the ADT-and not how it will be used. Otherwise, the client thinks that the imple­men­ta­tion of the ADT is cor­rect and doesn't worry about the details.