Monday, 28 April 2014

array implementation of list in c

Program Code:-
#include<stdio.h>
#include<conio.h>
void main()
{
  int arr[100],n,i,elements,pos,temps,temp; //Initializing variables and temp variables
  printf("######Implementing Linked List Using Arrays########\n");
  puts("how many elements you have to append\n");
  scanf("%d",&n);//recieve inputs to insert in to list
   for(i=0;i<=n;i++)
   {
  printf(" the element for position is %d\t",i);
  scanf("%d",&arr[i]);//recieve inputs for positions
 }
          for(i=0;i<=n;i++)
   {
  printf(" the element for this  %d position is %d \n",i,arr[i]); //Printing the elements with positions
 }
          printf("#######Implementing Search##########################\n");
          printf("Enter the element to search \n ");
          scanf("%d",&elements);
          for(i=0;i<=n;i++)//Loop to search entire array
   {
     if(arr[i]==elements)
                  {
                    printf("this element %d was found at position %d",elements,i);
                    break;
                    }
              else
                  {
                       //Do nothing
                  }
 }
printf("#######Implementing Insertion by shifting##########################\n");
       printf("Enter the element to insert \n ");
       scanf("%d",&elements);
       printf("Enter the position where to insert \n ");
       scanf("%d",&pos);
       for(i=10;i>=pos-1;i--)
   {
             arr[i+1]=arr[i];
             arr[pos-1]=elements;    
 }

 for(i=0;i<=n;i++)
   {
  printf(" the element for this  %d position is %d \n",i,arr[i]);
 }
}

 

  If you want to delete an element in an array then you shift the positions in a way opposite to previous one so the element of an array is deleted .
sorting algorithm will be updated shortly..I believe not in mixing concepts and i follow divide and concur approach have a nice day guys...

what are data structures and why are they important ?




In every day life we do certain job by implementing a strategy and  plan so then only we could live a pleasant life that doesn't ruin our routines .
what are the algorithm we follow in real life , they are best-shortest-path strategy to take a quickest road,Divide and Conquer as a business strategy to handle employers with manager and managers from different department,stack(what we eat doesn't comes out through mouth at end of the day),queue structure to buy a ticket and several more...

Similarly computers do follow a strategy  where in the real world they are as follows:-
windows media player playlist follows queues.
Computer memory follows stack structure.
Rip is a networking protocol that uses distance vector routing protocol.
arrays follows linked list.
windows search follows searching algorithms.
Fb also uses Data structures traversal,search,reorder algorithms.
and several more.....

List of Data-structures
Linked List Algorithm
Singly Linked List
Doubly Linked List
Array Implementation Of Stack
Circular Queue
Tree Traversals
Binary Search Tree
Priority Queue
Dijkstra's Algorithm
Hashing Technique
Greedy Algorithm.

Saturday, 26 April 2014

Algorithms and data structures in C/C++

Greetings fellas had a very rough time to implement the data-structure algorithms in code . at last i got it.
I didn't blog as i couldn't take it clear in to my head the implementation as the concept that was clear for me .
I am bringing this site live for students,grads to upgrade their skills to the level max.


All the Best Guyz this blog would be updated with all the data structure logic in c and Perl.