Note 1
##### Take Note:

Take a note while surfing.

##### Note With Ink

Give your Note a Colorful Tag.

##### Easy to Access

Stay on same information and in Sync wherever you are.

Note 2
##### Take Note:

Organize your information,It may take Shape.

##### Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3
##### Take Note:

Don't Let information to miss,Because it take shape

##### Note With Ink

Simple an Easy Way to take a note.

##### Easy to Access

Get the same in next visit.

Question :: 31
Write an efficient program to traverse the list N nodes from the tail

Input : NA

Output : NA

|  Linked List | | | |  Fresher
``` ```
``````

Tags:No Tags on this question yet!

Question :: 32
Write a program insert an element into ascending order list

Input : NA

Output : NA

|  Linked List | | | |  Fresher
``` ```
#include <stdio.h>
#include<iostream>
using namespace std;
void main()
{
int i, j, a, n, number[30];
cout<<"Enter the value of N \n";
cin>>n;
cout<<"Enter the numbers \n";
for (i = 0; i < n; ++i)
cin>>number[i];
for (i = 0; i < n; ++i)
{
for (j = i + 1; j < n; ++j)
{
if (number[i] > number[j])
{
a =  number[i];
number[i] = number[j];
number[j] = a;
}
}
}
cout<<"The numbers arranged in ascending order are given below \n";
for (i = 0; i < n; ++i)
cout<< number[i];
}
``````

Tags:Virtusa

Question :: 33
Write a program to reverse the single linked list

Input : NA

Output : NA

|  Linked List | | | |  Fresher
``` ```
``````

Tags:Virtusa

Question :: 34
Write a program to implement the stack and queue using list

Input : NA

Output : NA

|  Linked List | | | |  Fresher
``` ```
#include<conio.h>       #include<iostream.h> #include<process.h>  #include<malloc.h>   /*Creating a NODE Structure*/struct node{   int data;   struct node *next;}; /*Creating a class QUEUE*/class queue{   struct node *frnt,*rear;   public:      queue() // constructure      {     frnt=rear=NULL;      }      void insert(); /*to insert an element*/      void del();  /* to delete an element*/      void show(); /* to show the stack*/};/* Insertion */void queue::insert(){   int value;   struct node *ptr;   cout<<"\nInsertion\n";   cout<<"Enter a number to insert: ";   cin>>value;   ptr=new node;   ptr->data=value;   ptr->next=NULL;   if(frnt==NULL)      frnt=ptr;   else      rear->next=ptr;   rear=ptr;   cout<<"\nNew item is inserted to the Queue!!!";   getch();} /* Deletion*/void queue::del(){   if(frnt==NULL)   {      cout<<"\nQueue is empty!!";      getch();      return;   }   struct node *temp;   temp=frnt;   frnt=frnt->next;   cout<<"\nDeletion Operation........\nDeleted value is "<<temp->data;   delete temp;   getch();} /* Show Queue*/void queue::show(){   struct node *ptr1=frnt;   if(frnt==NULL)   {      cout<<"The Queue is empty!!";      getch();      return;   }   cout<<"\nThe Queue is\n";   while(ptr1!=NULL)   {      cout<<ptr1->data<<" ->";      ptr1=ptr1->next;   }   cout<<"END";   getch();}int main(){   clrscr();   queue q;   int choice;   while(1)   {      cout<<"\n-----------------------------------------------------------";      cout<<"\n\t\tQUEUE USING LINKED LIST\n\n";      cout<<"1:INSERTION\n2:DELETION\n3:DISPLAY QUEUE\n4:EXIT";      cout<<"\nEnter your choice(1-4): ";      cin>>choice;      switch(choice)      {       case 1:      q.insert();      break;       case 2:      q.del();      break;       case 3:      q.show();      break;       case 4:      exit(0);      break;       default:      cout<<"Please enter correct choice(1-4)!!";      getch();      break;       }   }   return 0;}
``````

Tags:Virtusa

Question :: 35
Write a program to compute the quicksort for the given input array

Input : NA

Output : NA

|  Sorting | | | |  Fresher
``` ```
<!DOCTYPE html><html><body><?php \$unsorted = array(43,21,2,1,9,24,2,99,23,8,7,114,92,5);function quick_sort(\$array){    // find array size    \$length = count(\$array);        // base case test, if array of length 0 then just return array to caller    if(\$length <= 1){        return \$array;    }    else{            // select an item to act as our pivot point, since list is unsorted first position is easiest        \$pivot = \$array[0];                // declare our two arrays to act as partitions        \$left = \$right = array();                // loop and compare each item in the array to the pivot value, place item in appropriate partition        for(\$i = 1; \$i < count(\$array); \$i++)        {            if(\$array[\$i] < \$pivot){                \$left[] = \$array[\$i];            }            else{                \$right[] = \$array[\$i];            }        }                // use recursion to now sort the left and right lists        return array_merge(quick_sort(\$left), array(\$pivot), quick_sort(\$right));    }}\$sorted = quick_sort(\$unsorted);print_r(\$sorted);?>  </body></html>
``````

Tags:No Tags on this question yet!

Question :: 36
Write a program to compute the bubble sort for the given input array

Input : NA

Output : NA

|  Sorting | | | |  Fresher
``` ```
#include<conio.h>
#include<iostream.h>
template<class bubble>
void bubble(bubble a[], int n)
{
int i, j;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
bubble element;
element = a[i];
a[i] = a[j];
a[j] = element;
}
}
}
}

void main()
{
int a[6]={1,2,3,4,4,3};
char b[4]={'s','b','d','e'};
clrscr();
bubble(a,6);
cout<<"\nSorted Order Integers: ";
for(int i=0;i<6;i++)
cout<<a[i]<<"\t";
bubble(b,4);

cout<<"\nSorted Order Characters: ";
for(int j=0;j<4;j++)
cout<<b[j]<<"\t";
getch();
}
``````

Tags:No Tags on this question yet!

Question :: 37
Write a program to construct the binary search tree

Input : NA

Output : NA

|  Trees | | | |  Fresher
``` ```
#include <stdio.h>#include <stdlib.h>struct btnode{    int value;    struct btnode *l;    struct btnode *r;}*root = NULL, *temp = NULL, *t2, *t1; void create(); void insert(); int flag = 1; void main(){insert();getch();}/* To insert a node in the tree */void insert(){    create();    if (root == NULL)         root = temp;    else            search(root);    } /* To create a node */void create(){    int data;     printf("Enter data of node to be inserted : ");    scanf("%d", &data);    temp = (struct btnode *)malloc(1*sizeof(struct btnode));    temp->value = data;    temp->l = temp->r = NULL;}
``````

Tags:No Tags on this question yet!

Question :: 38
Write a program to delete the given element in the tree

Input : NA

Output : NA

|  Trees | | | |  Fresher
``` ```
#include <stdio.h>#include <stdlib.h> struct btnode{    int value;    struct btnode *l;    struct btnode *r;}*root = NULL, *temp = NULL, *t2, *t1; void create(); void insert(); void delete(); int flag = 1; void main(){ insert(); delete();getch();}/* To insert a node in the tree */void insert(){    create();    if (root == NULL)         root = temp;    else            search(root);    }
``````

Tags:No Tags on this question yet!

Question :: 39
Write a program to compute the sum of all elements in the tree

Input : NA

Output : NA

|  Trees | | | |  Fresher
``` ```
#include <stdio.h>#include <malloc.h> /* Structure to create the binary tree */struct btnode{    int value;    struct btnode *l;    struct btnode *r;};struct btnode *root = NULL;int sum; /* Function Prototypes */ void in_order_traversal(struct btnode *);void in_order_sum(struct btnode *);struct btnode *newnode(int); void main(){      /* Inserting elements in the binary tree */    root = newnode(50);    root->l = newnode(20);    root->r = newnode(30);    root->l->l = newnode(70);    root->l->r = newnode(80);    root->l->l->l = newnode(10);    root->l->l->r = newnode(40);    root->l->r->r = newnode(60);    printf("The elements of Binary tree are:");    in_order_traversal(root);    in_order_sum(root);    printf("\nThe sum of all the elements are:%d", sum);} /* Code to dynamically create new nodes */struct btnode* newnode(int value){    struct btnode *temp = (struct btnode *)malloc(sizeof(struct btnode));    temp->value = value;    temp->l = NULL;    temp->r = NULL;    return temp;} /* Code to display the elements of the binary tree */void in_order_traversal(struct btnode *p){    if (!p)    {        return;    }    in_order_traversal(p->l);    printf("%d->",  p->value);    in_order_traversal(p->r);} /* Code to find the sum of all elements in the tree */void in_order_sum(struct btnode *p){    if (!p)    {        return;    }    in_order_sum(p->l);    sum = sum + p->value;    in_order_sum(p->r);}
``````

Tags:No Tags on this question yet!

Question :: 40
Write a program to find the maximum and minimum depth of the tree

Input : NA

Output : NA

|  Trees | | | |  Fresher
``` ```
#include<stdio.h>
#include<stdlib.h>

/* A binary tree node has data, pointer to left child
and a pointer to right child */
struct node
{
int data;
struct node* left;
struct node* right;
};

/* Compute the "maxDepth" of a tree -- the number of
nodes along the longest path from the root node
down to the farthest leaf node.*/
int maxDepth(struct node* node)
{
if (node==NULL)
return 0;
else
{
/* compute the depth of each subtree */
int lDepth = maxDepth(node->left);
int rDepth = maxDepth(node->right);

/* use the larger one */
if (lDepth > rDepth)
return(lDepth+1);
else return(rDepth+1);
}
}

/* Helper function that allocates a new node with the
given data and NULL left and right pointers. */
struct node* newNode(int data)
{
struct node* node = (struct node*)
malloc(sizeof(struct node));
node->data = data;
node->left = NULL;
node->right = NULL;

return(node);
}

int main()
{
struct node *root = newNode(1);

root->left = newNode(2);
root->right = newNode(3);
root->left->left = newNode(4);
root->left->right = newNode(5);

printf("Hight of tree is %d", maxDepth(root));

getchar();
return 0;
}
``````

Tags:No Tags on this question yet!