Data Structures: ADT and C++ Classes

Unit Objectives

  • Getting to know why data structures are important
  • Software development cycle
  • Getting to know basics of Object Oriented Programming
  • Learning Abstract Data Type
  •  

Reading List

  • Chapter 1 from the main textbook and web links provided by the instructor

Problems

  • Why data structures are important?
  • What procedures must be taken to develop good software?
  • What's the role of an ADT in Object Oriented Programming?
  • What are the basic steps in testing and  debugging?

 

Why Data Structures?

Data structure is a way to store information in a program. To solve a problem using a computer, we need to have a correct and efficient way to solve the problem (algorithm) but we also need to carefully organize the information (data). An algorithm is systematic methods and procedures to solve a specific problem. Quite often, the way we organize the information directly affects the performance, ease of programming and debugging of a program. So a good program is a combination of a good algorithm and  good data structures. An algorithm is about how to solve a problem and the data structure is about the organization of information that the algorithm is dealing with.

Program = Algorithms + Data Structures

You may have used arrays and some other simple data structures for the CSCI141/CSCI1411 Fundamentals of Computing and CSCI2320 Intermediate Programming. This course will guide you through many widely used advanced data structures and their proper applications. In addition, you'll learn and reinforce important concepts of object oriented programming using C++, and basics of software engineering.  


Software Development Cycle

Program design strategy

  1. specify the input and output
  2. Design an appropriate algorithm to solve the problem
  3. Choose appropriate data structures
  4. Translate the algorithm into a programming language of your choice (C++)
  5. Test and debug the program

There is no step like "write a program"

The software development cycle can be roughly illustrated as

  1. Specification
  2. Design
  3. Implementation

Specification

 The specification step includes following tasks

  1. Specifying precisely what the program is supposed to do
  2. Specifying what's the input of the program
  3. Specifying what's the output of the program

In this step, just ignore how the problem can be solved.

Design

The design step includes development of an algorithm and choosing the right data structures. The algorithm can be described in either a high level, programming language independent description for solving the problem. Since the detail is often omitted, the plain English is generally acceptable for this process, but sometimes the pseudo code is more desirable since it includes more detailed methods and is easier to translate into a programming languages.

Design step also outlines the data structures. All programs manipulate data in various form including text, number, picture, sound, etc. The data must be processed and stored. As mentioned above, data is the information manipulated by an algorithm.  So to make a program efficient, clear, correct and effective, data should be properly organized. Depending on the algorithm, usually there are matching or appropriate data structures beyond simple arrays, such as linked lists, stacks, queues, trees, and graphs. This process is especially important in object oriented programming since it considers algorithms and data structures are equally important and tightly related. Object oriented programming combines them in one package called Object.  The OOP will be detailed in the later units.

Implementation

Implementation is the actual source code written in a specific programming language that carries out the design. If you have a good specification and design, this final process is relatively straight forward to translate specification into pre- and post-conditions, and to translate algorithmic pseudo-code and data structures layout into actual source code.

What is a Good Program?


Programming Strategies

Before we start discussing the ADT and C++ Classes, let's think about the programming and effective strategies to solve problems as a whole. Take a look at this article


Object Oriented Software

Let's first discuss about what Object Oriented Software is. This article uses Smalltalk as an example of a true object oriented programming language but it's not widely used. Instead, C++ evolved substantially to incorporate OOP paradigm into widely used popular C language. Take a look at this article.


Object Oriented Software vs. Other Paradigm

This article is about the survey of programming techniques. It includes some advanced topics (linked list, and some basic software engineering concepts etc.) that we haven't discussed so far, but nonetheless it will give you a good idea about the main difference of the OOP and some historical perspective of the evolution of programming paradigm. Take a look at this article


Abstract Data Type

An abstract data type is a data structure and a collection of functions and procedures which operate on the data structure.

We'll call the functions and procedures methods (member functions in C++) and the data structure and its methods a class, i.e. we'll call our ADTs classes. An instance of the class is called an object . Objects represent objects in the real world and appear in programs as variables of a type defined by the class.

So what's the relationship between a class and an object?

A class is a template and an object is an instantiation from the class. You can think of an analogy to existing data types and variables. For example, if you want to declare a variable "mynumbers" in integer data type, you use "mynumbers" as a new variable name and create that variable using existing data type "integer". From OOP's point of view, "mynumbers" is an object and "integer" is a class. However, in this case, the class has only one data structure and no associated member function.  In addition, there's no mechanism for information hiding.

More formal definition of ADT can be found here.


 

Programming environments

Program source codes and/or examples in lectures will be given in C++. For homework and programming assignments only C++ should be used.

Computing facilities are available at LW814. There are PCs and Mac equipped with GNU compilers and debuggers. The official platform for this course is our departmental server csegrid.ucdenver.pvt, which is Unix(Linux or similar) with GNU C++ version 4.8 or later compiler and libraries. All homework assignments will be tested and graded on csegrid.ucdenver.pvt.  

 

If you prefer to work on your own PC at home, Clion is a good programming environment. It is free for students, and it supports C++ IDE that provides an integrated development environments including editor, project manger and debugger. You can download it from https://www.jetbrains.com/clion/. If you're not familiar with various programming environement listed below, I would recommend you to use Clion for programming on your home computer.

Detailed information on programming environment can be found from Programming Guideline.

 

Remote log-in to CSE Unix machines

If you're accessing csegrid server from outside of the campus, you must be on the University VPN. Here's how to connect to the University VPN.

Basic terminal access
Connect to the load balancer csegrid.ucdenver.pvt via ssh using the client of your choice.  A very simple one is putty available here

If you're using Mac, you can use the built-in mac terminal and connect to the server by "ssh csegrid.ucdenver.pvt" at prompt.

 

File Transfer between your home computer to csegrid.ucdenver.pvt

You can use a file transfer client such as FileZilla, a free ftp client.

Download it and connect to csegrid.ucdenver.pvt.

Again, make sure you're on the VPN.

 

I assume you have some basic experience in C++ programming from CSCI1410 and CSCI1411. You can use a direct compiler commands, but I recommend you to try Make utility using a Makefile.

Please refer to this tutorial for a detailed instruction with accessing the csegrid.

CSE_Grid_Tutorial

C++Code

 


 

Basics of testing and debugging

Program testing is important to make sure that the program generates correct answers in all reasonable situations. Choosing proper test data, boundary values, and basic debugging principles are described in chapter 1.3.

I highly recommend you to consider professional graphical development environments with debugging tools such as CLion, Code::Blocks or Eclipse. If you're using Windows/VC++ it has its own IDE and debugging tools. If you're using a Mac, Xcode has all the development tools. If you're working on other Unix platform on a remote terminal, usually text based console debuggers gdb, or dbx would do the job. Take a look at following debugging tutorials.

Debugging tutorials

Here's a pdf version of debugging tutorial.
 

Refer to the textbook chapter 1.3

 


To-Do List

Visit the programming guideline page and make sure that you understand them. Here's the check list.

  • make sure that you have an cse account
  • download the temperature conversion source code. Compile, link and run and print the outputs. You can use a direct compiler commands, but I recommend you to try Make utility using a Makefile.
  • visit Makefile tutorial sites at http://www.gnu.org/software/make/ for more detail and try/modify the sample Makefile a little bit to compile above two programs. 
  • For this, you need to update a few words from the sample Makefile, OBJ and TARGET. The programming guideline page has detailed step by step instruction, and sample code. This is a short youtube tutorial for Makefile.

Come to the first threaded discussion board and introduce yourself. Please note that class participation is one of the most important factors for the success of an online course and it will be partially counted toward your final grade.