CSC 217 Data Structure 1
CSC 217 Data Structure 1
For instance, in an object-oriented programming language, the data structure and its
associated methods are bound together as part of a class definition. In non-object-
oriented languages, there might be functions defined to work with the data structure,
but they aren't technically part of the data structure.
It's not only important to use data structures, but it's also important to choose
the proper data structure for each task. Choosing an ill-suited data structure
could result in slow runtimes or unresponsive code.
Early programming languages, such as Fortran, C and C++, let programmers define
their own data structures. Today, many programming languages include an extensive
collection of built-in data structures to organize code and information. For
example, Python lists and dictionaries and JavaScript arrays and objects are common
coding structures used for storing and retrieving information.
Software engineers use algorithms that are tightly coupled with the data structures,
such as lists, queues and mappings from one set of values to another. This approach
can be fused in a variety of applications, including managing collections of records in
a relational database and creating an index of those records using a data structure
called a binary tree.
Storing data. Data structures are used for efficient data persistence, such as
specifying the collection of attributes and corresponding structures used to store
records in a database management system.
Managing resources and services. Core operating system resources and services
are enabled using data structures such as linked lists for memory allocation, file
directory management and file structure trees, as well as process scheduling
queues.
Ordering and sorting. Data structures such as binary search trees -- also known
as an ordered or sorted binary tree -- provide efficient methods of sorting objects,
such as character strings used as tags. With data structures such as priority queues,
programmers can manage items organized according to a specific priority.
Indexing. Even more sophisticated data structures such as B-trees are used to
index objects, such as those stored in a database.
Searching. Indexes created using binary search trees, B-trees or hash tables speed
the ability to find a specific sought-after item.
Scalability. Big data applications use data structures for allocating and managing
data storage across distributed storage locations, ensuring scalability and
performance. Certain big data programming environments -- such as Apache
Spark -- provide data structures that mirror the underlying structure of database
records to simplify querying.
Characteristics of data structures
Data structures are often classified by their characteristics:
Linear or non-linear. This describes whether the data items are arranged in
sequential order, such as with an array, or in an unordered sequence, such as with a
graph.
Static and dynamic. This describes how the data structures are compiled. Static
data structures have fixed sizes, structures and memory locations at compile time.
Dynamic data structures have sizes, structures and memory locations that can
shrink or expand, depending on the use.
Data types
If data structures are the building blocks of algorithms and computer programs, the
primitive -- or base -- data types are the building blocks of data structures. The typical
base data types include the following:
This hierarchy shows how data types and data structures are related.
Types of data structures
The data structure type used in a particular situation is determined by the type
of operations that will be required or the kinds of algorithms that will be
applied. The various common data structures include the following:
Trie. A trie, also known as a keyword tree, is a data structure that stores
strings as data items that can be organized in a visual graph.
These are considered complex data structures, as they can store large
amounts of interconnected data.
A binary search tree is a set of nodes where each has a value and can point to two child nodes.
How long does it take an algorithm to process data within a structure (i.e., how
long does it take a program to process a given input)? Time complexity is often a
factor when selecting structures appropriate for machine learning applications.
Is the organization of the data structure and its functional interface easy to use?
Is the deletion of data stored in a data structure straightforward? There are times
when this, too, can be complex. For example, in linked lists, items can be deleted
by deleting a key, or by deleting a key in a specific position.
How easy is it to visualize the data structure? This can be an important criterion in
selection, as the graphing of data is generally useful in understanding real-life
problem-solving.
Linked lists are best if a program is managing a collection of items that don't need
to be ordered, constant time is required for adding or removing an item from the
collection, and increased search time is OK.
Stacks are best if the program is managing a collection that needs to support a
LIFO order.
Binary trees are good for managing a collection of items with a parent-child
relationship, such as a family tree.
Binary search trees are appropriate for managing a sorted collection where the goal
is to optimize the time it takes to find specific items in the collection.
Graphs work best if the application will analyze connectivity and relationships
among a collection of individuals in a social media network.
Structure is important for organizing and accessing data and for the people
responsible for it. Learn how organizations are structuring and managing their data
analytics teams.