Skip to content

DA1. Introduction to Data Structures and Algorithms

Statement

  • This course will build upon concepts such as abstract data types, date items, data types, and data structures.
  • Please define -in your own words- each of the following terms. Your definition must define what the term means and how it relates to the other terms. Assume that you are trying to explain what these terms mean to someone who does not know them.
    • Type
    • Data Item
    • Data Type
    • Abstract Data Type
    • Data Structure
    • Class
    • Member Function
    • Data Members
  • Review section 1.2 in the Shaffer text in preparation for this assignment.

Solution

  • A Type is a set of values that form a values pool that can be picked from. There are no limits on those values, they can be as little as two (Boolean type) or as many as infinity (Integer type).
  • A type can be simple or complex, simple types are atomic or primitive ones, such as integers, floats, characters, etc. Complex types are made up of simple types, such as arrays, structures, etc.
  • A Data Item is a value that is stored in a variable with simple types. It can be of any type. A complex data item usually consists of multiple simple data items grouped in some form.
  • A Data Type is a Type along with a set of operations that can be performed on it. It is a set of values and a set of operations that can be performed on those values. An example of a data type is the Integer type (in mathematics), which has the operations +, -, *, /, etc.
  • An Abstract Data Type is a software representation of a Data Type; which means it is a software component (usually an abstract class) that has its set of values defined along with a listing of operations (method) that can be performed on those values. Those methods are still abstract, that is, they are declared but not implemented (Shaffer, 2011).
  • A Data Structure is an implementation of an Abstract Data Type, that is, a software component that has its set of values defined along with a listing of operations (methods) that can be performed on those values. Those methods are implemented (Shaffer, 2011).
  • An Example of an Abstract Data Type is the Number class in Java, which is an abstract class that represents a number and has a set of abstract methods like intValue(), longValue(), floatValue(), etc. (Java 8 Documentation, n.d., Class Number).
  • An Example of a Data Structure would be the Integer class in Java, which is a concrete class that extends the Number class and implements its abstract methods; and has its own methods as well (Java 8 Documentation, n.d., Class Integer).
  • A Class is a software component that has data members and member functions. It is a template for creating objects. Each object created from a class is called an instance of that class and has data members and a copy of all instance member functions.
  • A class can be abstract or concrete. An abstract class is a class that has at least one abstract method. A concrete class is a class that has no abstract methods. An abstract class cannot be instantiated, but a concrete class can.
  • Data Members are Data Items that are stored in a class. They are the variables that are declared in a class. They can be either instance or static variables. Instance variables are stored in each instance of a class, while static variables are stored in the class itself. Static variables are usually used for constants or for variables that are shared by all instances of a class.
  • Member Functions are Methods that are declared in a class. They are the functions that are declared in a class. They can be either instance or static methods. Instance methods are called on an instance of a class, while static methods are called on the class itself. Static methods are usually used for utility functions or for functions that do not require an instance of a class to be called.

References