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

Data Structure Using C

Uploaded by

pk9131387
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Data Structure Using C

Uploaded by

pk9131387
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

DATA STRUCTURE USING C

MADE BY PRINCE KANOJIA


PRESENT BY:- PRINCE KANOJIA,PRINCE KUMAR,PRINCE SHAKYA,
PRIYANSHI,ROHIT PRATAP
A linear data structure is a type of data organization where
elements are arranged in a sequential manner. Each element is

EXPLAIN LINEAR DATA


connected to its previous and next element, forming a single
level of hierarchy. This structure allows for efficient traversal and
access to the elements.
STRUCTURE

Memory Allocation:
Fixed or Dynamic
Sequential Order: Arrays use contiguous
Size: Some structures,
Elements are arranged in memory allocation,
like arrays, have a fixed
a specific sequence, while linked lists utilize
size, while others, like
allowing for a clear non-contiguous
linked lists, can grow or
beginning and end. memory, with nodes
shrink dynamically.
pointing to each other.
TYPE OF LINEAR DATA STRUCTURE

Stacks:
•Arrays: Definition: A collection that follows the Last
•Definition: A collection of elements stored in In, First Out (LIFO) principle.
contiguous memory locations.
Queues:
•Linked Lists: Definition: A collection that follows the First
• Definition: A series of nodes, where each node In, First Out (FIFO) principle.
contains data and a reference to the next node. Types:
•Types: Simple Queue: Elements are added at
•Singly Linked List: Each node points to the the rear and removed from the front.
next node only. Circular Queue: The end of the queue
•Doubly Linked List: Each node points to both wraps around to the front when there’s
the next and the previous nodes. space.
•Circular Linked List: The last node points back Priority Queue: Elements are removed
to the first node, forming a circle. based on priority rather than the order
they were added.
Characteristics of
Array
These characteristics make arrays
How it works:

useful for various applications, 1 Fixed Size: The size of an


especially when the number of array is determined at the
elements is known in advance and time of its creation and
cannot be changed. This
quick access is a priority. means the number of
elements it can hold is static.

2 Contiguous Memory
Allocation: Elements are
stored in contiguous
memory locations, allowing
for efficient access and
manipulation.

Random Access: Elements


3 can be accessed directly using
their index, enabling quick
retrieval of data. For example,
accessing the nth element
takes constant time, O(1).
STORAGE Storage Order
Multidimensional arrays are
stored in row-major order in
memory, similar to 2D arrays. 1 Row-Major Order:
Arrays in C are stored in row-major order.
This means all elements of the first row
For example, the elements of are stored first, followed by the elements
of the second row, and so on.
the first block (arr[0][0][0] to
arr[0][2][3]) are stored first,
followed by the second block.
2 Example for a 2D array arr[2]
[3]

Arr[0][0],arr[0][1],arr[0]
[2],arr[1][0],arr[1][1],arr[1][2]

Column-Major Order:
3
• In some languages like Fortran, arrays are
stored in column-major order, where all
elements of the first column are stored
first, followed by the elements of the
second column, and so on.
1. Traversal Operations on Arrays
Definition: Traversal means visiting each element of the array
at least once to perform a specific operation (like printing the
elements). Arrays are one of the simplest and
1 most commonly used data structures.
Let's explore the key
2. Search
operations: Search, Traverse, Insert
Definition: Search involves finding a specific ion, and Deletion.
element in the array. Two common types of
searches are linear search and binary
search.
3. Insertion
2

Definition: Inserting a new element into the array at a specific position.

4. Deletion

Definition: Deleting an element from the array, after which the 3


size of the array is reduced.
POINTERS AND ACCESS Pointers:
- Declare: int *ptr;
- Initialize: int x = 10; int *ptr = &x;
- Dereference: *ptr
- Operations: assignment, increment,
2D ARRAYS

decrement, comparison

2D Arrays:
- Declare: int arr[3][4]; or int **arr;
- Initialize:
- Fixed: int arr[3][4] = {{1, 2}, {3, 4},
{5, 6}};
- Dynamic: arr = (int **)malloc(3 *
sizeof(int *));
- Access: arr[i][j] or *(arr + i * cols + j)
POINTERS

• ADVANTAGES • DISADVANTAGES
1. Pointers let you work 1. Using pointers makes
directly with memory, the code more difficult
allowing you to manage to understand and work
data more efficiently. with.
2. Instead of copying big 2. Mistakes with pointers
data like arrays, pointers are often tricky to find
allow you to reference and fix because they
them directly, saving affect low-level memory.
time and memory.
ARRAYS

Advantages of Array :- Disadvantages of Array :-

1. Arrays allow you to store 1. Once an array is created, its


multiple values in one place size can't change. If you need
using a single name. more space, you'll have to
create a new array.
2. You can easily find any value
in the array by using its position 2. If you don’t use all the space
(index). in the array, memory is
wasted.

You might also like