0% found this document useful (0 votes)
4 views

Unit 1 Introduction & Array

The document outlines the structure and content of an examination paper for a data structures course, detailing the types of questions, learning objectives, prerequisites, and course outcomes. It covers various units including linear and non-linear data structures, algorithms, and operations such as insertion, deletion, searching, and sorting. Additionally, it discusses the characteristics, advantages, and classifications of data structures, emphasizing their importance in efficiently organizing and manipulating data.

Uploaded by

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

Unit 1 Introduction & Array

The document outlines the structure and content of an examination paper for a data structures course, detailing the types of questions, learning objectives, prerequisites, and course outcomes. It covers various units including linear and non-linear data structures, algorithms, and operations such as insertion, deletion, searching, and sorting. Additionally, it discusses the characteristics, advantages, and classifications of data structures, emphasizing their importance in efficiently organizing and manipulating data.

Uploaded by

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

INSTRUCTIONS :

1. Question No. 1 should be compulsory and cover the entire syllabus.


There should be 10 questions of short answer type of 2 marks each,
having at least 2 questions from each unit.

2. Apart from Question No. 1, rest of the paper shall consist of four
units as per the syllabus. Every unit should have two questions to
evaluate analytical/technical skills of candidate. However, student may
be asked to attempt only 1 question from each unit. Each question
should be of 10 marks, including its subparts, if any.
LEARNING OBJECTIVES:
In this course, the learners will be provided expertise in 1.
Understanding of the basic concepts of data structures and their
operations like, insertion, deletion, searching and sorting 2. Design
algorithms and pseudo codes of various linear and non-linear data
structures.
PRE-REQUISITES:
1. C Programming Skills
2. Discrete Mathematics
COURSE OUTCOMES (COs):

After completion of this course, the learners will be able to:


Syllabus:
UNIT – I
• Linear Data Structures- Static: Introduction to Algorithms- Attributes, Design Techniques, Time Space Trade
Off, Data Structures, Classification and Operations of Data Structures.
• Arrays: Single Dimension, Two-Dimension and Introduction to Multi Dimensions, Memory Representation,
Address Calculation, Sparse Matrices- Types, Representation.
• Searching and Sorting: Linear and Binary Search, Selection Sort, Bubble Sort, Insertion Sort, Merge Sort,
Elementary Comparison of Searching and Sorting Algorithms.
• Hashing: Hash Table, Hash Functions, and Collision Resolution.

UNIT – II
• Linear Data Structures-
Dynamic Introduction: Dynamic Memory Allocation, Dynamic Memory versus Static Memory Allocation.
Linked List Types: Singly Linked List, Circular Linked List, Doubly Linked List.
Operations: Creation, Insertion, Deletion, Modification, Searching, Sorting, Reversing, and Merging.
UNIT – III
• Abstract Data Types:
• Stacks: Introduction, Static and Dynamic Implementation, Operations, Applications- Evaluation and
Conversion between Polish and Reverse Polish Notations.
• Queues: Introduction, Static and Dynamic Implementation, Operations, Types- Linear Queue, Circular Queue,
Doubly Ended Queue.

UNIT – IV
Non-Linear Data Structures:
Introduction to Graphs: Notations & Terminologies, Representation of Graphs- Adjacency Matrix, Incidence
Matrix and Linked Representation.
Trees: Notations & Terminologies, Memory Representation, Binary Trees Types- Complete, Full, Strict,
Expression Binary Tree, Tree Traversals (Recursive), Binary Search Tree and Basic Operations
Introduction and Creation (Excluding Implementation): AVL Tree, Heap Tree, M- Way Tree, and B Tree.
Unit 1
Introduction
• Data: Collection of raw facts.
• Structure : Way of organizing information
• Data Object : A data object is a unique location in computer memory that contains the values
• Data Structure is a systematic way to organize data in order to use it efficiently.
Data Structure = Organized data + Allowed Operation
• Algorithm : Step by Step procedure to solve a particular function.
Program = Algorithm + Data Structure

Data Structure is a way of collecting and organising 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 some data which has player's name "Virat" and age 26. Here "Virat" is of String data
type and 26 is of integer data type.

In simple language, Data Structures are structures programmed to store ordered data, so that various operations
can be performed on it easily. It represents the knowledge of data to be organized in memory. It should be
designed and implemented in such a way that it reduces the complexity and increases the efficiency.
Characteristics of a Data Structure
• Correctness − Data structure implementation should implement its
interface correctly.
• Time Complexity − Running time or the execution time of operations
of data structure must be as small as possible.
• Space Complexity − Memory usage of a data structure operation
should be as little as possible.
Need of Data Structure
• As applications are getting complex and data rich, there are three common
problems that applications face now-a-days. • Data Search − Consider an
inventory of 1 million(106) items of a store. If the application is to search an
item, it has to search an item in 1 million(106) items every time slowing
down the search. As data grows, search will become slower. • Processor
speed − Processor speed although being very high, falls limited if the data
grows to billion records. • Multiple requests − As thousands of users can
search data simultaneously on a web server, even the fast server fails while
searching the data. To solve the above-mentioned problems, data
structures come to rescue. Data can be organized in a data structure in such
a way that all items may not be required to be searched, and the required
data can be searched almost instantly.
Advantages of Data Structures
• • Efficiency: Efficiency of a program depends upon the choice of data
structures. For example: suppose, we have some data and we need to perform
the search for a perticular record. In that case, if we organize our data in an
array, we will have to search sequentially element by element. hence, using
array may not be very efficient here. There are better data structures which can
make the search process efficient like ordered array, binary search tree or hash
tables. • Reusability: Data structures are reusable, i.e. once we have
implemented a particular data structure, we can use it at any other place.
Implementation of data structures can be compiled into libraries which can be
used by different clients. • Abstraction: Data structure is specified by the ADT
which provides a level of abstraction. The client program uses the data
structure through interface only, without getting into the implementation
details.
Execution Time Cases
• There are three cases which are usually used to compare various data structure's
execution time in a relative manner.
• Worst Case − This is the scenario where a particular data structure operation
takes maximum time it can take. If an operation's worst case time is ƒ(n) then this
operation will not take more than ƒ(n) time where ƒ(n) represents function of n.
• Average Case − This is the scenario depicting the average execution time of an
operation of a data structure. If an operation takes ƒ(n) time in execution, then m
operations will take mƒ(n) time.
• Best Case − This is the scenario depicting the least possible execution time of an
operation of a data structure. If an operation takes ƒ(n) time in execution, then the
actual operation may take time as the random number which would be maximum
as ƒ(n).
What you study in Data Structure?
• Logical or mathematical description of the structure.
• Implementation of structure on a computer using different computer
Languages, but here we use C for Implementation.
Basic Terminology: Elementary Data Organization

Data: Data are simply values or sets of values.

Data items: Data items refers to a single unit of values

Data items that are divided into sub-items are called Group items.
Group items
Ex: An Employee Namemay be divided into three sub-items- first name, middle name, and last name.

Elementary items Data items that are not able to divide into sub-items are called Elementary items.

Ex: SSN
An entity is something that has certain attributes or properties which may be assignedvalues. The values may be either numeric or non-numeric.

Ex: Attributes- Names, Age, Sex, SSN


Entity:
Values- Rohland Gail, 34, F, 134-34-5533

Entities with similar attributes form an entity set. Each attribute of an entity set has a range of values, the set of all possible values that could be assigned to the
Entity Set: particular attribute.

Meaningful or processed data is called information. The collection of data is organized into the hierarchy of fields, records and files

Field It is a single elementary unit of information representing an attribute of an entity.

Record is the collection of field values of a given entity.

is the collection of records of the entities in a given entity set.

File Each record in a file may contain many field items but the value in a certain field may uniquelydetermine the record in the file. Such a field K is called a primary
key and the values k1, k2, ….. in such a field are called keys or key values.

Records may also be classified according to length.

A file can have fixed-length records or variable-length records.

 In fixed-length records, all the records contain the same data items with the same amountof space assigned to each data item.

 In variable-length records file records may contain different lengths.

Example: Student records have variable lengths, since different students take different numbers of courses. Variable-length records have a minimum and
a maximum length.

The above organization of data into fields, records and files may not be complex
Classification of Data Structure
Primitive Data Structure
 Data Structures that are directly operated upon the machine – level
instructions are known as primitive data structures.
 It is used to represent the Standard / Predefine / Built – in Data types in
anyone of the computer language.
 It includes: Integer, Float / Double, Character, String, Pointers etc.
Non – Primitive Data Structure
 There are more sophisticated data structures.

 These are derived from the primitive data structures.

 The non-primitive data structures emphasize on structuring of a group of


homogeneous (same type) or heterogeneous (different type) data items.
 Lists, Stack, Queue, Tree, Graph are example of non-primitive data structures.

 The design of an efficient data structure must take operations to be performed


on the data structure.
• The data structures can also be classified on the basis of the following characteristics:

Characteristic Description

Linear In Linear data structures, the data items are arranged in a linear sequence. Ex: Array

Non-Linear In Non-Linear data structures, the data items are not in sequence. Ex: Tree, Graph

Homogeneous In homogeneous data structures, all the elements are of same type. Ex: Array

Non- Homogeneous In Non-Homogeneous data structure, the elements may or may not be of the same type. Ex: Structures

Static Static data structures are those whose sizes and structures associated memory locations are fixed, at compile time.

Ex: Array
Linear Data Structures:

• A data structure is called linear if all of its elements are arranged in the linear order. In linear data
structures, the elements are stored in non-hierarchical way where each element has the successors and
predecessors except the first and last element.
• It has Homogeneous Elements
• It is very easy to implement, since the memory of a computer is also organized in a linear fashion.
• Some commonly used Data Structures are:
• Array
• Linked List
• Stack
• Queue
Types of Linear Data Structures are given below:

1. Arrays: The elements of array share the same variable name but each one carries a different index number known as subscript. The array can
be one dimensional, two dimensional or multidimensional.

• The individual elements of the array age are:


• age[0], age[1], age[2], age[3], age[98], age[99].

2. Linked List: Linked list is a linear data structure which is used to maintain a list in the memory. It can be seen as the collection of nodes stored
at non-contiguous memory locations. Each node of the list contains a pointer to its adjacent node.

3. Stack: Stack is a linear list in which insertion and deletions are allowed only at one end, called top.
• A stack is an abstract data type (ADT), can be implemented in most of the programming languages. It is named as stack because it
behaves like a real-world stack, for example: - piles of plates or deck of cards etc.

4. Queue: Queue is a linear list in which elements can be inserted only at one end called rear and deleted only at the other end called front.
• It is an abstract data structure, similar to stack. Queue is opened at both end therefore it follows First-In-First-Out (FIFO) methodology
for storing the data items.
Non Linear Data Structures:

This data structure does not form a sequence i.e. each item or element is connected with two or more other items in a non-linear arrangement.

The data elements are not arranged in sequential structure.

It may exhibit either a hierarchical relationship or parent child relationship.

Types of Non Linear Data Structures are given below:

1. Trees: Trees are multilevel data structures with a hierarchical relationship among its
elements known as nodes. The bottommost nodes in the hierarchy are called leaf node
while the topmost node is called root node. Each node contains pointers to point
adjacent nodes.
Tree data structure is based on the parent-child relationship among the nodes.
Each node in the tree can have more than one children except the leaf nodes whereas each
node can have atmost one parent except the root node. Trees can be classfied into many
categories which will be discussed later in this tutorial.

2. Graphs: Graphs can be defined as the pictorial representation of the set of elements
(represented by vertices) connected by the links known as edges.
• A graph is different from tree in the sense that a graph can have cycle while the
tree can not have the one.
Other Types of Data Structure are:
• Static Data Structure : (Array)
• 1. The size of the structure is fixed.
• The content of the data structure can be modified but without changing
the memory space allocated to it.

• 2. Dynamic Data Structure: (Linked List)


• The size of the structure is not fixed and can be modified during the
operations performed on it.
• Dynamic Data Structures are designed to facilitate change of Data
Structures in the run time.
Operation
Operations on data structure
Traversing: Every data structure contains the set of data elements. Traversing the data structure means
visiting each element of the data structure in order to perform some specific operation like searching or
sorting.
Example: If we need to calculate the average of the marks obtained by a student in 6 different subject, we
need to traverse the complete array of marks and calculate the total sum, then we will devide that sum by the
number of subjects i.e. 6, in order to find the average.
Insertion: Insertion can be defined as the process of adding the elements to the data structure at any location.
If the size of data structure is n then we can only insert n-1 data elements into it.
Deletion: The process of removing an element from the data structure is called Deletion. We can delete an
element from the data structure at any random location.
If we try to delete an element from an empty data structure then underflow occurs.
Searching: The process of finding the location of an element within the data structure is called Searching.
There are two algorithms to perform searching, Linear Search and Binary Search. We will discuss each one of
them later in this tutorial.
Sorting: The process of arranging the data structure in a specific order is known as Sorting. There are many
algorithms that can be used to perform sorting, for example, insertion sort, selection sort, bubble sort, etc.
Merging: When two lists List A and List B of size M and N respectively, of similar type of elements, clubbed or
joined to produce the third list, List C of size (M+N), then this process is called merging.
Data structures: Organization of data

• The collection of data you work within a program have some kind of structure or organization.
• No matter how complex your data structures are, they can be broken down into two fundamental types:
• Contiguous
• Non-Contiguous.
• In contiguous structures, terms of data are kept together in memory (either RAM or in a file). An array is an
example of a contiguous structure. Since each element in the array is located next to one or two other
elements.
• In contrast, items in a non-contiguous structure and scattered in memory, but we linked to each other in
some way. A linked list is an example of a non- contiguous data structure. Here, the nodes of the list are
linked together using pointers stored in each node.
Contiguous structures:

Contiguous structures can be broken drawn further into two kinds:


 those that contain data items of all the same size
 those where the size may differ.

The first kind is called the array. Figure 1.3(a. array) shows an example of an array of numbers. In an array, each
element is of the same type, and thus has the same size.
The second kind of contiguous structure is called structure, figure 1.3(b. struct) shows a simple structure consisting
of a person‘s name and age. In a struct, elements may be of different data types and thus may have different sizes.

For example, a person‘s age can be represented with a simple integer that occupies two bytes of memory. But his or her
• Non-contiguous structures:
• Non-contiguous structures are implemented as a collection of data-items, called nodes, where each node can
point to one or more other nodes in the collection.
• The simplest kind of non-contiguous structure is linked list. A linked list represents a linear, one- dimension
type of non-contiguous structure, where there is only the notation of backwards and forwards. as shown in
figure 1.4(a. Linked List)
• A tree such as shown in figure 1.4(b. Tree) is an example of a two-dimensional non-contiguous structure.
Here, there is the notion of up and down and left and right. In a tree each node has only one link that leads
into the node and links can only go do the tree. The most general type of non-contiguous structure, called a
graph has no such restrictions. Figure 1.4(c. Graph) is an example of a graph.
• Hybrid structures:
• If two basic types of structures are mixed then it is a hybrid form. Then one part contiguous and another part
non-contiguous. For example, figure 1.5 shows how to implement a double–linked list using three parallel
arrays, possibly stored a past from each other in memory.

The array D contains the data for the list, whereas the array P and N hold the previous andnext
―pointers‘‘. The pointers are actually nothing more than indexes into the D array. For instance, D[i] holds the
data for node i and p[i] holds the index to the node previous to i, where may or may not reside at position i–1.
Like wise, N[i] holds the index to the next node in the list.
ADT (Abstract Data Type)
THANKYOU

(PLEASE CHECK HANDWRITTEN


NOTES AS WELL)

You might also like