0% found this document useful (0 votes)
11 views21 pages

1.3.4 Structure

Uploaded by

harmnpreetkaur15
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)
11 views21 pages

1.3.4 Structure

Uploaded by

harmnpreetkaur15
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/ 21

UNIVERSITY INSTITUTE OF COMPUTING

Bachelor of Computer Application


Subject Name: Data Structure
23CAT-201/ 23SCT-201
VISION

To be a Centre of Excellence for nurturing computer professionals with


strong application expertise through experiential learning and research
for matching the requirements of industry and society instilling in them
the spirit of innovation and entrepreneurship.

2
Mission of the Department

M1. To provide innovative learning centric facilities and quality-


oriented teaching learning process for solving computational problems.
M2. To provide a frame work through Project Based Learning to
support society and industry in promoting a multidisciplinary activity.
M3. To develop crystal clear evaluation system and experiential
learning mechanism aligned with futuristic technologies and industry.
M4. To provide doorway for promoting research, innovation and
entrepreneurship skills incollaboration with industry and academia.
M5. To undertake societal activities for upliftment of rural/deprived
sections of the society.
3
Program Outcomes
• PO1 Apply mathematics and computing fundamental and domain concepts to find out the solution of defined problems and requirements. (Computational
Knowledge)
• PO2 Use fundamental principle of Mathematics and Computing to identify, formulate research literature for solving complex problems, reaching appropriate
solutions. (Problem Analysis)
• PO3 Understand to design, analyze and develop solutions and evaluate system components or processes to meet specific need for local, regional and global public
health, societal, cultural, and environmental systems.
• PO4 (Design /Development of Solutions)Use expertise research-based knowledge and methods including skills for analysis and development of information to
reach valid conclusions. (Conduct Investigations of Complex Computing Problems)
• PO5 Adapt, apply appropriate modern computing tools and techniques to solve computing activities keeping in view the limitations. (Modern Tool Usage)
• PO6 Exhibiting ethics for regulations, responsibilities and norms in professional computing practices. (Professional Ethics)
• PO7 Enlighten knowledge to enhance understanding and building research, strategies in independent learning for continual development as computer applications
professional. (Life-long Learning)
• PO8 Establishing strategies in developing and implementing ideas in multi- disciplinary environments using computing and management skills as a member or
leader in a team. (Project Management and Finance)
• PO9 Contribute to progressive community and society in comprehending computing activities by writing effective reports, designing documentation, making
effective presentation, and understand instructions. (Communication Efficacy)
• PO10 Apply mathematics and computing knowledge to access and solve issues relating to health, safety, societal, environmental, legal, and cultural issues within
local, regional and global context. (Societal and Environmental Concern)
• PO11 Gain confidence for self and continuous learning to improve knowledge and competence as a member or leader of a team. (Individual and Teamwork)
• PO12 Learn to innovate, design and develop solutions for solving real life business problems and addressing business development issues with a passion for quality
competency and holistic approach. (Innovation and Entrepreneurship)

4
Program Educational Objectives

PEO1 Demonstrate analytical and design skills including the ability to generate creative solutions and foster
team-oriented professionalism through effective communication in their careers.
PEO2 Expertise in successful careers based on their understanding of formal and practical methods of
application development using the concept of computer programming languages and design principles in
accordance to industry 4.0
PEO3 Exhibit the growth of the nation and society by implementing and acquiring knowledge of upliftment of
health, safety and other societal issues.
PEO4 Implement their exhibiting critical thinking and problem- solving skills in professional practices or tackle
social, technical and business challenges.

5
Program Specific Outcomes

PSO1 Analyze their abilities in systematic planning, developing, testing


and executing complex computing applications in field of Social-Media
and Analytics, Web Application Development and Data Interpretations.
PSO2 Apprise in-depth expertise and sustainable learning that
contributes to multi-disciplinary creativity, permutation, modernization
and study to address global interest.

6
Topic To be Covered

• Structure (CO2)
• Self Referential Structure (CO2)
• Types of Self Referential Structure (CO2)
Structure

• A structure is a composite data type that defines a grouped list of variables that are to be
placed under one name in a block of memory. It allows different variables to be accessed by
using a single pointer to the structure.
• Syntax
struct structure_name
{
data_type member1;
data_type member2;
.
.
data_type memeber;
};
Advantages

• It can hold variables of different data types.


• We can create objects containing different types of attributes.
• It allows us to re-use the data layout across programs.
• It is used to implement other data structures like linked lists, stacks,
queues, trees, graphs etc.
Create a Structure

• To create a structure, use the struct keyword and declare each of its
members inside curly braces.
• After the declaration, specify the name of the structure variable
(myStructure in the example below):
struct { // Structure declaration
int myNum; // Member (int variable)
string myString; // Member (string variable)
} myStructure; // Structure variable
Access Structure Members
To access members of a structure, use the dot syntax (.):

// Declare a structure named "car" // Create another car structure and store it in myCar2;
struct car { car myCar2;

string brand; myCar2.brand = "Ford";


myCar2.model = "Mustang";
string model;
myCar2.year = 1969;
int year;
};
// Print the structure members

int main() { cout << myCar1.brand << " " << myCar1.model << " " <<
myCar1.year << "\n";
// Create a car structure and store it in myCar1; cout << myCar2.brand << " " << myCar2.model << " " <<
car myCar1; myCar2.year << "\n";

myCar1.brand = "BMW";
return 0;
myCar1.model = "X5";
}
myCar1.year = 1999;
Self Referential Structures

• Self Referential structures are those structures that have one or more
pointers which point to the same type of structure, as their member.
Example:
struct node {
int data1;
char data2;
struct node* link;
};

int main()
{
struct node ob;
return 0;
}

• In the above example ‘link’ is a pointer to a structure of type ‘node’. Hence, the structure ‘node’ is a self-referential
structure with ‘link’ as the referencing pointer.
An important point to consider is that the pointer should be initialized properly before accessing, as by default it
contains garbage value.
Types of Self Referential Structures

• Self Referential Structure with Single Link


• Self Referential Structure with Multiple Links
Self Referential Structure with Single Link:

• These structures can have only one self-pointer as their member. The
following example will show us how to connect the objects of a self-
referential structure with the single link and access the corresponding
data members. The connection formed is shown in the following
figure.
Implementation
#include <stdio.h> // Initialization
struct node { ob2.link = NULL;
int data1; ob2.data1 = 30;
char data2; ob2.data2 = 40;
struct node* link;
};
// Linking ob1 and ob2
int main()
ob1.link = &ob2;
{
struct node ob1; // Node1
// Initialization // Accessing data members of ob2 using ob1
ob1.link = NULL; printf("%d", ob1.link->data1);
ob1.data1 = 10; printf("\n%d", ob1.link->data2);
ob1.data2 = 20; return 0;
struct node ob2; // Node2 }
Self Referential Structure with Multiple
Links:

• Self referential structures with multiple links can have more than one
self-pointers. Many complicated data structures can be easily
constructed using these structures. Such structures can easily connect
to more than one nodes at a time. The following example shows one
such structure with more than one links.
The connections made in the above example can be understood using
the following figure.
Implementation: struct node ob3; // Node3

// Initialization
#include <stdio.h>
ob3.prev_link = NULL;
struct node { ob3.next_link = NULL;
int data; ob3.data = 30;

struct node* prev_link; // Forward links

struct node* next_link; ob1.next_link = &ob2;

ob2.next_link = &ob3;
};
int main()
// Backward links
{ ob2.prev_link = &ob1;
struct node ob1; // Node1 ob3.prev_link = &ob2; // Accessing data of ob1, ob2 and ob3 by ob1

// Initialization printf("%d\t", ob1.data);

ob1.prev_link = NULL; printf("%d\t", ob1.next_link->data);

printf("%d\n", ob1.next_link->next_link->data);
ob1.next_link = NULL;
// Accessing data of ob1, ob2 and ob3 by ob2
ob1.data = 10;
printf("%d\t", ob2.prev_link->data);
struct node ob2; // Node2 printf("%d\t", ob2.data);
// Initialization
printf("%d\n", ob2.next_link->data); // Accessing data of ob1, ob2 and ob3 by ob3
ob2.prev_link = NULL; printf("%d\t", ob3.prev_link->prev_link->data);

ob2.next_link = NULL; printf("%d\t", ob3.prev_link->data);

printf("%d", ob3.data);
ob2.data = 20;
return 0;

}
Book References
TEXT BOOKS
• Seymour Lipchitz, Schaum's Outlines Series Data Structures TMH. J.P. Hayes,
Computer Organization and Architecture, Third Edition, TMH.
• Data Structure Theory Problem and Algorithms, R.S. Salaria, Khanna Book
Publishing Company, Delhi.
REFERENCE BOOKS
• Introduction to Data Structures Applications, Trembley&Soreson, Second
Edition, Pearson Education Robert L. Britton, MIPS Assembly Language
Programming, Pearson Prentice Hall.
• A. Tanenbaum, Y. Lanhgsam and A. J. Augenstein, Data Structures Using C++,
Prentice Hall of India, 1990
Video Links

https://www.youtube.com/watch?v=XBFGsKQX21s
THANK YOU

Created by: Deepika Dhiman (E15896)


[email protected]

You might also like