-->

Wednesday, March 12, 2014

QUEUE for Data Structure in C Programming

Queue is also a special type of linear data structure resulting after restriction of insertion and deletion operations on linear data structure. So, it can be implemented using either one-dimensional array or linked list. When the insertion operation is restricted to the other end in a linear data structure, then the resulting data structure is called as QUEUE. Insertion or addition of items is done at the end called REAR end and deletion of items is done from the other end called as FRONT end.
                         Assume a service center, with one serving window. The person comes for the service first is served first. If another person comes for the service, while the first person is being served, he has to wait. He will stand behind the first person. If any other persons come for the service, they will also stand one by one behind each other. The waiting persons frame a QUEUE. The persons are added into the QUEUE from end called REAR end. One person who enters the QUEUE  first is served first. The deletion is done from the other end FRONT end. As an item is added to QUEUE at the REAR end and it is deletion from the other end, FRONT end, the item added first comes out first. So the data structure QUEUE is also called as FIFO, First In First Out structure. QUEUE has many applications in computer Field.
                   In a multiprocessing environment, the processes waiting for the CPU service are placed in a QUEUE called Ready Queue. In multiprocessing environment the CPU executes more than one process.

Representation of Queue: 
          The representation of QUEUE  depends on the type of QUEUE. The QUEUE can be implemented either using a one-dimensional array or using Linked List. As there are different type of QUEUE depending on storage and the way the ADD and DELETE operations are done on the QUEUE.

Type of QUEUE:


1 Linear QUEUE: The elements are arranged in a QUEUE in linear order.

2 Circular QUEUE: The elements are arranged in a QUEUE by means of circular array.
3 DEQUE-Double Ended QUEUE: The ADD and DELETE operations are done from both the ends.
4 Priority QUEUE: The elements are stored in QUEUE with a characteristic called priority and DELETE  operation depends on priority, high priority elements are deleted first (served first).

Tuesday, March 11, 2014

Recursion for Data Structure in C programming

Recursion:


          Recursion is another good example of programming field where STACK is used. Recursion is an art of programming or a technique in programming in which the subprogram calls itself. In programming usually when a subprogram is written it is called in main program. Using a statement in the main program can do a call to the subprogram. If a call statement of the subprogram is used within the definition of the same subprogram then it is termed as recursion.
                                        Whenever a function (in case of C the subprogram is function) call is made in main program the control transfers to the function, the function is executed and control transfers back to the calling point. Note here that the internal STACK is used to store the address of the next instruction that is to be execution completes.

                                   main()
                                  {
                                     -----;
                                     fun();
                                     -----;<------------address of this instruction is stored in STACK
                                  }
                                   fun()
                                   {
                                      ----:
                                    }
                   The recursion can be used to solve certain problems where the problems have base condition. When the base condition is satisfied the call should terminate otherwise a call is made again with changed value. Means recursion is used only in those cases when the same set of statements are to be executed again and again with changed value and that changed value reaches to base condition the recursive call should terminate.

Monday, March 10, 2014

Evaluation of POSTFIX expression using STACK

Evaluation of POSTFIX expression using STACK :

To evaluation the value of a POSTFIX expression STACK can be used in the following way:
Procedure: Add #, a pound symbol, a sentinel, a terminating symbol at the end of the POSTFIX expression. Scan the expression from left to right till #.If the character scanned character is an operand PUSH it on to STACK. If the scanned character is any operator, * , POP STACK once call it B and POP again and call it A, find A  *   B, and PUSH the result on to STACK. If the character scanned is #, then POP the STACK and it is the value of the POSTFIX expression.. For example consider a POSTFIX expression, 6 3 2| *3 6 +/.

The value of POSTFIX expression is 6.
Algorithm to evaluate the value of POSTFIX expression:
POSTFIXVAL (P)
[P is a POSTFIX expression]
Add # at the end of P
Repeat Scanning P from left to right While scanned character
< >  #
  If Scanned Character = operand Then:
    [PUSH it on to STACK]
   STACK [TOP]<--OPERAND, TOP<--TOP+1
 Else:
  B<--STACK[TOP], TOP<--TOP-1
  A<--STACK[TOP],TOP<--TOP-1
  RES <-- A operator B
  STACK [TOP]<--RES
[End of While]
VAL<--STACK[TOP]
Write : ‘Value of POSTFIX expression is ‘, VAL
Exit.


Sunday, March 9, 2014

How to use Unique Key Constraint on Column in SQL

Unique constraint is something like primary key constraint, which is used to make a record unique within all other records in sql database.

The unique constraint is used to enforce uniqueness on non-primary key columns. A primary key constrain column automatically includes a restriction for uniqueness. The unique constraint is similar to the primary key constraint except that it allows one NULL row.

Multiple unique constrains can be created on a table. The syntax of applying the unique constraint when creating table is:

CREATE TABLE table_Name
(
Col_name [CNTRAIN cstraint_name UNIQUE [CLUSTERED | NONCLUSTERED]
 Col_name [, col_name [, col_name [, …]]])
Col_name [, col_name [, col_name [, …]]]
)
Where
  • Constraint_name species the name of the constraint to created.
  • CLUSTERED | NONCLUSTERED are keywords that specify if a clustered or a nonclustered index is to be created for the unique constraint.
  • Col_name specifies the name of the column(s) on which the unique constraint is to be defined.
This constraint is also applied on columns as same as primary key constraint.

Primary Key Constraint
Foreign Key constraint

Friday, March 7, 2014

Main Features of Silverlight

As started earlier, silverlight was previously known as WPF/E because it is a subset of WPF, inheriting many functionalities of WPF. For example, Silverlight supports XAML, 2-D vector graphics, animations, and multimedia. However, certain features, such as 3-D graphics and hardware rendering of WPF, are not available to Silverlight. You may wonder about the difference between XAML browser Applications (XBAPs) in WPF and Silverlight. One of the notable differences between the two is that XBAPs can run only in Internet Explorer and firefox, whereas Silverlight applications can run in multiple Web browsers. Secondly, XBAPs require .NET Framework to be available on the users’ computers, while Silverlight provides the necessary components on itsown and does not need .NET Framework. Thirdly, an XBAP has access to the computer WPF functionality, while a Silverlight application has only limited WPF functionality.

The first version of silverlight unveiled by Microsoft was Silverlight 1.0. this version was released in 2007 and was based on the JavaSript application model. You could incorporate the functionality of Silverlight 1.0 in .NET Framework 2.0 and Visual Studio 2005 applications. Now, let’s go through these main features of Silverlight.

Improved Programming Model

Silverlight technology supports the .NET Framework programming model to develop Silverlight applications easily. Silverlight leverages many functionality and features of .NET Framework, such as type safety and exception handling. It also includes many classes from the base class liberary, and offers you the provision of working with IO, collections and generics, and threading. You can use any of the .NET languages, such as VB and C# to develop Silverlight applications. You can also use other dynamic language such as IronPython and IronRuby. Furthermore, you integrate Silverlight functionalities with the existing ASP.NET Web applications. You can combine ASP.NET AJAX and Silverlight to get the best of both the technologies. Silverlight also supports language Integrated Query (LINQ) to objects, which facilitates you to work with various types of data in the Web applications.

Note that Silverlight seamlessly integrates with the HTML, JavaScript Document Object Model (DOM) as with XAML parser providing you with the facility to work with HTML, JavaScript, and XAML simultaneously. In this way, Silverlight extends a cohesive platform for developing interactive and superior quality  Web applications.

Comprehensive UI Framework

Silverlight has a comprehensive UI framework to allow you to design the UI of Web applications by using the predefined controls, styles, themes, and templates. Silverlight offers a wide range of controls and layout features to build exceptionally attractive Web applications. Most of the controls and layout features are the same as those available in WPF. For example, the Grid, StackPanel, Calendar, Button, TextBox, and RadioButton controls of WPF are also available in Silverlight. You can also use styles and control templates in the Silverlight applications. Moreover , there are additional controls, such as MultiScaleImage that are specific to Silverlight. You can also use the data binding and data manipulation controls, such as DataGrid. These new controls were designed from scratch to give an extra edge to the Web applications.
These predefined Silverlight controls and layout features help you to quickly and easily develop some high-end Web applications. You can set the properties of these controls to get the desired effect. Note that these properties can also be set using XAML. XAML is the facilitator for separating the design and the code of Web applications.

Support for Deep Zoom Technology

Silverlight  includes a new feature called Deep Zoom, which allows you to zoom high-resolution images in the applications. You can use the Deep Zoom technology to deliver unbelievably creative and uniquely interactive Web applications. With the Deep Zoom technology, you can easily, quickly, and smoothly zoom in or out multiple photographs simultaneously. You can see a highly detailed and fine view of the photographs by using the MultiScaleImage control available in Silverlight 

Support for 2-D Graphics, Animations, and Multimedia

Silverlight has built-in support for using 2-D vector graphics and animations in Web applications. You can create 2-Dshpes, such as rectangles and ellipses, geometries, and brushes. You can also transform and animate the shapes and geometries. In addition, you can make your Web applications dynamic by using storyboards controlling the animation timeline and speed, and much more.
There is an extensive support in Silverlight for captivating multimedia experience on the Web. You can include .jpeg or images in the applications to give them an attractive UI. In addition, Silverlight supports various multimedia formats, such as .wma, .wmv, and .mp3 and has some of the essential codecs for playing back multimedia content. You can also use High-Definition (HD) quality video (up to 720p) in Silverlight applications. Silverlight also offers protection through authentication  and authorization of users and Digital Rights Management (DRM) for the multimedia content that you add to your Web applications.

Support for Networking

Silverlight  contains classes to support networking and predefined sockets. It allows you to use various HTTP, XML, RSS and REST services. Furthermore, you can use an XML format to use the data and resources on other web sites. Silverlight extends the cross-domain support for networking. You can also use Silverlight  for communication with sockets over standard network protocols, such as IPv4 and IPv6.

How to develop rich-interactive applications with silverlight

In the initial years of the Internet and Web development, websites were developed using only Hypertext Markup Language (HTML). The content built using only HTML for the Web pages is mostly static. Gradually, with the advent of other new technologies and languages, such as cascading Style Sheets (CSS), XHTML, and Javascript, it is now possible to add user interactivity and a little bit of dynamism to webpages. With the passing years, some other technologies, such as Adobe flash and JavaFx, gave a new dimension of interactivity to Web pages as these technologies gave a huge boost to various fields of business, such as e-learning and online advertising. However, some of these technologies are expensive to deploy, varied in performance, and also have inadequate compatibility with different programming technologies.

How to develop rich-interactive applications with silverlight


To overcome the limitations of earlier technologies, such as Adobe Flash and the ever increasing demand of Rich Internet Applications (RIA), Microsoft brought out Silverlight. Formerly known as Windows presentation Foundation/Everywhere (WPF/E), Silverlight is an inexpensive small plug-in that can work in a cross-platform, cross-browser, and cross-device environment. Silverlight is supported by both Microsoft Windows and Apple Macintosh family of operating systems as well as popular Web browsers, such as Microsoft Internet Explorer, Mozilla Firefox, and Apple Safari.

Silverlight is a Web-based technology that allows Web designers and developers to stretch the boundaries of Web application development. It is an integration of the rich user interface (UI) of desktop applications and the transparency of other Web languages, such as HTML and JavaScript . Silverlight allows you to develop Web applications that contain high-fidelity multimedia content and eye-catching visual effects. Web applications.

Thursday, March 6, 2014

How to use Primary Key Constraint on Column in SQL

In SQL, Primary Key constraint is defined on a column or a set of columns whose values uniquely identify all the rows in a table. These columns are referred to as the primary key columns. A primary key column cannot contain NULL values since it is used to uniquely identify rows in a table. The primary key constraint ensures entity integrity.

You can define a primary key constraint while creating the table or you can add it later by altering the table. However, if you define the primary key constraint after inserting rows, the SQL Server will give an error if the rows contain duplicate values in the column. While defining a primary key constraint, you need to specify a name for the constraint. If a name is not specified, the SQL Server automatically assigns a name to the constraint.

If a primary key constraint is defined on a column that already contains data, then the existing data in the column is screened. If any duplicate values are found, then the primary key constraint is rejected. The syntax of applying the primary key constraint when creating table is:

CREATE TABLE table_name
(
Col_name [CONSTRAINT constraint_name PRIMARY KEY
 [CLUSTERED|NONCLUSTERED]
Col_name [, col_name [, col_name [, … ] ] ]
)

Where,

  • Constraint_name specifies the name of the constraint to be created.
  • CLUSTERED|NONCLUSTERED are keywords that specify if a clustered or a nonclustered index is to be created for the primary key constraint.
  • Col_name specifies the name of the column(s) on which the primary key constraint is to be defined.

In the preceding example of the EmployeeLeave table, you can add a primary key constraint, while creating the table. You can set the EmployeeID and the LeaveStartDate columns of the EmployeeLeave table as a composite primary key. You can use the following statement to apply the primary key constraint:

CREATE TABLE HumanResources.EmployeeLeave
(
EmployeeID int,
LeaveStartDate datetime CONSTRAINT cpkLeaveStartDate PRIMARY KEY (EmployeeID, LeaveStartDate),



)

The preceding statement creates the EmployeeLeave table with a composite primary key constraint on EmployeeID and LeaveStartDate. The name of the constraint is cpkLeaveStartDate.
© Copyright 2013 Computer Programming | All Right Reserved