0% found this document useful (0 votes)
18 views7 pages

Lecture-2 DS

The document outlines the syllabus for a course on Data Structures using C, covering key topics such as algorithms, data types, and memory representation. It explains the classification of data structures into primitive and non-primitive types, along with their characteristics and examples. Additionally, it discusses memory allocation methods in C, including static and dynamic allocation, and provides syntax for memory management functions.

Uploaded by

Vedaang Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views7 pages

Lecture-2 DS

The document outlines the syllabus for a course on Data Structures using C, covering key topics such as algorithms, data types, and memory representation. It explains the classification of data structures into primitive and non-primitive types, along with their characteristics and examples. Additionally, it discusses memory allocation methods in C, including static and dynamic allocation, and provides syntax for memory management functions.

Uploaded by

Vedaang Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

UGCSA112: Data Structures Using C

(BCA – II Sem)b

Unit-1

Module 1: Introduction to Algorithms & Data Structure (Syllabus)

Introduction: Data types, Abstraction, Concept of data structure, Types of data structures,
Operations on Data Structures, Introduction to Algorithms, Writing Pseudo codes,
Algorithm analysis, Complexity of algorithms and Time space trade-off, Arrays, Address
calculation in a single and multi- dimensional array. Searching: Linear and Binary search
algorithms and their complexity analysis.

INTRODUCTION: Computer Science is the study of data, its representation and transformation
by computer. For every data object, we consider the class of operations to be performed and then
the way to represent the object so that these operations may be efficiently carried out. We require
two techniques for this:

• Devise alternative forms of data representation

• Analyze the algorithm which operates on the structure.

These are several terms involved above which we need to know carefully before we proceed. These
include data structure, data type and data representation.

A data type is a term which refers to the kinds of data that variables may hold. With every
programming language there is a set of built-in data types. This means that the language allows
variables to name data of that type and provides a set of operations which meaningfully
manipulates these variables. Some data types are easy to provide because they are built-in into the
computer’s machine language instruction set, such as integer, character etc. Other data types
require considerably more efficient to implement. In some languages, these are features which
allow one to construct combinations of the built-in types (like structures in ‘C’) . However, it is
necessary to have such mechanism to create the new complex data types which are not provided
by the programming language. The new type also must be meaningful for manipulations. Such
meaningful data types are referred as abstract data type.

DATA STRUCTURE: Data Structures are the programmatic way of storing data so that data can
be used efficiently. Almost every enterprise application uses various types of data structures in one
or the other way.

Thus, a data structure is the portion of memory allotted for a model, in which the required data can
be arranged in a proper fashion. Data Structure is a way of collecting and organizing data in such
a way that we can perform operations on these data in an effective way. Data Structures is about
rendering data elements in terms of some relationship, for better organization and storage. For
example, we have data player's name "Rahul" and his age 28. Here "Rahul" is of String data type
and 28 is of integer data type.

Programming: Programming is the process of taking an algorithm and encoding it into a notation,
a programming language, so that it can be executed by a computer. Although many programming
languages and many different types of computers exist, the important first step is the need to have
the solution. Without an algorithm there can be no program. Computer science is not the study of
programming. Programming, however, is an important part of what a computer scientist does.
Programming is often the way that we create a representation for our solutions. Therefore, this
language representation and the process of creating it becomes a fundamental part of the discipline.
CONCEPTS OF DATA AND INFORMATION:

Data: Data are simply values or set of values. A data item refers to a single unit of item.

Information: Information is any entity or form that provides the answer to a question of some
kind or resolves uncertainty. It is thus related to data and knowledge, as data represents values
attributed to parameters, and knowledge signifies understanding of real things or abstract concepts.

Definition of Data Structure:

Data Structure is the way of storing data in computer’s memory so that it can be used easily and
efficiently. There are different data-structures used for the storage of data. It can also be defined as
a mathematical or logical model of a particular organization of data items. The representation of
particular data structure in the main memory of a computer is called as storage structure.

or

A Data structure is a storage that is used to store and organize data. It is a way of arranging data
on a computer so that it can be accessed and updated efficiently.

or

A Data structure is not only used for organizing the data. It is also used for processing, retrieving,
and storing data.
CLASSIFICATION OF DATA STRUCTURES: -

A Data Structure can be broadly classified into

(i) Built-in/Primitive data structure

(ii) User Defined/Non-primitive data structure

(i) Primitive Data Structure: The Data Structures, typically those data structure that are
directly operated upon by machine level instructions i.e. the fundamental data types such as int,
float, double in case of C, are known as primitive data structures.

(ii) Non-primitive data structure: The Data Structures, which are not primitive, are called
non-primitive data structures. There are two types of non-primitive data structures.
Linear data structure: Data structure in which data elements are arranged sequentially or linearly,
where each element is attached to its previous and next adjacent elements, is called a linear data
structure. Examples of linear data structures are array, stack, queue, linked list, etc.

• Static data structure: Static data structure has a fixed memory size. It is easier to access the
elements in a static data structure. An example of this data structure is an array.
• Dynamic data structure: In the dynamic data structure, the size is not fixed. It can be
randomly updated during the runtime which may be considered efficient concerning the
memory (space) complexity of the code. Examples of this data structure are queue, stack,
etc.

Non-linear Data Structure: Data structures where data elements are not placed sequentially or
linearly are called non-linear data structures. In a non-linear data structure, we can’t traverse all
the elements in a single run only. Examples of non-linear data structures are trees and graphs.

Abstract data types: Abstract Data type (ADT) is a type or class for objects whose behavior is
defined by a set of value and a set of operations. ADT only mentions what operations are to be
performed but not how these operations will be implemented. It does not specify how data will be
organized in memory and what algorithms will be used for implementing the operations. It is called
“abstract” because it gives an implementation independent view. The process of providing only
the essentials and hiding the details is known as abstraction. Example: Stack, Queue etc.

IMPLEMENTATION ASPECTS:

MEMORY REPRESENTATION:

There are 2 types of memory allocations possible in C:


1.Compile time or Static allocation

2.Runtime or Dynamic allocation

1. Compile time or static allocation: Compile time memory allocation means reserving memory
for variables, constants during the compilation process. So you must exactly know how many bytes
you require? This type of allocation is done with the help of Array. The biggest disadvantage of
compile time memory allocation, we do not have control on allocated memory. You cannot
increase, decrease or free memory, the compiler takes care of memory management. We can also
refer compile time memory allocation as static or stack memory allocation.

2. Runtime or Dynamic allocation: Memory allocated at runtime either through malloc(), calloc()
or realloc().You can also refer runtime memory allocation as dynamic or heap memory allocation.
Professional programmers prefer dynamic memory allocation more over static memory allocation.
Since, we have full control over the allocated memory. Which means we can allocate, de-allocate
and can also reallocate memory when needed.

a. malloc(): allocates requested size of bytes and return a void pointer pointing to the first byte
the allocated space.

Syntax: malloc (no. of elements* size of each element);

For example:

int *ptr;

ptr=(int*)malloc(10*sizeof(int));
b. calloc(): allocate space for an array of element and initialize them to zero and then return a void
pointer to memory.

Syntax: malloc (no. of elements, size of data type);

For example:

int *ptr; ptr=(int*)calloc(10,2);

c. realloc(): modify the size of previously allocated space.

Syntax: ptr=realloc(ptr,newsize);

d. free(): releases previously allocated memory.

You might also like