Top Banner
24
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Leniar datastructure
Page 2: Leniar datastructure

Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd

Page 3: Leniar datastructure

Week Target Achieved

1 22

2 25 243 30 25

4 30 28

Typing Speed

Page 4: Leniar datastructure

Jobs Applied# Company Designation Applied Date Current Status

1 AfiInfotec SoftwareDeveloper 21/8/2013

2 CodeLogic SoftwareDeveloper 23/8/2013

3

Page 5: Leniar datastructure

Linear data structure

Page 6: Leniar datastructure

Leniar Data Structure

• A data structure is a method for organizing and storing data, which would allow efficient data retrieval and usage.

• Linear data structure is a structure that organizes its data elements one after the other.

• Linear data structures are organized in a way similar to how the computer’s memory is organized.

Page 7: Leniar datastructure

Example For Linear data structure

Array, Stcks, Linked list, Queue

Page 8: Leniar datastructure

Arrays

Declaration of array

• Here, the name of array is age. The size of array is 5,i.e., there are 5 items(elements) of array age. All element in an array are of the same type (int, in this case)

For example:Data type array name[array size]; int age[5];

Page 9: Leniar datastructure

• Initialization of one-dimensional array: • Arrays can be initialized at declaration time in

this source code as:• int age[5]={2,4,34,3,4}; It is not necessary to

define the size of arrays during initialization. • int age[]={2,4,34,3,4};

• In this case, the compiler determines the size of array by calculating the number of elements of an array.

Page 10: Leniar datastructure
Page 11: Leniar datastructure

queue• Queue is a data structure which works as FIFO principle. • FIFO means “First in First out”, i.e the element which we have inserted

first will be deleted first and the element that we have inserted last will be deleted last.

• You can have c program to implement queue using array, . Two variables are used to implement queue, i.e “rear” and “front”. Insertion will be done at rear side and deletion will be performed at front side. Figure below will show you and will make some concept of queue.

With simple queue, you can also have circular queue data structure and dequeue data structure.

• c program for queue using array

Page 12: Leniar datastructure

• #include<stdio.h>

• #include<conio.h> • #define MAX 10 void insert(int); • int del(); int queue[MAX], rear=0, front=0; • void display(); • int main() { char ch , a='y';• int choice, token;• printf("1.Insert");• printf("\n2.Delete"); • printf("\n3.show or display"); • do { printf("\nEnter your choice for the operation: "); • scanf("%d",&choice); • switch(choice) { case 1: insert(token); • display(); break; case 2: token=del();• printf("\nThe token deleted is %d",token);• display(); break;• case 3: display();

Page 13: Leniar datastructure

• break; • default: printf("Wrong choice");• break; } • printf("\nDo you want to continue(y/n):");• ch=getch();• } while(ch=='y'||ch=='Y')• ; getch(); • } void display() { int i;

• printf("\nThe queue elements are:"); • for(i=rear;i<front;i++) { printf("%d ",queue[i]);• } }• void insert(int token) { char a; if(rear==MAX) { printf("\nQueue full"); • return; } do { printf("\nEnter the token to be inserted:"); scanf("%d",&token);

queue[front]=token; front=front+1; printf("do you want to continue insertion Y/N"); a=getch(); } while(a=='y'); } int del() { int t; if(front==rear) { printf("\nQueue empty"); return 0; } rear=rear+1; t=queue[rear-1]; return t;

Page 14: Leniar datastructure

• return;• } do { printf("\ nEnt er the token to be inserted:"); • scanf("% d” ,&token); • queue[front]=token; • front=front+1;• printf("do you want to continue insertion Y/N"); a=getch(); • } while(a=='y');• } int del() { int t;• if(front==rear) { printf("\nQueue empty"); • return 0; • } rear=rear+1; • t=queue[rear-1];• return t;

Page 15: Leniar datastructure

STACK

Page 16: Leniar datastructure
Page 17: Leniar datastructure
Page 18: Leniar datastructure
Page 19: Leniar datastructure
Page 20: Leniar datastructure

Simple program using Stack

Page 21: Leniar datastructure

Application of Stack

Page 22: Leniar datastructure

end

Page 23: Leniar datastructure

If this presentation helped you, please visit our page facebook.com/baabtra and like it.

Thanks in advance.

www.baabtra.com | www.massbaab.com |www.baabte.com

Page 24: Leniar datastructure

Contact Us

Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

Start up VillageEranakulam,Kerala, India.

Email: [email protected]