 What is data structure?
Ans: Is the way of sorting and organizing data in computer memory or even
disk storage
 What is Data?
Ans: is row facts about people place or entities(1).
 What is data processing?
Ans: Is the way of putting data in its type in the memory or disk spaces.
 What is information?
Ans: is the output of data been processed.Oris the useful dat.
 Types of data structure
 -Linear Data Structure : Is the way of organizing data sequenced order In
the memory. Or sequenced data.
 -Non-Linear Data Structure: is non-sequenced data.
 Examples of linear and non-linear data structures
1: Linear “Arrays, Linked List, Queue”
2: Non-linear “Stark, tress, Graphs”
Chapter 2:
 An algorithm :is a well-defined computational method, which takes some
value(s) as input and produces somevalue(s) as output. In other words, an
algorithm is a sequence of computational steps that transforms input(s) into
output(s).
 Problem Definition: Sort given n numbers by non-descending order by
using insertion sort.
 Space Complexity: The Space complexity of an algorithm is the amount of
main memory needed to run the program till completion.
 Time Complexity: The Time complexity of an algorithm is the amount of
computer time it needs to run the program till completion.
 Linked list: is a linear dynamic data structure.
 Singly linked list: is a linked list which is a linear list of some nodes
containing homogeneous elements
 Doubly linked list: is a linked list which is a linear list of some nodes
containing homogeneous elements.
 Circular linked list: is a linked list similar with the singly linked list. The
only difference between the circular linked list and the singly linked list
 Stack : is a special type of data structure where elements are inserted from one
end and elements are deleted from the same end.
 Push : Data is added to the stack using the Push operation.
 Pop : Data is removed using the Pop operation
 Push operation : The procedure of inserting a new element to the top of the stack
is known as push operation.
 Programming
 #include<stdio.h>
 #include<conio.h>
 #include<malloc.h>
 #include<stdlib.h>
 void push(); //push() function declaration
 void pop(); //pop() function declaration
 void display(); //display() function declaration
 struct node
 {
 int data;
 struct node *next;
 };
 struct node *top=NULL;
 void main()
 {
 int choice;
 clrscr();
 while(1)
 {
 printf("n1.Push");
 printf("n2.Pop");
 printf("n3.Display");
 printf("n4.Quit");
 printf("nEnter your choice:");
 scanf("%d",&choice);
 switch(choice)
 {
 case 1: push();
 break;
 case 2: pop();
 break;
 case 3: display();
 break;
 case 4: exit(1);
 default:printf("Invalid Choicen");
 }//end of switch
 } //end of while loop
 }//end of main fuction
 void push()
 {
 struct node *ptr;
 int item;
 ptr=(struct node *)malloc(sizeof(struct node));
 printf("Enter a value to be pushed onto the stack: ");
 scanf("%d",&item);
 ptr->data=item;
 ptr->next=top;
 top=ptr;
 }//end of push fuction
 void pop()
 {
 struct node *ptr,*next;
 if(top==NULL)
 printf("nStack is Empty");
 else
 {
 ptr=top;
 printf("nPopped element is : %dn",ptr->data);
 top=top->next;
 free(ptr);
 }
 }//end of pop function definition
 void display()
 {
 struct node *p;
 p=top;
 if(top==NULL)
 printf("nStack is emptyn");
 else
 {
 printf("nStack elements:n");
 while(p!=NULL)
 {
 printf("%dn",p->data);
 p=p->next;
 }
 }
 } //end of display function

What is data structure

  • 1.
     What isdata structure? Ans: Is the way of sorting and organizing data in computer memory or even disk storage  What is Data? Ans: is row facts about people place or entities(1).  What is data processing? Ans: Is the way of putting data in its type in the memory or disk spaces.  What is information? Ans: is the output of data been processed.Oris the useful dat.  Types of data structure  -Linear Data Structure : Is the way of organizing data sequenced order In the memory. Or sequenced data.  -Non-Linear Data Structure: is non-sequenced data.  Examples of linear and non-linear data structures 1: Linear “Arrays, Linked List, Queue” 2: Non-linear “Stark, tress, Graphs” Chapter 2:  An algorithm :is a well-defined computational method, which takes some value(s) as input and produces somevalue(s) as output. In other words, an algorithm is a sequence of computational steps that transforms input(s) into output(s).  Problem Definition: Sort given n numbers by non-descending order by using insertion sort.  Space Complexity: The Space complexity of an algorithm is the amount of main memory needed to run the program till completion.  Time Complexity: The Time complexity of an algorithm is the amount of computer time it needs to run the program till completion.  Linked list: is a linear dynamic data structure.  Singly linked list: is a linked list which is a linear list of some nodes containing homogeneous elements  Doubly linked list: is a linked list which is a linear list of some nodes containing homogeneous elements.  Circular linked list: is a linked list similar with the singly linked list. The only difference between the circular linked list and the singly linked list  Stack : is a special type of data structure where elements are inserted from one end and elements are deleted from the same end.  Push : Data is added to the stack using the Push operation.  Pop : Data is removed using the Pop operation
  • 2.
     Push operation: The procedure of inserting a new element to the top of the stack is known as push operation.  Programming  #include<stdio.h>  #include<conio.h>  #include<malloc.h>  #include<stdlib.h>  void push(); //push() function declaration  void pop(); //pop() function declaration  void display(); //display() function declaration  struct node  {  int data;  struct node *next;  };  struct node *top=NULL;  void main()  {  int choice;  clrscr();  while(1)  {  printf("n1.Push");  printf("n2.Pop");  printf("n3.Display");  printf("n4.Quit");  printf("nEnter your choice:");  scanf("%d",&choice);  switch(choice)  {  case 1: push();  break;  case 2: pop();  break;  case 3: display();  break;  case 4: exit(1);  default:printf("Invalid Choicen");  }//end of switch  } //end of while loop  }//end of main fuction
  • 3.
     void push() {  struct node *ptr;  int item;  ptr=(struct node *)malloc(sizeof(struct node));  printf("Enter a value to be pushed onto the stack: ");  scanf("%d",&item);  ptr->data=item;  ptr->next=top;  top=ptr;  }//end of push fuction  void pop()  {  struct node *ptr,*next;  if(top==NULL)  printf("nStack is Empty");  else  {  ptr=top;  printf("nPopped element is : %dn",ptr->data);  top=top->next;  free(ptr);  }  }//end of pop function definition  void display()  {  struct node *p;  p=top;  if(top==NULL)  printf("nStack is emptyn");  else  {  printf("nStack elements:n");  while(p!=NULL)  {  printf("%dn",p->data);  p=p->next;  }  }  } //end of display function