Wednesday 22 August 2012

c sharp overloading program

c sharp overloading program
c (#)sharp overloading programs with source code
using System;
using System.Collections.Generic;
using System.Text;

namespace overloading
{
class overload
{
public void ovl()
{
Console.WriteLine("No Parameters.");
}

public void ovl(int a)
{
Console.WriteLine("One parameter is passed i.e " + a);
}

public int ovl(int a, int b)
{
Console.WriteLine("Two parameters are passed they are" + a + "and" + b);
return a + b;
}

public double ovl(double a, double b)
{
Console.WriteLine("Two double parameters are passed they are" + a + "and" + b);
return a + b;
}
}
public class poly
{
static void Main(string[] args)
{
overload ob = new overload();
int resi;
double resd;

ob.ovl();
Console.WriteLine();

resi = ob.ovl(4, 6);
Console.WriteLine("Result  of adding these integers is" + resi);
Console.WriteLine();


resd = ob.ovl(1.11, 1.12);
Console.WriteLine("Result of adding these doubles is:" + resd);
Console.WriteLine();
Console.ReadLine();

}
}

inheritance | example | source code in C sharp

inheritance | example | source code in C sharp
inheritance | example | source code in C sharp
using System;
using System.Collections.Generic;
using System.Text;

namespace inh_sing
{
public class person
{
public string phone,name,address;
public void getp()
{
Console.WriteLine("Enter name:");
name=Console.ReadLine();

Console.WriteLine("Enter address:");
address = Console.ReadLine();

Console.WriteLine("Enter phone:");
phone = Console.ReadLine(); 


}
}

public class stud:person
{
public string course;
public int roll;
public void gets()
{
Console.WriteLine("Enter rollno:");
roll = int.Parse (Console.ReadLine());
Console.WriteLine("Enter course:");
course = Console.ReadLine();
}

public void display()
{
Console.WriteLine("Roll No:-" + roll);
Console.WriteLine("Name:-" + name);
Console.WriteLine("Course:-" + course);
Console.WriteLine("Address:-" + address);
Console.WriteLine("Phone:-" + phone);
}
}


public static void Main(string[] args)
{
stud s1 = new stud();
s1.getp();
s1.gets();
s1.display();
Console.ReadLine();
}
}
}

c# .net class with constructor

c# .net class with constructor
c# .net |  namespace and class with constructor | code source | program | output | comments
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace constatnt
{
class Program // class  name program
{
int i;
float j;

public Program(int x, float z) // constructor  declared as public
{
i = x;
j = z;
}


public void display()
{
Console.Write("roll  number"+i+"\n"+"salary ="+j+"rs");
}

static void Main(string[] args  ) // main of the program
{
Program p = new Program(10, 3.4f);
p.display();

}
}
}

/*output


//program c# .net |  namespace and class with constructor | code source | program | output | comments//
roll number =10
salary =3.4 rs

E-num with code asp.net

E-num with code asp.net
E-num with code asp.net
Practical program with code
protected void RadioButtonList2_SelectedIndexChanged1(object sender, EventArgs e)
{
BulletedList2.BulletStyle = (BulletStyle)Enum.Parse(typeof(BulletStyle), RadioButtonList2.SelectedItem.Text);

}

protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
BulletedList1.BulletStyle  = (BulletStyle)Enum.Parse(typeof(BulletStyle), RadioButtonList1.SelectedItem.Text );

}

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string[] brdStl = (string[])Enum.GetNames(typeof(BulletStyle));
foreach (string b in brdStl)
{
RadioButtonList1.Items.Add(b);
RadioButtonList2.Items.Add(b);
}
}
}

Simple DataTable in c# with count rows | For loop

Simple DataTable in c# with count rows | For loop
How to count total number of rows from datatable in c#.


DataTable DtObject=new  DataTable(); 

            int cnt=0; //initialization count as 0.
       if(DtObject.Rows.Count!=null) // dt1.Rows.count will give information about total records or tital rows in datatable.
       {
           for (int i = 0; i < DtObject.Rows.Count-1; i++)
           {
               cnt += 1;
           }
           lblResult.Text = cnt.ToString();
          
          
       }

StringBuilder in c# with Append method| Asp.Net | How to use

StringBuilder in c# with Append method| Asp.Net | How to use
using System.Text;
Logic to use  StringBuilder in Program to display the report. with append method
To improve performance of application.
 StringBuilder strAppend = new StringBuilder();
                            if (dsrpt.Tables[0].Rows.Count != 0)
                            {
                                for (int i = 0; i < dt1.Rows.Count; i++)
                                {
                               
             strAppend.Append("<TABLE BGCOLOR=RED WIDTH=100% height=60%>");
              strAppend.Append("<TR><TD>" + (dt1.Rows[1][0]) + "</TD></TR>");
             strAppend.Append("<TR><TD>" + (dt1.Rows[2][1]) + "</TD></TR>");

                                    strAppend.Append("</TABLE>");
             
                                }
                            }

Namespace Import For Crystal Report .

Namespace Import For Crystal Report .
How many Namespace Import For Crystal Report .
Whenever You are going to design Crystal Report
then  remember to import  Namespace In C#.net.
I have mentioned here Some of important namespaces


using System.Drawing.Design;
using System.Drawing.Imaging;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Web;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web.Design;

Session use on button click for dropdownlist in c#

Session use on button click for dropdownlist in c#
How to store   Dropdown value or text into the session.
protected void btn_Click(object sender, EventArgs e)
        {
            Session["field"] = dropdownDdl.SelectedValue.ToString();
            Session["Assign"] = objLogicLayer;
            Response.Redirect("Stud_Report.aspx");
        }

how to solve Error :Unable to connect: incorrect log on parameters

how to solve Error :Unable to connect: incorrect log on parameters
in asp.net when we  run program for crystal report then this problem might come so i m wondering how  to sole this kind of error..if any one got please reply
Logon failed. Details: crdb_adoplus : Object reference not set to an instance of an object. Error in File C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\temp_ad5664c4-2542-42ab-939f-4357a392e7ec {E29B2F59-0CC5-4B8B-BCBE-4B3361349354}.rpt: Unable to connect: incorrect log on parameters

'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.

'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
How to solve this error .
Whenever we create procedure like..
Use [Db_Name]
ALTER procedure [schema].[Procedure_name]
(
@field1 varchar(16)=null
)
Since there is nothing between use[ db name ]and
[ create/alter proc name]  hence  this error come.
just write like this .

Use [Db_Name]
GO
ALTER procedure [schema].[Procedure_name]
(
@field1 varchar(16)=null
)

If you don't want to use go then r

SqlException was unhandled by user code | How to solve

SqlException was unhandled by user code | How to solve
SqlException was unhandled by user code

This Error is showing that  the  sql server you looking for is not present or not exist .

  1. Just Open Sql Server
  2. File
  3. Connect Object Explorer
  4. In Front Of Server Name select option Browse For More.
  5. Network Servers.
  6. Explore DataBase Engine.
  7. Just check that which server you looking for that is present  or not.
  8. If Not then Check LAN setting and if present then There might be different way to solve this problem.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

How to solve DataTable must be set prior to using DataView. Error

How to solve DataTable must be set prior to using DataView. Error
How can we  solve Error when comes like this
  DataTable must be set prior to using DataView.
.
This problem comes Normally when we use   DataView.
so to taking   DataView in table or with dataset we must know
basic idea about DataView.

If your concept is clear then problem is not with Dataview but ..
SqlException
Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. 

Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)) | How to solve

Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)) | How to solve
"How to solve" this kind of crystal Report Error at runtime.
This error comes because of binding of report formula and front end data.
   ReportObject.DataDefinition.FormulaFields["@crystalReportFormulaParamater"].Text = frontEndvalue.
whenever we pass formula fields from crystal report to get the data from client ..
without using any procedure or query then this kind of problem comes .
Hence just concentrate on above mentioned "red undelined code" and try with that one.
in most of cases the error comes by mentioned red undelined code  .
But not all times .

How to display crystal report in pdf | Exel | Word format | With Code

How to display crystal report in pdf | Exel | Word format | With Code
We can display crystal report in many format like pdf format , Exel Format . Word Fortmat.
Now using below code you can develop logic to display record in Browser also.

Import the following important namespace
using CrystalDecisions.CrystalReports;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Web;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web.Design;


Under CrystalReportViewer1_Init write down your data table or dataset code to retrieve data.
From database .

Make CrystalReportViewer1.EnableDatabaseLogonPrompt = false;
and write the code
Session["data"] = Session["data"].ToString();
if (Session["data"] != null)
{
lblPdf.Text = Session["Ft"].ToString();
if (lblpdf.Text == "Pdf")
{
YourReportObject.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "your dataAdapter Name or report name");
}
For Exel Format :-
Just Write ExportFormatType.Excel,

For WorFormat:-

ExportFormatType.RichText

Types of error in Crystal report

Types of error in Crystal report
Parser Error Message: The base class includes the field 'CrystalReportViewer1', but its type (CrystalDecisions.Web.CrystalReportViewer) is not compatible with the type of control (CrystalDecisions.Web.CrystalReportViewer


Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

it shows that missing to add any assembly or   compatibility problem is there

innerHTML in javascript

innerHTML in javascript
How to embed function_innerHTML in javascript with getElementById





HELLO

How to embed function_innerHTML in javascript with  getElementById
<script>
function function_innerHTML()
{
document.getElementById('div1').innerHTML="dev"

}
</script>
<body>
<div id='div1' style="color:red;font-face:30;font-family:forte">
HELLO
</div>
<input type="button" value="click" onclick="function_innerHTML()">
</body>

How to embed setTimeout in javascript

How to embed setTimeout in javascript
How to embed setTimeout  in javascript
<script>
function create_setTimeoutFunction()
{
alert("hi user")
setTimeout(" create_setTimeoutFunction()",1)
}
</script>
<body text="pink">
"How how r u?"
<input type="button" value="click" onclick="create_setTimeoutFunction()">
</body>
How to embed setTimeout in javascript


"How how r u?"

How to embed getElementById in javascript

How to embed getElementById in javascript
<script>
function  create_getElementById()
{
x=document.getElementById('first word').value;
y=document.getElementById('Second word').value;
alert(x+y)
}
</script>
<body>
<input type="text" id="txt1">
<input type="text" id="txt2">
<input type="button" value="click" onclick="create_getElementById()">
</body>






parseInt | eval | in javascript

parseInt | eval | in javascript
How to use  parseInt , eval , in javascript
<script>
function fun1()
{
x="dev"
y=8786
alert(parseInt(x)+y)
}

</script>
<body>
<input type="button" value="click" onclick="fun1()">
</body>


<script>
function create_function()
{
x="200+788"
alert(eval(x))
}
</script>
<body>
<input type="button" value="click" onclick="create_function()">
</body>

How to use parseInt , eval , in javascript










javascript program find the coordinate of two axis | code

javascript program find the coordinate of two axis | code
javascript program find the coordinate of two axis | code
<script>
function xycod()
{ var x1,y1;
x1=event.clientX;
y1=event.clientY;
alert("x-coordinate="+x1+" "+"y-coordinate="+y1);
}

javascript prompt | prompt in javascript

javascript prompt | prompt in javascript
How to write javascript in html pages with using prompt.
<html>
<head>
    <script type="text/javascript">
        x=prompt("Enter your date of birth:" ,",");
        y=Date.parse(x);
        today=new Date();
        age1=(today-y);
        alert("Your age is:"+age1+"milliseconds");
        age=age1/(1000*60*60*24*365);
        alert("Age is:"+Math.round(age)+"years");
    </script>
</head>
<body>
</html>



How to use prompt in javascript
<script>
function fun1()
{
x=prompt("enter a number");
y=prompt("enter a number");
alert(parseInt(x)+parseInt(y))
}
</script>
<body>
<input type="button" value="click" onclick="fun1()">
</body>

Before calling fun1() just create a function then use in script. 

php Tags | Type of tags | how to use tags

php Tags | Type of tags | how to use tags
php Tags
<?
print("welcome to php");
?>

// universal style tag
<?php
// php script
?>
short open tag
<?
 // php script
?>
//asp style tag

<%
//php script
%>
<script language="php">
//php script
</script>

// script type tag
By default Xampp 1.7.2 will not execute asp style tags and short open tags .Because php.ini we have to configuration  direction related  to this tags those are
 1) Asp_tags , short_open_tags  ,  the value of this tag is off by change this value to  "ON" we can execute this tag.
If we change the value of php.ini , php.conf direction we have to save the files then restart the web server.
<?php
print("universal style");
?>

<%
print("asp style");
%>
<?
print("short open tag");
?>
<script language="php">
print("script style");
</script>

How to calculate Area ,Perimeter of Rectangle ,Triangle , and Square with formula IN PHP

How to calculate Area ,Perimeter of Rectangle ,Triangle , and Square with formula IN PHP
How to use sqrt in php.
Formula to calculate Area and Perimeter of Rectangle ,Triangle , and Square.
Logic to develop Code in Php.

<?php

echo"<h1>RECTANGLE</h1>";
$l=30;
$b=40;
$area=$l*$b;
$peri=2*($l+$b);
echo "AREA: ".$area."<br>";
echo "PERIMETER: ".$peri."<br>";

echo"<h1>SQUARE</h1>";
$S=30;

$peri=4*$s;
$area=$s*$s;
echo "AREA: ".$area."<br>";
echo "PERIMETER: ".$peri."<br>";

echo"<h1>TRIANGLE</h1>";
$s1=30;
$s2=40;
$s3=50;

$peri= $s1 + $s2 + $s3;
$s=0.5*$peri;
$area=sqrt($s*($s-$s1)*($s-$s2)*($s-$s3));
echo "AREA: ".$area."<br>";
echo "PERIMETER: ".$peri."<br>";

?>

Php interview important questions

Php interview important questions

1,2,3...50  questions are there but that is equal to 500 Php  questions

What are the differences between Get and post methods in form submitting, give the case where we can use get and we can use post methods?
Who is the father of PHP and explain the changes in PHP versions?
How can we submit a form without a submit button?
In how many ways we can retrieve the date in the result set of mysql using PHP?
What is the difference between mysql_fetch_object and mysql_fetch_array?
What is the difference between $message and $$message?
How can we create a database using PHP and mysql?
What are the differences between require and include, include_once?

What are the different tables present in mysql, which type of table is generated when we are creating a table in the following syntax: create table employee(eno int(2),ename varchar(10)) ?
Functions in IMAP, POP3 AND LDAP?
How can I execute a PHP script using command line?

some other technical important questions


Shopping cart online validation i.e. how can we configure Paypal, etc.?
What is meant by nl2br()?
Draw the architecture of Zend engine?
What are the current versions of apache, PHP, and mysql?
What are the reasons for selecting lamp (linux, apache, mysql, PHP) instead of combination of other software programmes, servers and operating systems?
How can we encrypt and decrypt a data present in a mysql table using mysql?
How can we encrypt the username and password using PHP?
What are the features and advantages of object-oriented programming?
What are the differences between procedure-oriented languages and object-oriented languages?
What is the use of friend function?
What are the differences between public, private, protected, static, transient, final and volatile?
What are the different types of errors in PHP?
What is the functionality of the function strstr and stristr?
What are the differences between PHP 3 and PHP 4 and PHP 5?
How can we convert asp pages to PHP pages?
What is the functionality of the function htmlentities?
How can we get second of the current time using date function?
How can we convert the time zones using PHP?
What is meant by urlencode and urldocode?
What is the difference between the functions unlink and unset?
How can we register the variables into a session?
How can we get the properties (size, type, width, height) of an image using PHP image functions?
How can we get the browser properties using PHP?
What is the maximum size of a file that can be uploaded using PHP and how can we change this?
How can we increase the execution time of a PHP script?
How can we take a backup of a mysql table and how can we restore it. ?
How can we optimize or increase the speed of a mysql select query?
How many ways can we get the value of current session id?
How can we destroy the session, how can we unset the variable of a session?
How can we destroy the cookie?
How many ways we can pass the variable through the navigation between the pages?
What is the difference between ereg_replace() and eregi_replace()?
What are the different functions in sorting an array?
How can we know the count/number of elements of an array?
What is the PHP predefined variable that tells the What types of images that PHP supports?
How can I know that a variable is a number or not using a JavaScript?
List out some tools through which we can draw E-R diagrams for mysql.
How can I retrieve values from one database server and store them in other database server using PHP?
List out the predefined classes in PHP?
How can I make a script that can be bilanguage (supports English, German)?
What are the difference between abstract class and interface?
How can we send mail using JavaScript?

type of error using examples in php

type of error using examples in php
type of error using examples
Notice : Notice is a message to the end user it won't stop the execution  of the script .
 ex:=if we are trying to  acess undefined variables , then output is notice.
we can't see the notice on web page  directly because in php.ini we have one configuration directives that is
erro_reporting, the value of this directive id  is E_ALL
.
error_reporting_(e_all)
<?php
error_reporting(E_ALL);
$a=100;
echo $a;
echo $b;
?>
/*output
100
Notice: Undefined variable: b in F:\xampp\new\htdocs\php\var_dump.php on line 5
*?
but it will not stop the execution .

<?php
//error_reporting(E_ALL); put it into comments
$=100;
echo $a;
echo $b;
?>
/* output
100
*/

warning:-warning message will not stop the execution of the script , if we are trying  to access the undefined constant
the output is warning.
<?php
define("a","100");///declare constant
echo constant("a");
echo constant ("city");//warning
echo "scott";
?>

/*output
100 // executed
Warning: constant() [function.constant]: Couldn't find constant city in F:\xampp\new\htdocs\php\var_dump.php on line 4 // showing error
scott // executed
*/

Fatal error;
fatal error stops the execution of rest of the script if we are trying to call undefined function  the output is Fatal error.
<?php
echo "firt executable line form function 1";
function fun1()
{
echo "From function 1";
}
echo (fun1());
fun2();
?>
/*output
Executable line
From function 1 execution
Fatal error: Call to undefined function fun2() in F:\xampp\new\htdocs\php\var_dump.php on line 9
*/

<?php
fun2();
echo "firt executable line form function 1";
function fun1()
{
echo "From function 1";
}
echo (fun1());
?>
/*output
Fatal error: Call to undefined function fun2() in F:\xampp\new\htdocs\php\var_dump.php on line 2

How to calculate Area ,Perimeter of Rectangle ,Triangle , and Square with formula IN PHP

How to calculate Area ,Perimeter of Rectangle ,Triangle , and Square with formula IN PHP
How to use sqrt in php.
Formula to calculate Area and Perimeter of Rectangle ,Triangle , and Square.
Logic to develop Code in Php.

<?php

echo"<h1>RECTANGLE</h1>";
$l=30;
$b=40;
$area=$l*$b;
$peri=2*($l+$b);
echo "AREA: ".$area."<br>";
echo "PERIMETER: ".$peri."<br>";

echo"<h1>SQUARE</h1>";
$S=30;

$peri=4*$s;
$area=$s*$s;
echo "AREA: ".$area."<br>";
echo "PERIMETER: ".$peri."<br>";

echo"<h1>TRIANGLE</h1>";
$s1=30;
$s2=40;
$s3=50;

$peri= $s1 + $s2 + $s3;
$s=0.5*$peri;
$area=sqrt($s*($s-$s1)*($s-$s2)*($s-$s3));
echo "AREA: ".$area."<br>";
echo "PERIMETER: ".$peri."<br>";

?>

Circular queue implementation and operation | front | rear

Circular queue implementation and operation | front | rear
/* Program of circular queue implementation and operation on circular queue */

#include<stdio.h>
#include<conio.h>
#define max 5

typedef struct queue
{
int front,rear;
int item[max];
}queue;
queue q1;

void insert()
{
int n;
if((q1.front==0 && q1.rear==max-1) || (q1.front==q1.rear+1))
printf("\nQueue is full");
else
{
if (q1.front==-1)
q1.rear=q1.front=0;
else
if(q1.rear==max-1)
q1.rear=0;
else
q1.rear++;
printf("\nenter the element for insertion in queue:- ");
scanf("%d", &n);
q1.item[q1.rear]=n;
}
}

void del()
{
if (q1.front==-1)
printf("\nQueue is empty");
else
{
printf("\n%d is deleted from queue:- ",q1.item[q1.front]);
if(q1.front==q1.rear)
q1.front=q1.rear=-1;
else
if(q1.front==max-1)
q1.front=0;
else
q1.front++;
}
}

void display()
{
int front_temp=q1.front,rear_temp=q1.rear;
if(q1.front==-1)
printf("\nQueue is empty");
else
{
printf("\nelement of the queue are:-\n");
if(front_temp<=rear_temp)
{
while(front_temp<=rear_temp)
printf("%d\t",q1.item[front_temp++]);
}
else
{
while(front_temp<=max-1)
printf("%d\t",q1.item[front_temp++]);
front_temp=0;
while(front_temp<=rear_temp)
printf("%d\t",q1.item[front_temp++]);
}
}
}

void main()
{
int ch;
clrscr();
q1.front=q1.rear=-1;
while(1)
{
printf("\n\n1:for insertion");
printf("\n2:for deletion");
printf("\n3:for exit");
printf("\nEnter your choice:- ");
scanf("%d",&ch);
switch(ch)
{

case 1 :
insert();
display();
break;
case 2 :
del();
display();
break;
case 3:
exit(0);
default:
printf("\nyou entered wrong choice");
}
}
}
/*
Output:-

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 1
1

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 2
element of the queue are:-
1       2

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 3
element of the queue are:-
1       2       3

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 4
element of the queue are:-
1       2       3       4

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 5
element of the queue are:-
1       2       3       4       5

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
Queue is full
element of the queue are:-
1       2       3       4       5

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 2
1 is deleted from queue:-
element of the queue are:-
2       3       4       5

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 2
2 is deleted from queue:-
element of the queue are:-
3       4       5

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 1
element of the queue are:-
3       4       5       1

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 2
element of the queue are:-
3       4       5       1       2

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 3

*/

Circular linked list | malloc(sizeof) | deletion | insertion code

Circular linked list | malloc(sizeof) | deletion | insertion code



/* Program for implementation of circular linked list
and operation on cicular linked list */

# include <stdio.h>
# include <malloc.h>

struct node
{
int info;
struct node *link;
}*last;

void create(int data)
{
struct node *q,*temp;
temp=malloc(sizeof(struct node));
temp->info=data;
if(last==NULL)
{
last=temp;
temp->link=last;
}
else
{
temp->link=last->link;
last->link=temp;
last=temp;
}
}

void insbig(int data)
{
struct node *temp;
temp=malloc(sizeof(struct node));
temp->info=data;
temp->link=last->link;
last->link = temp;
}

void insmid(int data,int pos)
{

struct node *temp,*q;
int i;
q=last->link;
for(i=1;i<pos-1;i++)
q=q->link;
temp=malloc(sizeof(struct node));
temp->link=q->link;
temp->info=data;
q->link=temp;
}

void del(int data)
{
struct node *temp,*q;
if(last->link==last && last->info==data)
{
temp=last;
last=NULL;
free(temp);
}
q=last->link;
if(q->info==data)
{
temp=q;
last->link=q->link;
free(temp);
}
while(q->link!=last)
{
if(q->link->info==data)
{
temp=q->link;
q->link=temp->link;
free(temp);
printf("\n%d is deleted form list",data);
}
q=q->link;
}
if(q->link->info==data)
{
temp=q->link;
q->link=last->link;
free(temp);
last=q;
}
printf("\nElement %d not found",data);
}

void display()
{
struct node *q;
if(last==NULL)
printf("\nList is empty");
q=last->link;
while(q!=last)
{
printf("%d\t",q->info);
q=q->link;
}
printf("%d",last->info);
}

void main()
{
int ch,n,m,pos,i;
last=NULL;
clrscr();
while(1)
{
printf("\n\n1:For Create List");
printf("\n2:For Add at begining");
printf("\n3:For Add between");
printf("\n4:For Delete");
printf("\n5:For Display");
printf("\n6:For Exit");
printf("\nEnter your choice:- ");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\nHow many nodes you want into linked list:- ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter the element:- ");
scanf("%d",&m);
create(m);
}
break;
case 2:
printf("\nEnter the element:- ");
scanf("%d",&m);
insbig(m);
break;
case 3:
printf("\nEnter the element:- ");
scanf("%d",&m);
printf("\nEnter the position at which this element is inserted:- ");
scanf("%d",&pos);
insmid(m,pos);
break;
case 4:
if(last==NULL)
printf("\nList is empty\n");
else
{
printf("\nEnter the number for deletion:- ");
scanf("%d",&m);
del(m);
}
break;
case 5:
display();
break;
case 6:
exit(0);
default:
printf("\nYou entered wrong choice");
}
}
}

Conversion from infix to postfix and prefix expression | priority method and evaluation of postfix and prefix expression | Output

Conversion from infix to postfix and prefix expression | priority method and evaluation of postfix and prefix expression | Output
conversion from infix to postfix and prefix expression | priority method and evaluation of
postfix and prefix expression | Output
/* How to  convert from infix to postfix and prefix expression
by priority method and evaluation of postfix and prefix expression */

#include<stdio.h>
#include<conio.h>
#define max 50

typedef struct stack
{
int top;
char item[max];
}stack;
stack s1;

void push(char n)
{
if(s1.top==max-1)
puts("\nstack is full");
else
s1.item[++s1.top]=n;
}

int pop()
{
if(s1.top==-1)
return s1.top;
else
return(s1.item[s1.top--]);
}

int prio(char ch)
{
int sh;
if(ch=='^' || ch=='$')
sh=3;
else if(ch=='*' || ch=='/')
sh=2;
else if(ch=='+' || ch=='-')
sh=1;
else if(ch=='{' || ch=='(' || ch=='[')
sh=0;
return sh;
}

void in_post()
{
int i,j=0;
char inf[20],post[20],ch1;
printf("\nenter infix expression:- ");
scanf("%s",&inf);
for(i=0;inf[i]!='\0';i++)
{
if(inf[i]=='{' || inf[i]=='[' || inf[i]=='(')
push(inf[i]);
else if((inf[i]>=65 && inf[i]<91) || (inf[i]>=97 && inf[i]<123))
post[j++]=inf[i];
else if(inf[i]=='^' || inf[i]=='$' || inf[i]=='+' || inf[i]=='-' || inf[i]=='*' || inf[i]=='/')
{
if(s1.top==-1)
push(inf[i]);
else
{
if(prio(inf[i])>prio(s1.item[s1.top]))
push(inf[i]);
else
{
while(prio(inf[i])<=prio(s1.item[s1.top]))
{
post[j++]=pop();
if(s1.top==-1)
break;
}
push(inf[i]);
}
}
}
else if(inf[i]==')'||inf[i]=='}'||inf[i]==']')
{
while(s1.item[s1.top]!='(' && s1.item[s1.top]!='[' && s1.item[s1.top]!='{')
post[j++]=pop();
pop();
}
}
if(s1.top!=-1)
{
while(s1.top!=-1)
post[j++]=pop();
}
post[j]='\0';
printf("\npostfix expression is:- %s",post);
}

int prio1(char ch)
{
int sh;
if(ch=='^' || ch=='$')
sh=3;
if(ch=='*' || ch=='/')
sh=2;
if(ch=='+' || ch=='-')
sh=1;
if(ch=='}' || ch==')' || ch==']')
sh=0;
return sh;
}

void in_pre()
{
int i,j=0;
char inf[30],pre[30],ch1;
printf("\nenter infix expression:- ");
scanf("%s",&inf);
for(i=strlen(inf);i>=0;i--)
{
if(inf[i]=='}' || inf[i]==']' || inf[i]==')')
push(inf[i]);
else if((inf[i]>=65 && inf[i]<91) || (inf[i]>=97 && inf[i]<123))
pre[j++]=inf[i];
else if(inf[i]=='^' || inf[i]=='$' || inf[i]=='+' || inf[i]=='-' || inf[i]=='*' || inf[i]=='/')
{
if(s1.top==-1)
push(inf[i]);
else
{
if(prio1(inf[i])>=prio1(s1.item[s1.top]))
push(inf[i]);
else
{
while(prio1(inf[i])<prio1(s1.item[s1.top]))
{
pre[j++]=pop();
if(s1.top==-1)
break;
}
push(inf[i]);
}
}
}
else if(inf[i]=='{'||inf[i]=='('||inf[i]=='[')
{
while(s1.item[s1.top]!=')' && s1.item[s1.top]!=']' && s1.item[s1.top]!='}')
pre[j++]=pop();
pop();
}
}
if(s1.top!=-1)
{
while(s1.top!=-1)
pre[j++]=pop();
}
pre[j]='\0';
printf("\nprefix expression is:- %s",strrev(pre));
}

void eval_post()
{
int a,b,c,d,e,i,op1,op2;
char pos[30];
printf("\nenter the value of a,b,c,d,e:- ");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
printf("\nenter postfix expression:- ");
scanf("%s",&pos);
for(i=0;pos[i]!='\0';i++)
{
switch(pos[i])
{
case 'a':
push(a);
break;
case 'b':
push(b);
break;
case 'c':
push(c);
break;
case 'd':
push(d);
break;
case 'e':
push(e);
break;
default:
op2=pop();
op1=pop();
}
switch(pos[i])
{
case '+':
push(op1+op2);
break;
case '-':
push(op1-op2);
break;
case '*':
push(op1*op2);
break;
case '/':
push(op1/op2);
break;
case '%':
push(op1%op2);
break;
}
}
printf("\nvalue of postfix expression is:- %d",pop());
}

void eval_pre()
{
int a,b,c,d,e,i,op1,op2,l;
char pre[30];
printf("\nenter the value of a,b,c,d,e:- ");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
printf("\nenter prefix expression:- ");
scanf("%s",&pre);
l=strlen(pre);
for(i=l;i>=0;i--)
{
switch(pre[i])
{
case 'a':
push(a);
break;
case 'b':
push(b);
break;
case 'c':
push(c);
break;
case 'd':
push(d);
break;
case 'e':
push(e);
break;
default:
op1=pop();
op2=pop();
break;
}
switch(pre[i])
{
case '+':
push(op1+op2);
break;
case '-':
push(op1-op2);
break;
case '*':
push(op1*op2);
break;
case '/':
push(op1/op2);
break;
case '%':
push(op1%op2);
break;
}
}
printf("\nvalue of prefix expression is:- %d",pop());
}

int menu()
{
int ch;
s1.top=-1;
printf("\n\n1:for conversion from infix to postfix expression");
printf("\n2:for conversion from infix to prefix expression");
printf("\n3:for evaluation of postfix expression");
printf("\n4:for evaluation of prefix expression");
printf("\n5:for exit");
printf("\nenter your choice:- ");
scanf("%d",&ch);
switch(ch)
{
case 1:
in_post();
menu();
break;
case 2:
in_pre();
menu();
break;
case 3:
eval_post();
menu();
break;
case 4:
eval_pre();
menu();
break;
case 5:
exit(0);
default:
printf("\nyou entered wrong choice");
menu();
}
return 0;
}

void main()
{
clrscr();
menu();
getch();
}

Insertion | Deletion using circular queue | How to write code

Insertion | Deletion using circular queue | How to write code
How to write Program from insert, delete using
circular queue

#include<stdio.h>
#include<conio.h>
#define max 5

typedef struct queue
{
int front,rear;
int item[max];
}queue;
queue q1;

void insert()
{
int n;
if((q1.front==0 && q1.rear==max-1) || (q1.front==q1.rear+1))
printf("\nQueue is full");
else
{
if (q1.front==-1)
q1.rear=q1.front=0;
else
if(q1.rear==max-1)
q1.rear=0;
else
q1.rear++;
printf("\nenter the element for insertion in queue:- ");
scanf("%d", &n);
q1.item[q1.rear]=n;
}
}

void del()
{
if (q1.front==-1)
printf("\nQueue is empty");
else
{
printf("\n%d is deleted from queue:- ",q1.item[q1.front]);
if(q1.front==q1.rear)
q1.front=q1.rear=-1;
else
if(q1.front==max-1)
q1.front=0;
else
q1.front++;
}
}

void display()
{
int front_temp=q1.front,rear_temp=q1.rear;
if(q1.front==-1)
printf("\nQueue is empty");
else
{
printf("\nelement of the queue are:-\n");
if(front_temp<=rear_temp)
{
while(front_temp<=rear_temp)
printf("%d\t",q1.item[front_temp++]);
}
else
{
while(front_temp<=max-1)
printf("%d\t",q1.item[front_temp++]);
front_temp=0;
while(front_temp<=rear_temp)
printf("%d\t",q1.item[front_temp++]);
}
}
}

void main()
{
int ch;
clrscr();
q1.front=q1.rear=-1;
while(1)
{
printf("\n\n1:for insertion");
printf("\n2:for deletion");
printf("\n3:for exit");
printf("\nEnter your choice:- ");
scanf("%d",&ch);
switch(ch)
{

case 1 :
insert();
display();
break;
case 2 :
del();
display();
break;
case 3:
exit(0);
default:
printf("\nyou entered wrong choice");
}
}
}
/*
Output:-

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 1
1

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 2
element of the queue are:-
1       2

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 3
element of the queue are:-
1       2       3

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 4
element of the queue are:-
1       2       3       4

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 5
element of the queue are:-
1       2       3       4       5

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
Queue is full
element of the queue are:-
1       2       3       4       5

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 2
1 is deleted from queue:-
element of the queue are:-
2       3       4       5

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 2
2 is deleted from queue:-
element of the queue are:-
3       4       5

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 1
element of the queue are:-
3       4       5       1

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 1
enter the element for insertion in queue:- 2
element of the queue are:-
3       4       5       1       2

1:for insertion
2:for deletion
3:for exit
Enter your choice:- 3

*/

Program for conversion from infix to postfix using push() and pop()

Program for conversion from infix to postfix using push() and pop()
/* How to write Data structure Program for conversion from infix to postfix expression source code */

#include<stdio.h>
#include<conio.h>
#define max 50

typedef struct stack
{
int top;
char item[max];
}stack;
stack s1;

int push(char n)
{
if(s1.top==max-1)
puts("\nstack is full");
else
s1.item[++s1.top]=n;
return 0;
}

int pop()
{
if(s1.top==-1)
{
puts("\nstack is empty");
return 0;
}
else
return(s1.item[s1.top--]);
}

void main()
{
char inf[30],pos[30],ch,temp;
int i,j=0,valid=1;
s1.top=-1;
clrscr();
printf("\nenter infix expression:- ");
scanf("%s",&inf);
for(i=0;inf[i]!='\0';i++)
{
if(inf[i]=='(' || inf[i]=='{' || inf[i]=='[')
push(inf[i]);
if(inf[i]==')' || inf[i]=='}' || inf[i]==']')
if(s1.top==-1)
valid=0;
else
{
temp=pop();
if( inf[i]==')' && (temp=='{' || temp=='[') )
valid=0;
if( inf[i]=='}' && (temp=='(' || temp=='[') )
valid=0;
if( inf[i]==']' && (temp=='(' || temp=='{') )
valid=0;
}
}
if(s1.top>=0)
valid=0;
if( valid==1 )
{
for(i=0;inf[i]!='\0';i++)
{
if((inf[i]>=65 && inf[i]<91)||(inf[i]>=97 && inf[i]<123))
pos[j++]=inf[i];
if(inf[i]=='('||inf[i]=='{'||inf[i]=='['||inf[i]=='+'||inf[i]=='-'||inf[i]=='*'||inf[i]=='/'||inf[i]=='%')
push(inf[i]);
if(inf[i]==')'||inf[i]=='}'||inf[i]==']')
{
while(s1.top!=-1)
{
ch=pop();
if(ch!='('&&ch!='['&&ch!='{')
pos[j++]=ch;
}
}
}
pos[j]='\0';
printf("\npostfix expression is:- %s",pos);
}
else
printf("\nNot Valid expression\n");
getch();
}

Logivc of Implementation of Hash Function | Data Structure

Logivc of Implementation of Hash Function | Data Structure
How to write Data structure  Program for implementation of Hash Function using for loop with output
#include<stdio.h>
#include<conio.h>

int hash(int no)
{
return no%10;
}

void main()
{
int arr[10],i,pos,cnt,no,ch;
clrscr();
for(i=0;i<10;i++)
arr[i]=-1;
do
{
printf("\n\n Enter the no. that you want to insert:- ");
scanf("%d",&no);
pos=hash(no);
if(pos>10)
pos=hash(pos);
if(arr[pos]==-1)
arr[pos]=no;
else
{
i=1;
cnt=0;
while(arr[pos+i]!=-1)
{
i++;
cnt++;
if(cnt==10)
break;
}
if(arr[pos+i]==-1)
arr[pos+i]=no;
}
if(cnt==10)
printf("\n Memory is full.");
printf("\n\n The elements in memory with address:- ");
for(i=0;i<10;i++)
printf("\n[%2d]=>%2d",i,arr[i]);
printf("\n Do you want to continue??(Yes=1/No=0):- ");
scanf("%d",&ch);
}while(ch);
getch();
}

/*
Output:-

Enter the no. that you want to insert:- 4

The elements in memory with address:-
[ 0]=>-1
[ 1]=>-1
[ 2]=>-1
[ 3]=>-1
[ 4]=> 4
[ 5]=>-1
[ 6]=>-1
[ 7]=>-1
[ 8]=>-1
[ 9]=>-1
Do you want to continue??(Yes=1/No=0):- 1

Enter the no. that you want to insert:- 67

The elements in memory with address:-
[ 0]=>-1
[ 1]=>-1
[ 2]=>-1
[ 3]=>-1
[ 4]=> 4
[ 5]=>-1
[ 6]=>-1
[ 7]=>67
[ 8]=>-1
[ 9]=>-1
Do you want to continue??(Yes=1/No=0):- 1

Enter the no. that you want to insert:- 29

The elements in memory with address:-
[ 0]=>-1
[ 1]=>-1
[ 2]=>-1
[ 3]=>-1
[ 4]=> 4
[ 5]=>-1
[ 6]=>-1
[ 7]=>67
[ 8]=>-1
[ 9]=>29
Do you want to continue??(Yes=1/No=0):- 1

Enter the no. that you want to insert:- 60

The elements in memory with address:-
[ 0]=>60
[ 1]=>-1
[ 2]=>-1
[ 3]=>-1
[ 4]=> 4
[ 5]=>-1
[ 6]=>-1
[ 7]=>67
[ 8]=>-1
[ 9]=>29
Do you want to continue??(Yes=1/No=0):- 0

*/

Program for infix to prefix conversion | Data Structure | how to write code

Program for infix to prefix conversion | Data Structure | how to write code
/* Data structure program for infix to prefix conversion with output */

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define max 50

typedef struct stack
{
int top;
char item[max];
}stack;
stack s1;

int push(char n)
{
if(s1.top==max-1)
puts("\nstack is full");
else
s1.item[++s1.top]=n;
return 0;
}
int pop()
{
if(s1.top==-1)
{
puts("\nstack is empty");
return 0;
}
else
return(s1.item[s1.top--]);
}

void main()
{
char inf[30],pre[30],temp,ch;
int i,j=0,l,valid=1;
s1.top=-1;
clrscr();
printf("\nenter infix expression:- ");
scanf("%s",&inf);
l=strlen(inf);
for(i=0;inf[i]!='\0';i++)
{
if(inf[i]=='(' || inf[i]=='{' || inf[i]=='[')
push( inf[i] );
if(inf[i]==')' || inf[i]=='}' || inf[i]==']')
if(s1.top == -1)
valid=0;
else
{
temp=pop();
if( inf[i]==')' && (temp=='{' || temp=='[') )
valid=0;
if( inf[i]=='}' && (temp=='(' || temp=='[') )
valid=0;
if( inf[i]==']' && (temp=='(' || temp=='{') )
valid=0;
}
}
if(s1.top>=0)
valid=0;
if( valid==1 )
{
for(i=l;i>=0;i--)
{
if((inf[i]>=65 && inf[i]<91)||(inf[i]>=97 && inf[i]<123))
pre[j++]=inf[i];
if(inf[i]==')'||inf[i]=='}'||inf[i]==']'||inf[i]=='+'||inf[i]=='-'||inf[i]=='*'||inf[i]=='/'||inf[i]=='%')
push(inf[i]);
if(inf[i]=='('||inf[i]=='{'||inf[i]=='[')
{
while(s1.top!=-1)
{
ch=pop();
if(ch!=']'&&ch!='}'&&ch!=')')
pre[j++]=ch;
}
}
}
pre[j]='\0';
printf("\nprefix expression is:- %s",strrev(pre));
}
else
printf("\nNot Valid Expression");
getch();
}

operation on linked list | Reverse | insert | add | delete | search

operation on linked list | Reverse | insert | add | delete | search
Data structure Program | operation on linked list | Reverse | insert | add | delete | search
#include<stdio.h>
#include<conio.h>
#include<malloc.h>

struct node
{
int info;
struct node *link;
}*start;

void create(int data)
{
struct node *q,*temp;
temp=malloc(sizeof(struct node));
temp->info=data;
temp->link=NULL;
if(start==NULL)
start=temp;
else
{
q=start;
while(q->link!=NULL)
q=q->link;
q->link=temp;
}
}

void display()
{
struct node *temp;
temp=start;
if(start==NULL)
printf("\nList Is Empty");
else
{
while(temp!=NULL)
{
printf("%d\t",temp->info);
temp=temp->link;
}
}
}

void insbeg(int data)
{
struct node *temp;
temp=malloc(sizeof(struct node));
temp->info=data;
temp->link=start;
start=temp;
}

void insmid(int data,int pos)
{
int i;
struct node *q,*temp;
temp=malloc(sizeof(struct node));
temp->info=data;
q=start;
for(i=1;i<pos-1;i++)
q=q->link;
temp->link=q->link;
q->link=temp;
}

void insend(int data)
{
struct node *temp,*q;
q=start;
temp=malloc(sizeof(struct node));
temp->info=data;
while(q->link!=NULL)
q=q->link;
q->link=temp;
temp->link=NULL;
}

void delfir()
{
struct node *temp;
temp=start;
start=start->link;
free(temp);
}

void delmid(int data)
{
struct node *temp,*q;
q=start;
while(q->link->link!=NULL)
{
if(q->link->info==data)
{
temp=q->link;
q->link=temp->link;
free(temp);
}
q=q->link;
}
}

void delend()
{
struct node *q,*temp;
q=start;
while(q->link->link!=NULL)
q=q->link;
temp=q->link;
q->link=NULL;
free(temp);
}

void rev()
{
struct node *p1,*p2,*p3;
p1=start;
p2=p1->link;
p3=p2->link;
p1->link=NULL;
p2->link=p1;
while(p3!=NULL)
{
p1=p2;
p2=p3;
p3=p3->link;
p2->link=p1;
}
start=p2;
}

void delpos(int pos)
{
int i;
struct node *q,*temp;
q=start;
for(i=1;i<pos-1;i++)
q=q->link;
temp=q->link;
q->link=temp->link;
free(temp);
}

void search(int data)
{
int i=0,flag=1;
struct node *temp;
temp=start;
while(temp!=NULL)
{
i++;
if(temp->info==data)
{
printf("\n%d is found at %d position",data,i);
flag=0;
break;
}
temp=temp->link;
}
if(flag==1)
printf("%d is not found",data);
}

void searchpos(int pos,int n)
{
int i;
struct node *temp;
temp=start;
if(pos>n)
printf("\nyou enter wrong position");
else
{
for(i=1;i<pos;i++)
temp=temp->link;
printf("\n%d is found at %d position",temp->info,i);
}
}

void menu()
{
int ch,n,num,i,pos;
puts("\n\n1:for create list");
puts("2:for display");
puts("3:for exit");
puts("4:for insertion at begining");
puts("5:for insertion at between");
puts("6:for insertion at end");
puts("7:for delete first element");
puts("8:for deletion at between");
puts("9:for delete last element");
puts("10:for reverse the list");
puts("11:for delete element by position");
puts("12:for searching the element");
puts("13:for searching the element by position");
printf("\nenter your choice:- ");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\nhow many node you want to enter:- ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nenter the %d element:- ",i+1);
scanf("%d",&num);
create(num);
}
menu();
break;
case 2:
display();
menu();
break;
case 3:
exit(0);
case 4:
printf("\nenter the element you want to insert:- ");
scanf("%d",&num);
insbeg(num);
menu();
break;
case 5:
printf("\nenter the element you want to insert:- ");
scanf("%d",&num);
printf("\nenter the position you want to insert:- ");
scanf("%d",&pos);
insmid(num,pos);
menu();
break;
case 6:
printf("\nenter the element you want to insert:- ");
scanf("%d",&num);
insend(num);
menu();
break;
case 7:
delfir();
menu();
break;
case 8:
printf("\nenter the element you want to delete:- ");
scanf("%d",&num);
delmid(num);
menu();
break;
case 9:
delend();
menu();
break;
case 10:
rev();
menu();
break;
case 11:
printf("\nenter the position:- ");
scanf("%d",&pos);
delpos(pos);
menu();
break;
case 12:
printf("\nenter the element you want to search:- ");
scanf("%d",&num);
search(num);
menu();
break;
case 13:
printf("\nenter the position for searching the element:- ");
scanf("%d",&pos);
searchpos(pos,n);
menu();
break;
default:
printf("\nYou enter wrong choice");
menu();
}
}

void main()
{
clrscr();
start=NULL;
menu();
getch();
}

Unsorted list | Sorted list | implementation of Insertion Sort | output

Unsorted list | Sorted list | implementation of Insertion Sort | output
/* Program for implementation of Insertion Sort */


#include<stdio.h>
#include<conio.h>
#define max 20

void main()
{
int i,j,n,k,t,temp,a[max];
clrscr();
printf("\How many no. you want to insert into list:- ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter %d no:- ",i+1);
scanf("%d",&a[i]);
}
printf("\nUnsorted list is:-\n");
for(i=0;i<n;i++)
printf("\n%d",a[i]);
for(i=1;i<n;i++)
{
for(j=0;j<i;j++)
{
if(a[i]<a[j])
{
temp=a[j];
a[j]=a[i];
for(k=i;k>j;k--)
a[k]=a[k-1];
a[k+1]=temp;
}
}
}
printf("\n\nSorted list is:-\n");
for(i=0;i<n;i++)
printf("\n%d",a[i]);
getch();
}

/*
Output:-

How many no. you want to insert into list:- 5

Enter 1 no:- 4
Enter 2 no:- 3
Enter 3 no:- 5
Enter 4 no:- 2
Enter 5 no:- 1

Unsorted list is:-

4
3
5
2
1

Sorted list is:-

1
2
3
4
5

*/

stack implementation using linked list | display() | Source code

stack implementation using linked list | display() | Source code
/* Program for stack implementation using linked list */ pop() | display() function

#include<stdio.h>
#include<conio.h>
#include<malloc.h>

struct node
{
int info;
struct node *link;
}*top=NULL;

void push()
{
int n;
struct node *temp;
temp=malloc(sizeof(struct node));
printf("\nenter the element u want to insert:- ");
scanf("%d",&n);
temp->info=n;
temp->link=top;
top=temp;
}

void pop()
{
struct node *temp;
temp=top;
if(top==NULL)
printf("\nstack is empty");
else
{
printf("\n%d is deleted from stack\n",top->info);
top=top->link;
free(temp);
}
}

void display()
{
struct node *temp;
temp=top;
if(top==NULL)
printf("\nstackis empty");
else
{
while(temp!=NULL)
{
printf("%d\t",temp->info);
temp=temp->link;
}
}
}

void main()
{
int ch;
clrscr();
while(1)
{
printf("\n1:for insertion");
printf("\n2:for deletion");
printf("\n3:for display");
printf("\n4:for exit");
printf("\nenter your choice:- ");
scanf("%d",&ch);
switch(ch)
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
display();
break;
case 4:
exit(0);
default:
printf("\nyou entered wrong choice");
}
}
}

Program for queue implementation using linked list | Diaply() | Delete() | insert()

Program for queue implementation using linked list | Diaply() | Delete() | insert()
Data structure Program for queue implementation using linked list source code
/* Program for queue implementation using linked list */

#include<stdio.h>
#include<conio.h>
#include<malloc.h>

struct node
{
int info;
struct node *link;
}*front=NULL,*rear=NULL;

void insert()
{
int n;
struct node *temp;
temp=malloc(sizeof(struct node));
printf("\nenter the element u want to insert:- ");
scanf("%d",&n);
temp->info=n;
temp->link=NULL;
if(front==NULL)
front=temp;
else
rear->link=temp;
rear=temp;
}

void del()
{
struct node *temp;
temp=front;
if(front==NULL)
printf("\nqueue is empty");
else
{
printf("\n%d is deleted from queue\n",front->info);
front=front->link;
free(temp);
}
}

void display()
{
struct node *temp;
temp=front;
if(front==NULL || front==rear+1)
printf("\nqueueis empty");
else
{
while(temp!=NULL)
{
printf("%d\t",temp->info);
temp=temp->link;
}
}
}

void main()
{
int ch;
clrscr();
while(1)
{
printf("\n1:for insertion");
printf("\n2:for deletion");
printf("\n3:for display");
printf("\n4:for exit");
printf("\nenter your choice:- ");
scanf("%d",&ch);
switch(ch)
{
case 1:
insert();
break;
case 2:
del();
break;
case 3:
display();
break;
case 4:
exit(0);
default:
printf("\nyou entered wrong choice");
}
}
}

Multiplication of two(2) polynomials | How to write code

Multiplication of two(2) polynomials | How to write code
Data structure program | multiplication of polynomials | source code
/* Program for multiplication of polynomials */

#include<stdio.h>
#include<conio.h>
#define max 20

typedef struct
{
int coef;
int deg;
}poly;
poly p1[max],p2[max],p3[max],p4[max];

void createpoly(poly p[],int x)
{
int i;
for(i=0;i<x;i++)
{
printf("\nEnter the %d coefficient of polynomial:- ",i+1);
scanf("%d",&p[i].coef);
printf("\nEnter the %d degree of polynomial:- ",i+1);
scanf("%d",&p[i].deg);
}
sort(p,x);
printf("\nEntered polynomial is:- ");
displaypoly(p,x);
}

int displaypoly(poly p[],int x)
{
int i;
for(i=0;i<x-1;i++)
printf("%dX^%d+",p[i].coef,p[i].deg);
printf("%dX^%d",p[i].coef,p[i].deg);
return 0;
}

int sort(poly p[],int x)
{
int i,j,temp1,temp2;
for(i=0;i<x;i++)
{
for(j=i+1;j<x;j++)
{
if(p[i].deg<p[j].deg)
{
temp1=p[i].deg;
p[i].deg=p[j].deg;
p[j].deg=temp1;
temp2=p[i].coef;
p[i].coef=p[j].coef;
p[j].coef=temp2;
}
}
}
return 0;
}

void mulpoly(int m,int n)
{
int i=0,j=0,k=0,l=0;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++,k++)
{
p3[k].coef=p1[i].coef*p2[j].coef;
p3[k].deg=p1[i].deg+p2[j].deg;
}
}
sort(p3,k);
for(i=0,j=i+1,l=0;i<k;i++,j++,l++)
{
if(p3[i].deg==p3[j].deg)
{
p4[l].coef=p3[i].coef+p3[j].coef;
p4[l].deg=p3[i++].deg;
}
else
{
p4[l].coef=p3[i].coef;
p4[l].deg=p3[i].deg;
}
}
displaypoly(p4,l);
}

void main()
{
int m,n;
clrscr();
printf("\nHow many term you want into the 1st polynomial:- ");
scanf("%d",&m);
createpoly(p1,m);
printf("\n\nHow many term you want into the 2nd polynomial:- ");
scanf("%d",&n);
createpoly(p2,n);
printf("\n\nMultiplication of two polynomials is:- ");
mulpoly(m,n);
getch();
}

postfix evaluation | How to write postfix evaluation source code

 postfix evaluation | How to write postfix evaluation source code
Data structure  Program |  postfix evaluation | source code
/* program for postfix evaluation */

#include<stdio.h>
#include<conio.h>
#define max 50

typedef struct stack
{
int top;
int item[max];
}stack;
stack s1;

void push(int n)
{
if(s1.top==max-1)
puts("\nstack is full");
else
s1.item[++s1.top]=n;
}

int pop()
{
if(s1.top==-1)
return s1.top;
else
return(s1.item[s1.top--]);
}

void main()
{
int a,b,c,d,e,i,op1,op2;
char pos[30];
s1.top=-1;
clrscr();
puts("\nenter the value of a,b,c,d,e");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
printf("\nenter postfix expression:- ");
scanf("%s",&pos);
for(i=0;pos[i]!='\0';i++)
{
switch(pos[i])
{
case 'a':
push(a);
break;
case 'b':
push(b);
break;
case 'c':
push(c);
break;
case 'd':
push(d);
break;
case 'e':
push(e);
break;
default:
op2=pop();
op1=pop();
}
switch(pos[i])
{
case '+':
push(op1+op2);
break;
case '-':
push(op1-op2);
break;
case '*':
push(op1*op2);
break;
case '/':
push(op1/op2);
break;
case '%':
push(op1%op2);
break;
}
}
printf("\nvalue of postfix expression is:- %d",pop());
getch();
}

prefix evaluation | program source code for prefix evaluation

prefix evaluation | program source code for prefix evaluation
Data structure program | prefix evaluation |  source code
/* Program for prefix evaluation. */

#include<stdio.h>
#include<conio.h>
#define max 50

typedef struct stack
{
int top;
int item[max];
}stack;
stack s1;

void push(int n)
{
if(s1.top==max-1)
puts("\nstack is full");
else
s1.item[++s1.top]=n;
}

int pop()
{
if(s1.top==-1)
return s1.top;
else
return(s1.item[s1.top--]);
}

void main()
{
int a,b,c,d,e,i,op1,op2,l;
char pre[30];
s1.top=-1;
clrscr();
puts("enter the value of a,b,c,d,e");
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
printf("\nenter prefix expression:- ");
scanf("%s",&pre);
l=strlen(pre);
for(i=l;i>=0;i--)
{
switch(pre[i])
{
case 'a':
push(a);
break;
case 'b':
push(b);
break;
case 'c':
push(c);
break;
case 'd':
push(d);
break;
case 'e':
push(e);
break;
default:
op1=pop();
op2=pop();
break;
}
switch(pre[i])
{
case '+':
push(op1+op2);
break;
case '-':
push(op1-op2);
break;
case '*':
push(op1*op2);
break;
case '/':
push(op1/op2);
break;
case '%':
push(op1%op2);
break;
}
}
printf("\nvalue of prefix expression is:- %d",pop());
getch();
}

c#.net how to use namespace and class and creat object

c#.net how to use namespace and class and creat object
simple program in c#.net  how to use namespace and class and creat object

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace constant
{
class Program
{
int i = 10;
float j = 3.4f; // here we will use 3.4f not only 3.4//


public void display()
{
Console.Write("roll  number"+i+"\n"+"salary ="+j +"rs");
}

static void Main(string[] args)
{
Program p = new Program();
p.display();

}
}
}


output of the program

program //simple program in c#.net  how to use namespace and class and create object//


roll no=10
salary =3.4 rs

implementation and operation on linked list

implementation and operation on linked list
/* Program for implementation and operation on linked list */
create | start | temp | delete | reverse | search | position
#include<stdio.h>
#include<conio.h>
#include<malloc.h>

struct node
{
int info;
struct node *link;
}*start;

void create(int data)
{
struct node *q,*temp;
temp=malloc(sizeof(struct node));
temp->info=data;
temp->link=NULL;
if(start==NULL)
start=temp;
else
{
q=start;
while(q->link!=NULL)
q=q->link;
q->link=temp;
}
}

void display()
{
struct node *temp;
temp=start;
if(start==NULL)
printf("\nList Is Empty");
else
{
while(temp!=NULL)
{
printf("%d\t",temp->info);
temp=temp->link;
}
}
}

void insbeg(int data)
{
struct node *temp;
temp=malloc(sizeof(struct node));
temp->info=data;
temp->link=start;
start=temp;
}

void insmid(int data,int pos)
{
int i;
struct node *q,*temp;
temp=malloc(sizeof(struct node));
temp->info=data;
q=start;
for(i=1;i<pos-1;i++)
q=q->link;
temp->link=q->link;
q->link=temp;
}

void insend(int data)
{
struct node *temp,*q;
q=start;
temp=malloc(sizeof(struct node));
temp->info=data;
while(q->link!=NULL)
q=q->link;
q->link=temp;
temp->link=NULL;
}

void delfir()
{
struct node *temp;
temp=start;
start=start->link;
free(temp);
}

void delmid(int data)
{
struct node *temp,*q;
q=start;
while(q->link->link!=NULL)
{
if(q->link->info==data)
{
temp=q->link;
q->link=temp->link;
free(temp);
}
q=q->link;
}
}

void delend()
{
struct node *q,*temp;
q=start;
while(q->link->link!=NULL)
q=q->link;
temp=q->link;
q->link=NULL;
free(temp);
}

void rev()
{
struct node *p1,*p2,*p3;
p1=start;
p2=p1->link;
p3=p2->link;
p1->link=NULL;
p2->link=p1;
while(p3!=NULL)
{
p1=p2;
p2=p3;
p3=p3->link;
p2->link=p1;
}
start=p2;
}

void delpos(int pos)
{
int i;
struct node *q,*temp;
q=start;
for(i=1;i<pos-1;i++)
q=q->link;
temp=q->link;
q->link=temp->link;
free(temp);
}

void search(int data)
{
int i=0,flag=1;
struct node *temp;
temp=start;
while(temp!=NULL)
{
i++;
if(temp->info==data)
{
printf("\n%d is found at %d position",data,i);
flag=0;
break;
}
temp=temp->link;
}
if(flag==1)
printf("%d is not found",data);
}

void searchpos(int pos,int n)
{
int i;
struct node *temp;
temp=start;
if(pos>n)
printf("\nyou enter wrong position");
else
{
for(i=1;i<pos;i++)
temp=temp->link;
printf("\n%d is found at %d position",temp->info,i);
}
}

void menu()
{
int ch,n,num,i,pos;
puts("\n\n1:for create list");
puts("2:for display");
puts("3:for exit");
puts("4:for insertion at begining");
puts("5:for insertion at between");
puts("6:for insertion at end");
puts("7:for delete first element");
puts("8:for deletion at between");
puts("9:for delete last element");
puts("10:for reverse the list");
puts("11:for delete element by position");
puts("12:for searching the element");
puts("13:for searching the element by position");
printf("\nenter your choice:- ");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\nhow many node you want to enter:- ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nenter the %d element:- ",i+1);
scanf("%d",&num);
create(num);
}
menu();
break;
case 2:
display();
menu();
break;
case 3:
exit(0);
case 4:
printf("\nenter the element you want to insert:- ");
scanf("%d",&num);
insbeg(num);
menu();
break;
case 5:
printf("\nenter the element you want to insert:- ");
scanf("%d",&num);
printf("\nenter the position you want to insert:- ");
scanf("%d",&pos);
insmid(num,pos);
menu();
break;
case 6:
printf("\nenter the element you want to insert:- ");
scanf("%d",&num);
insend(num);
menu();
break;
case 7:
delfir();
menu();
break;
case 8:
printf("\nenter the element you want to delete:- ");
scanf("%d",&num);
delmid(num);
menu();
break;
case 9:
delend();
menu();
break;
case 10:
rev();
menu();
break;
case 11:
printf("\nenter the position:- ");
scanf("%d",&pos);
delpos(pos);
menu();
break;
case 12:
printf("\nenter the element you want to search:- ");
scanf("%d",&num);
search(num);
menu();
break;
case 13:
printf("\nenter the position for searching the element:- ");
scanf("%d",&pos);
searchpos(pos,n);
menu();
break;
default:
printf("\nYou enter wrong choice");
menu();
}
}

void main()
{
clrscr();
start=NULL;
menu();
getch();
}
linked list operation and implemantation

Stack implementation using linked list | How to do code

Stack implementation using linked list | How to do code
/*How to write  Program for stack implementation using linked list */

#include<stdio.h>
#include<conio.h>
#include<malloc.h>

struct node
{
int info;
struct node *link;
}*top=NULL;

void push()
{
int n;
struct node *temp;
temp=malloc(sizeof(struct node));
printf("\nenter the element u want to insert:- ");
scanf("%d",&n);
temp->info=n;
temp->link=top;
top=temp;
}

void pop()
{
struct node *temp;
temp=top;
if(top==NULL)
printf("\nstack is empty");
else
{
printf("\n%d is deleted from stack\n",top->info);
top=top->link;
free(temp);
}
}

void display()
{
struct node *temp;
temp=top;
if(top==NULL)
printf("\nstackis empty");
else
{
while(temp!=NULL)
{
printf("%d\t",temp->info);
temp=temp->link;
}
}
}

void main()
{
int ch;
clrscr();
while(1)
{
printf("\n1:for insertion");
printf("\n2:for deletion");
printf("\n3:for display");
printf("\n4:for exit");
printf("\nenter your choice:- ");
scanf("%d",&ch);
switch(ch)
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
display();
break;
case 4:
exit(0);
default:
printf("\nyou entered wrong choice");
}
}
}
stack implementation using linked list

Simple Program for insertion in AVL tree

Simple Program for insertion in AVL tree
/*Program for insertion in AVL tree*/
#include<stdio.h>
#include<malloc.h>

typedef enum { FALSE ,TRUE } bool;
struct node
{
int info;
int balance;
struct  node *lchild;
struct  node *rchild;
};

struct node *insert (int , struct node *, int *);
struct node* search(struct node *,int);

main()
{
bool ht_inc;
int info ;
int choice;
struct node *root = (struct node *)malloc(sizeof(struct node));
root =  NULL;

while(1)
{
printf("1.Insert\n");
printf("2.Display\n");
printf("3.Quit\n");
printf("Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter the value to be inserted : ");
scanf("%d", &info);
if( search(root,info) == NULL )
root = insert(info, root, &ht_inc);
else
printf("Duplicate value ignored\n");
break;
case 2:
if(root==NULL)
{
printf("Tree is empty\n");
continue;
}
printf("Tree is :\n");
display(root, 1);
printf("\n\n");
printf("Inorder Traversal is: ");
inorder(root);
printf("\n");
break;
case 3:
exit(1);
default:
printf("Wrong choice\n");
}/*End of switch*/
}/*End of while*/
}/*End of main()*/

struct node* search(struct node *ptr,int info)
{
if(ptr!=NULL)
if(info < ptr->info)
ptr=search(ptr->lchild,info);
else if( info > ptr->info)
ptr=search(ptr->rchild,info);
return(ptr);
}/*End of search()*/

struct node *insert (int info, struct node *pptr, int *ht_inc)
{
struct node *aptr;
struct node *bptr;

if(pptr==NULL)
{
pptr = (struct node *) malloc(sizeof(struct node));
pptr->info = info;
pptr->lchild = NULL;
pptr->rchild = NULL;
pptr->balance = 0;
*ht_inc = TRUE;
return (pptr);
}


if(info < pptr->info)
{
pptr->lchild = insert(info, pptr->lchild, ht_inc);
if(*ht_inc==TRUE)
{
switch(pptr->balance)
{
case -1: /* Right heavy */
pptr->balance = 0;
*ht_inc = FALSE;
break;
case 0: /* Balanced */
pptr->balance = 1;
break;
case 1: /* Left heavy */
aptr = pptr->lchild;
if(aptr->balance == 1)
{
printf("Left to Left Rotation\n");
pptr->lchild= aptr->rchild;
aptr->rchild = pptr;
pptr->balance = 0;
aptr->balance=0;
pptr = aptr;
}
else
{
printf("Left to right rotation\n");
bptr = aptr->rchild;
aptr->rchild = bptr->lchild;
bptr->lchild = aptr;
pptr->lchild = bptr->rchild;
bptr->rchild = pptr;

if(bptr->balance == 1 )
pptr->balance = -1;
else
pptr->balance = 0;
if(bptr->balance == -1)
aptr->balance = 1;
else
aptr->balance = 0;
bptr->balance=0;
pptr=bptr;
}
*ht_inc = FALSE;
}/*End of switch */
}/*End of if */
}/*End of if*/

Djikstra algorithm using Graph | how to find out shortest path between 2 node

Djikstra algorithm using Graph | how to find out shortest path between 2 node
* Program of shortest path between two node in graph using Djikstra algorithm */
#include<stdio.h>

#define MAX 10
#define TEMP 0
#define PERM 1
#define infinity 9999

struct node
{
int predecessor;
int dist; /*minimum distance of node from source*/
int status;
};

int adj[MAX][MAX];
int n;
void main()
{
int i,j;
int source,dest;
int path[MAX];
int shortdist,count;

create_graph();
printf("The adjacency matrix is :\n");
display();

while(1)
{
printf("Enter source node(0 to quit) : ");
scanf("%d",&source);
printf("Enter destination node(0 to quit) : ");
scanf("%d",&dest);

if(source==0 || dest==0)
exit(1);

count = findpath(source,dest,path,&shortdist);
if(shortdist!=0)
{
printf("Shortest distance is : %d\n", shortdist);
printf("Shortest Path is : ");
for(i=count;i>1;i--)
printf("%d->",path[i]);
printf("%d",path[i]);
printf("\n");
}
else
printf("There is no path from source to destination node\n");
}/*End of while*/
}/*End of main()*/


create_graph()
{
int i,max_edges,origin,destin,wt;

printf("Enter number of vertices : ");
scanf("%d",&n);
max_edges=n*(n-1);

for(i=1;i<=max_edges;i++)
{
printf("Enter edge %d(0 0 to quit) : ",i);
scanf("%d %d",&origin,&destin);
if((origin==0) && (destin==0))
break;
printf("Enter weight for this edge : ");
scanf("%d",&wt);
if( origin > n || destin > n || origin<=0 || destin<=0)
{
printf("Invalid edge!\n");
i--;
}
else
adj[origin][destin]=wt;
}/*End of for*/
}/*End of create_graph()*/

display()
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
printf("%3d",adj[i][j]);
printf("\n");
}

}/*End of display()*/

int findpath(int s,int d,int path[MAX],int *sdist)
{
struct node state[MAX];
int i,min,count=0,current,newdist,u,v;
*sdist=0;
/* Make all nodes temporary */
for(i=1;i<=n;i++)
{
state[i].predecessor=0;
state[i].dist = infinity;
state[i].status = TEMP;
}

/*Source node should be permanent*/
state[s].predecessor=0;
state[s].dist = 0;
state[s].status = PERM;

/*Starting from source node until destination is found*/
current=s;
while(current!=d)
{
for(i=1;i<=n;i++)
{
/*Checks for adjacent temporary nodes */
if ( adj[current][i] > 0 && state[i].status == TEMP )
{
newdist=state[current].dist + adj[current][i];
/*Checks for Relabeling*/
if( newdist < state[i].dist )
{
state[i].predecessor = current;
state[i].dist = newdist;
}
}
}/*End of for*/

/*Search for temporary node with minimum distand make it current node*/
min=infinity;
current=0;
for(i=1;i<=n;i++)
{
if(state[i].status == TEMP && state[i].dist < min)
{
min = state[i].dist;
current=i;
}
}/*End of for*/

if(current==0) /*If Source or Sink node is isolated*/
return 0;
state[current].status=PERM;
}/*End of while*/

/* Getting full path in array from destination to source    */
while( current!=0 )
{
count++;
path[count]=current;
current=state[current].predecessor;
}

/*Getting distance from source to destination*/
for(i=count;i>1;i--)
{
u=path[i];
v=path[i-1];
*sdist+= adj[u][v];
}
return (count);
}/*End of findpath()*/

Djikstra algorithm using graph

Logic for Struct code | examples struct queue

Logic for Struct code | examples struct queue
download struct queue code tricks
#include<conio.h>
#define max 10

struct queue
{
int item[max];
int rear,front;
};



void insert(struct queue *q,int c)
{

if(q->front==-1)
q->front=0;
if(q->rear==max-1)
printf("Given queue is overflow");
else
q->item[++(q->rear)]=c;
}

int del(struct queue *q)
{
if(q->front==-1||q->front>q->rear)
printf("Queue underflow");
else
return(q->item[(q->front)++]);
}

void show(struct queue *q)
{
int i;
for(i=q->front;i<=q->rear;i++)
{
printf("   %d\n",q->item[i]);
}
}

void main()
{
struct queue q;
int i,ch;
int e;
q.front=q.rear=-1;

while(1)
{
clrscr();
printf("     *************************** Option *******************************\n");
printf("                       0:Exit.\n");
printf("                       1:Insert element into queue.\n");
printf("                       2:Delete element from queue.\n");
printf("                       3:Show all element of queue.\n");
printf("     ******************************************************************\n");

printf("Please enter your choice=");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("Enter element to insert=");
scanf("%d",&e);
insert(&q,e);


break;
case 2:
printf("Deleted element=%d",del(&q));
break;
case 3:
printf("Element of queue\n");
show(&q);
break;
default:
exit(0);
}
printf("\n Press enter to next opration");
getch();
}

}

Monday 20 August 2012

Radix Sort | Counting Sort. | Theta Notation | Pseudocode Questions

Radix Sort | Counting Sort. | Theta Notation | Pseudocode Questions
  • Questions related to sort , algorithms , Pseudocode
    1Algorithm  | characteristics of the algorithms
    Pseudocode  | Pseudocode with example?
    3. Asymptotic notations used in algorithms
    Big Oh notation..
    Omega notation.
    Theta Notation .
    short notes:
    Space Complexity
    Time Complexity
    Best Case Complexity
    Max Heap.Explain how time complexity of an algorithm is computed?
    Frequency count | algorithm.
    What is  Disjoint Set.
    Operations | performed | disjoint set?
    what is Weighting Rule. state it with examples
    .what is  the Collapsing Rule.
    Heap-sort algorithm | complexity.
    Counting sort algorithm  |
    calculate   its complexity.
    .Sort |  elements |using Heap-sort..
    .Sort  | elements  | using Counting Sort.
    Sort the given given elements using radix Sort.

Algorithm Questions | prim’s | Krushkal | Dijkstra’s

Algorithm Questions | prim’s | Krushkal | Dijkstra’s
Data analysis and design important interview questions
  • control abstraction | divide and conquer strategy .
  • algorithm to search an element in a list using binary search technique
  • algorithm | Mergsort | complexity.
  • algorithm | Quicksort | complexity.
  • Show that merge takes a time in O(n log n) to sort n elements.
  • Use merge sort to the given array.
  • explain the control abstraction of the greedy method.
  • what Is greedy method .write an algorithm to solve knapsack problem using greedy method.
  • what is optimal merge pattern .write an algorithm to generate a two way merge pattern .
  • write the greedy algorithm for sequencing unit time jobs with deadline and profits.
  • find the minimum cost spanning tree using
  • prim’s algorithm
  • Krushkal’s algorithm
  • Dijkstra’s algorithm  example.

dynamic programming | Knapsack problem | multistage graph principle of optimality interview question papers

dynamic programming | Knapsack problem | multistage graph principle of optimality interview question papers
dynamic programming  | Knapsack problem  | multistage graph  principle of optimality interview question papers
1.what is actual  dynamic programming ?
2. principle of optimality .
3.how to write  the multistage graph problem.
4.find the minimum cost path from “S” TO “T” in the multistage graph given below.
4.consider the following instance of 0/1 knapsack problem
N=3,M=6,P=(1,2,3), W=(2,3,4)
USING THE DYNAMIC programming determine the optimal profit & the solution vector.
5.how to write purging and merging rule in 0/1 Knapsack problem
6.explain how we can solve the  TSP problem by  using dynamic programming .

7.what is scheduling rule?
8.how can we used scheduling rule in Flow shop Scheduli

Greedy Method | Krushkal’s | Dijkstra’s algorithm | knapsack instance

Greedy Method | Krushkal’s | Dijkstra’s algorithm | knapsack instance
interview questions for Greedy Method  | Krushkal’s | Dijkstra’s algorithm  | knapsack instance
1. control abstraction of the greedy method.
2.  greedy method  | algorithm | solve knapsack problem
3. optimal solution | knapsack instance
4 optimal merge pattern | algorithm | generate | two way merge pattern .
5.optimal binary merge pattern for given example
6. greedy algorithm | sequencing unit time jobs with deadline and profits.
8.Minimal spanning tree
the PRIM’S algorithm
9.find the minimum cost spanning tree using
1O.prim’s algorithm 2.Krushkal’s algorithm
11.explain Dijkstra’s algorithm

Backtracking ,N-queens problem, Hamiltonian cycles, m-coloring of graph, interview

Backtracking ,N-queens problem, Hamiltonian cycles, m-coloring of graph, interview
1.what is backtracking ?explain the implicit and explicit constraints.

2.define the following

1.state space tree

2. Problem state

3.solution state

4.answer state

5. live node

6.E.node

7.DEAD NODE

8.chromatic number of graph


3.describe 4-queens problem .draw and explain the portion of the tree for 4-queen problem that is generated.

4.explain the control abstraction of backtracking using recursive formulation.


5 explain the control abstraction of backtracking using Iterative formulation .

6.what is N-queens problem .write algorithm for N-queens problem.

7.explain graph coloring problem with an example. draw the portion of state space for a 4 node graph with 3-colorings.

8.write the algorithm to find all m-colorings of a graph.

9.write an algorithm for all m-coloring of graph.

9.what is Hamiltonian Cycle ?

Give an examples.

10.write an algorithm to find all the Hamiltonian cycles of a graph.

C Programming | tips and tricks to improove logic

C Programming | tips and tricks to improove logic
C Programming | Chapters  | Topics

chapter 1)->An Overview of C....

    1 History  | C
    2 C  | middle-level Language
    3 C  | Structured Language
    4 Compiler Vs Interpreters difference
    5  Form | C Program.
    6 Library & Linking.
    7 Compilation | Execution  | C  Program


chapter 2)-> Variables, Data Types, Operator & Expression

    1 Character Set
    2 C Token
    3 Identifier & Keyword
    4 Constant
    Integer, Floating Point, Character, String,
    Enumeration
    5 Data Types in C
    6 Data Declaration & Definition
    7 Operator & Expression



chapter 3)-> Console I/O

    1 Introduction
    2 Character input & Output
    3 String Input & Output.
    4 Formatted Input/Output (scanf/printf)
    5 sprintf & sscanf
    4 Control Statement


chapter 4)-> Selection Statements

    If | Nested if | if-else-if |
    The Conditional Expression
    Nested switch  |Iteration Statements
    for  | while  | do-while loop

chapter 5)->Jump Statements

    Goto & label
    break
    continue
    exit() function

chapter 6)-> Pointers

    Memory Organization
    The basics of Pointer
    The Pointer operator
    Application of Pointer
    Pointer Expression
    Declaration of Pointer, Initializing Pointer,
    De-referencing Pointer
    Void Pointer
    Pointer Arithmetic
    Precedence of &, * operators
    Pointer to Pointer
    Constant Pointer

chapter 7)-> Array & String

    Single Dimension Arrays
    Accessing array elements, Initializing an array
    Multidimensional Arrays
    Initializing the arrays, Memory Representation
    Accessing array elements
    Passing Single Dimension array to Function
    Array & Pointer
    Array of Pointer
    String Manipulation Functions

chapter 8)->Function

    Arguments & local variables
    Returning Function Results by reference &
    Call by value
    Recursion


chapter 9)->Storage Class & Scope

    Meaning of Terms
    Scope - Block scope & file scope
    Storage Classes
    Automatic Storage, Extern Storage, Static
    Structure, Union, Enumeration & typedef


chapter 10)-> Structures

    Declaration  | Initializing Structure,
    Accessing Structure members
    Assignments | Arrays of Structure
    Structure to function  | Pointer



chapter 11)->File handling

    Opening a File
    Closing a File
    Input/Output Operations on Files
    Error Handling During I/O Operation
    Random Access To Files

chapter 12)-> Bitwise Operator

    Applications
    Masking, Internal Representation of Date
    Bit Fields

chapter 13)->Graphics In C

    Drawing Object in C
    Line, Circle, Rectangle, Ellipse
    Changing Foreground & Background
    Filling Object by Color

Command Line Arguments