data12 - Introduction to Data Structures Introduction...

This preview shows pages 1–2. Sign up to view the full content.

Computer algorithms are used to solve problems where the computer is one of the tools in the problem solvers arsenal. As we have mentioned many times, the success or failure of our algorithm will in part depend on how well we can represent the data that is required to solve our problem. If the data is inefficiently or unnaturally represented, then it will be very difficult for our algorithm to overcome this and be an efficient solution to the problem. Many of the constructs that we have seen in the C language are designed to allow us to better represent the data for our problem. Arrays for example, allow us to group together into a single structure, data which is similar in nature and related in some ways to each other. Similarly, the concept of the record allowed us to group heterogeneous data together in very complex fashion to help us model the data for our specific problem. For many problems, the representation of the data is best if it is modeled in certain conventional fashion. These are classic data structures that can be used to solve an incredibly wide array of problems through the representation of the data for that problem. Lists, stacks, queues, and trees, to name but a few of these data structures can be used to solve vastly different types of problems, but they are so fundamental to problem solving that even solutions to very complex problems will still take advantage of the representation of data that is provided by these structures. The remainder of our course will focus primarily on these various data structures. We will examine how the structure is represented in C, the types of problems to which the structure is suited and algorithms which allow us access to the data contained in the structure. Static vs. Dynamic Data Structures Most modern programming languages provide the built in type of an array . An array is a data structure which is (in most languages) statically allocated. This means that the space required for the array that you specify in your program is set aside before the program begins execution (during compilation). Once the program is in execution you cannot change the size of the array, it can neither become smaller nor grow larger once execution begins. This restriction can be a problem for certain types of programs. However, there are even greater restrictions on the efficiency of arrays for certain types of problems. Consider the following situation: we have an array capable of holding 10 elements and currently the array contains 8 elements. The elements in the array are maintained in ascending order (let’s assume the elements are just numbers). Lets’ assume the array looks like the one below:

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 11

data12 - Introduction to Data Structures Introduction...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online