Beruflich Dokumente
Kultur Dokumente
SONAL PANDEY
NITTTR Chd.
Data Structure:
1. Organization of data
2. Accessing Methods
3. Degree of associativity
Primitive DS Non-Primitive DS
Non Linear
Linear list
list
●
Array: is commonly used in computer
programming to mean a contiguous block of
memory locations, where each memory location
stores one fixed-length data item.
e.g. Array of Integers int a[10], Array of
Character char b[10]
Array of Integers Array of Character
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
5 6 4 3 7 8 9 2 1 2 5 6 4 3 7 8 9 2 1 2
zaid shabbir
Types of Data Structure ...
Stack: A stack is a data 1(TOP)
structure in which items can 4
be inserted only from one 8
FRONT REAR
1 2 4 6 5 8
Types of Data Structure ...
zaid shabbir
Types of Data Structure ...
Types of Data Structure ...
zaid shabbir
Types of Data Structure ...
Undirected Graph: A
graph whose edges are
unordered pair of vertices.
That is each edge connects
two vertices. In an
undirected graph, direction
is not important, if the path
is available, it can be
traversed in any direction.
zaid shabbir
Types of Data Structure ...
zaid shabbir
Data Structure Operations :
1. Traversing
2. Searching
3. Inserting
4. Deleting
5. Sorting
6. Merging
The basic operations that are performed on data structures are as
follows:
data type is a data storage format that can contain a specific type
or range of values.
Data
Types
Primary Derived
Float Type
Void
User Define
Enumerated Typedef
3
Structure
INT DATA TYPE
4
CHAR DATA TYPE
Charactertype variable can hold a single character. As there are singed and
unsigned int (either short or long), in the same way there are signed and
unsigned chars; both occupy 1 byte each, but having different ranges.
Unsigned characters have values between 0 and 255; signed characters
have values from –128 to 127.
5
FLOAT DATA TYPE
The float data type is used to store fractional numbers (real numbers) with
6 digits of precision. Floating point numbers are denoted by the keyword
float. When the accuracy of the floating point number is insufficient, we
can use the double to define the number. The double is same as float but
with longer precision and takes double space (8 bytes) than float. To
extend the precision further we can use long double which occupies 10
bytes of memory space.
6
TYPE VOID DATA TYPE
7
DERIVED DATA TYPE
8
ENUMERATED DATA TYPE (ENUM)
Enumerated data type is a user defined data type having finite set of enumeration
constants. The keyword 'enum' is used to create enumerated data type.
Enumeration data type consists of named integer constants as a list.
It start with
Enumerated data0type(zero) by default
is a user and type
defined data valuehaving
is incremented
finite setby 1 for the
ofsequential
enumeration constants.
identifiers in theThe
list. keyword 'enum' is used to create
enumerated data type. Enumeration data type consists of named
integer
It start constants
with 0 as(zero)
a list. by default and value is
incremented by 1 for the
Syntax:
Enum [data_type] {const1, const2… constn}; Enum example
in C:
enum month { Jan, Feb, Mar }; or /* Jan, Feb and Mar variables will be assigned
to 0, 1 and 2 respectively by default */
enum month { Jan = 1, Feb, Mar }; /* Feb and Mar variables will be assigned to
2 and 3 respectively by default */
enum month { Jan = 20, Feb, Mar }; /* Jan is assigned to 20. Feb and Mar
9
variables will be assigned to 21 and 22 respectively by default */
Example:
#include <stdio.h>
enum weekdays{Sunday=1, Monday, Tuesday, Wednesday, Thurs
day, Friday, Saturday};
int main()
{
enum weekdays w; // variable declaration of weekdays type
w=Monday; // assigning value of Monday to w.
printf("The value of w is %d",w);
return 0;
}
Ouput:
The Value of w is 2
TYPEDEF DATA TYPE
Syntax:
typedef [data_type] new_data_type;
Example:
typedef int integer; integer roll_no;
1
0
STRUCTURE DATA TYPE
C Structure is a collection of different data types which are grouped
2. using a const keyword: Using const keyword to define
constants is as simple as defining variables, the difference is you
will have to precede the definition with a const keyword.
// Driver code
int main()
{
printf("Integer Constant: %d\n", val);
printf("Floating point Constant: %f\n", floatVal);
printf("Character Constant: %c\n", charVal);
return 0;
}
Variable
A variable in simple terms is a storage place which has some
memory allocated to it. Basically, a variable used to store some
form of data.
In programming, a variable is a container (storage area) to hold
data.
To indicate the storage area, each variable should be given a unique
name (identifier). Variable names are just the symbolic
representation of a memory location. For example:
#include<stdio.h>
void main()
{
/* c program to print value of a variable */
int age = 33;
printf("I am %d years old.\n", age); }
Output:
I am 33 years old.
Pointers :
A pointer is an entity that refers to the memory addresses. It
specifies the number that gives a location in a memory. Each
pointer variable can point to specific data type such as int, char,
float etc.
Pointers are used for…….
1. Accessing array elements.