You are on page 1of 5

CSC252: DATA STRUCTURES (2 UNITS)

Pre-requisite CSC 201 and CSC 102


Primitive types, arrays, records, strings and string processing, data
representation in memory, stack and heap allocation. Implementation
strategies for queue, stacks, trees, runtime storage management: pointers
and references, linked structures. Use C, C++ or java for implementation
Basic Concepts: Introduction to Data Structures
Data is one of the most powerful tools available to any business or organization that wants to not
only survive but rise to the top in today’s competitive and challenging world. The more
information available, the more options and better solutions to problems and obstacles open up.
Data Structure can be defined as the group of data elements which provides an efficient way of
storing and organising data in the computer so that it can be used efficiently.
Data structures can also be defined as a specific way of organizing data in a specialized format
on a computer so that the information can be organized, processed, stored, and retrieved quickly
and effectively. They are a means of handling information, rendering the data for easy use.
Basic Terminology
Data structures are the building blocks of any program or the software. Choosing the appropriate
data structure for a program is the most difficult task for a programmer. Following terminology
is used as far as data structures are concerned.
 Data: Data can be defined as an elementary value or the collection of values, for
example, student's name and his/her registration number are the data about the student.
 Data items: refer to the single unit of a value. Example Student’s name, Reg number,
Date of Birth etc. There are two types of Data item: Group item and Elementary items:
 Group item: These are data items that can be divided into sub-items. Example, the
name of a person is a group item because it can be divided nto surname, first
name and middle name. Another example includes address, date, qualification etc
 Elementary Items: These are data items that cannot be divided into sub-items.
Example: S/N, Age etc
 Record: Record can be defined as the collection of various data items, for example, if we
talk about the student entity, then its name, reg number, address, course and marks can be
grouped together to form the record for the student.
 File: A File is a collection of various records of one type of entity, for example, if there
are 60 employees in the class, then there will be 20 records in the related file where each
record contains the data about each employee.
 Attribute and Entity: An entity represents the class of certain objects. It contains
various attributes. Each attribute represents the particular property of that entity.
Example:
Entity: Customer
Attributes for the Entity “Customer”: First name, surname, Date of birth, Address,
Nationality, Phone number etc
 Field: Field is a single elementary unit of information representing the attribute of an
entity.
Classification of Data Structures
Data Structure is classified in basically two main categories -
 Primitive Data Structure
 Non Primitive Data Structure
Primitive and Non Primitive are further classified into many different types.
Primitive Data Structure
The primitive data structure is the basic data structure that directly operates upon the machine
instruction. Primitive data structure is a data structure that can hold a single value in a specific
location. Primitive data structure contains fundamental data types such as integer, float,
character, pointer, and these fundamental data types can hold a single type of value. For
example, integer variable can hold integer type of value, float variable can hold floating type of
value, character variable can hold character type of value whereas the pointer variable can hold
pointer type of value.
The examples of primitive data structure are float, character, integer and pointer, Character and
Real. The value to the primitive data structure is provided by the programmer.
 Integer: The integer data type contains the numeric values. It contains the whole numbers
that can be either negative or positive. When the range of integer data type is not large
enough then in that case, we can use long.
 Float: The float is a data type that can hold decimal values. When the precision of
decimal value increases then the Double data type is used.
 Boolean: It is a data type that can hold either a True or a False value. It is mainly used for
checking the condition.
 Character: It is a data type that can hold a single character value both uppercase and
lowercase such as 'A' or 'a'.
 Pointer: Pointer holds the memory address of another value
 Float: Float stores double precision floating point number

Importance of Data Structures


1. They facilitate greater processing speeds. Large amounts of data require faster
processing, and data structures help organize the data into forms that are easier to work
with and process.
2. They make it easier to search for data. Data structures organize information into workable
forms that are easier to conduct required searches for.
3. They are reusable. Once you implement a given data structure, it can be used anywhere.
There is no need to make a new structure. This function saves time and resources.
4. They make it easy to handle multiple requests. You rarely find a single user accessing a
database. Instead, it’s common to have hundreds, if not thousands, of users searching and
interacting with a database. Data structures arrange information so that users don’t have
to search every item — they can instantly search just the required data.

Application Areas of Data Structures


 Compiler Design
 Operating System
 Database Management Science (DBMS)
 Statistical Analysis Package
 Artificial Intelligence
 Graphics
 Simulation
 Numerical Analysis

Operations on Data Structure


All the data structures perform various operations on its elements. These are common to all data
structures and are listed as follows:
 Searching: This operation is performed to search for a particular element or a key. The
most common searching algorithms are sequential/linear search and binary search.
 Sorting: Sorting operation involves arranging the elements in a data structure in a
particular order either ascending or descending. There are various sorting algorithms that
are available for data structures. Most popular among them are Quicksort, Selection sort,
Merge sort, etc.
 Insertion: Insertion operation deals with adding an element to the data structure. This is
the most important operation and as a result of the addition of an element, the
arrangement changes and we need to take care that the data structure remains intact.
 Deletion: Deletion operation removes an element from the data structure. The same
conditions that are to be considered for insertion are to be fulfilled in case of the deletion
operation as well.
 Traversing: We say that we traverse a data structure when we visit each and every
element in the structure. Traversing is required to carry out certain specific operations on
the data structure

Records
A record is a special type of data structure that, unlike arrays, collects different data types that
define a particular structure such a book, product, person and many others. A record is a
collection of fields, possibly of different data types, typically in fixed number and sequence. The
fields of a record may also be called members, particularly in object-oriented programming. For
example, a date could be stored as a record containing a numeric year field, a month field
represented as a string, and a numeric day-ofmonth field. A Personnel record might contain a
name, a salary, and a rank. Records are distinguished from arrays by the fact that their number of
fields is typically fixed, each field has a name, and that each field may have a different type. A
record type is a data type that describes such values and variables. Most modern computer
languages allow the programmer to define new record types. The definition includes specifying
the data type of each field and an identifier (name or label) by which it can be accessed. Records
can exist in any storage medium, including main memory and mass storage devices such as
magnetic tapes or hard disks. Records are a fundamental component of most data structures,
especially linked data structures. Many computer files are organized as arrays of logical records,
often grouped into larger physical records or blocks for efficiency.

You might also like