Thursday, March 31, 2011

Solved Assignment CS-612 III Sem (2011)


There are four questions in this assignment. Answer all the questions. You may use illustrations and diagrams to enhance explanations.

Question 1: (a) What is a worksheet? How to create and format controls on worksheet. (4 Marks)

A worksheet is a sheet of paper, or on a computer, on which problems are worked out or solved and answers recorded.
A worksheet is an object in a spreadsheet program that consists primarily of a grid of cells, organized in rows and column, in which spreadsheet calculations and information are held. A file saved by a spreadsheet program may consist of many worksheets.
Some spreadsheet application
Microsoft Excel
Microsoft Excel is a commercial spreadsheet application written and distributed byMicrosoft for Microsoft Windows and Mac OS X. It features calculation, graphing tools, pivot tables and a macro programming language called Visual Basic for Applications. It has been a very widely applied spreadsheet for these platforms, especially since version 5 in 1993. Excel forms part of Microsoft Office. The current versions are 2010 for Windows and 2011 forMac.
Lotus 123
Lotus 1-2-3 is a spreadsheet program from Lotus Software (now part of IBM). It was the IBM PC's first "killer application"; its huge popularity in the mid-1980s contributed significantly to the success of the IBM PC in the corporate environment.
Open Office Calc
A spreadsheet similar to Microsoft Excel and Lotus 1-2-3. Calc can export spreadsheets to the PDF format. (See ooWriter entry, above, for details of PDF). Calc provides a number of features not present in Excel, including a system which automatically defines series for graphing, based on the layout of the user’s data.

(b) What is need of a web browser? List the advantages and disadvantages of different browsers. (3 Marks)
A web browser or Internet browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web. An information resource is identified by aUniform Resource Identifier (URI) and may be a web page, image, video, or other piece of content. Hyperlinks present in resources enable users to easily navigate their browsers to related resources.
Although browsers are primarily intended to access the World Wide Web, they can also be used to access information provided by Web servers in private networks or files in file systems. Some browsers can also be used to save information resources to file systems.
Mozilla released Firefox 3.0 on 17 June 2008, with performance improvements, and other new features. Firefox 3.5 followed on 30 June 2009 with further performance improvements, native integration of audio and video, and more privacy features.
Google released the Chrome browser for Microsoft Windows on December 11, 2008, using the same WebKit rendering engine as Safari and a faster JavaScript engine called V8. An open sourced version for the Windows, Mac OS X and Linux platforms was released under the name Chromium. According to Net Applications, Chrome had gained a 3.6% usage share by October 2009. After the release of the beta for Mac OS X and Linux, the market share had increased rapidly.
On March 19, 2009, Microsoft released Internet Explorer 8, which added accelerators, improved privacy protection, a compatibility mode for pages designed for Internet Explorer 7 and improved support for various web standards.

During December 2009 and January 2010, StatCounter reported that its statistics indicated that Firefox 3.5 was the most popular browser, when counting individual browser versions, passing Internet Explorer 7 and 8 by a small margin. This is the first time a global statistic has reported that a non-Internet Explorer browser version has exceeded the top Internet Explorer version in usage share since the fall of Netscape Navigator. This feat, which GeekSmack called the "dethron[ing of] Microsoft and its Internet Explorer 7 browser," can largely be attributed to the fact that it came at a time when IE 8 was replacing IE 7 as the dominant Internet Explorer version. No more than two months later IE 8 had established itself as the most popular browser version, a position which it still holds as of March 2011. It should also be noted that other major statistics, such as Net Applications, never report any non-IE browser version as having a higher usage share than the most popular Internet Explorer version, although Firefox 3.5 was reported as the third most popular browser version between December 2009 and February 2010, to be replaced by Firefox 3.6 since April 2010, each ahead of IE7 and behind IE6 and IE8.
On January 21, 2010, Mozilla released Mozilla Firefox 3.6, which allows support for a new type of theme display, 'Personas', which allows users to change Firefox's appearance with a single click. Version 3.6 also improves JavaScript performance, overall browser responsiveness and startup times.
In October 2010, StatCounter reported that Internet Explorer had for the first time dropped below 50% market share to 49.87% in their figures. Also, StatCounter reported Internet Explorer 8's first drop in usage share in the same month.
On February 3, 2011, Google released Chrome 9. New features introduced include: support for WebGL, Chrome Instant, and the Chrome Web Store.
StatCounter global market share figures were as follows for February 2011. Internet Explorer 45%, Firefox 30%, Chrome 17%, Safari 5% and Opera 2%, leaving all the others sharing the remaining 1%.




HLOOKUP()
Searches for a value in the top row of a table or an array of values, and then returns a value in the same column from a row you specify in the table or array. Use HLOOKUP when your comparison values are located in a row across the top of a table of data, and you want to look down a specified number of rows. Use VLOOKUP when your comparison values are located in a column to the left of the data you want to find.
SYNTAX

HLOOKUP(lookup_value,table_array,row_index_num,range_lookup)
Where
Lookup_value :- The value to search in the first column of the table array.
Table_Array :- Two or more columns of data.
row_index :- The row number in table_array from which the matching value must be returned.
Range_lookup :- A logical value that specifies whether you want VLOOKUP to find an exact
match or an approximate match:
If TRUE or omitted, an exact or approximate match is returned. If an exact match is not found, the next largest value that is less than lookup_value is returned.

(b) What is FTP? Explain how it is different from telnet. (3 Marks)
File Transfer Protocol (FTP) is a standard network protocol used to copy a file from one host to another over a TCP-based network, such as the Internet. FTP is built on a client-server architecture and utilizes separate control and data connections between the client and server. FTP users may authenticate themselves using a clear-text sign-in protocol but can connect anonymously if the server is configured to allow it.
The first FTP client applications were interactive command-line tools, implementing standard commands and syntax. Graphical user interface clients have since been developed for many of the popular desktop operating systems in use today.
Both of these applications allow two different computers to communicate with each other. Telnet allows the user to log on to an account on a remote computer and work as if you were there. This is useful if you are traveling or are going to be away from your own computer and your local account but need to have access to the latter. You might be at a conference in another state and suddenly remember that you need some information that is stored on a file in your account back at your home institution. You can log on remotely, telnet to your account, get into your files that are on that server, and retrieve the information. For example, let's say you are at ACTFL and you are supposed to meet some people but you forgot the time and the place. They sent you this information in an e-mail message, and you have that message in your account on the server at your institution. If you can use a computer with Internet access where you are, you can telnet to your account, call up the message, and read the information off the screen. Voilá--you won't miss your dinner date.



Questioon 3: (a) Whhat is Koniggsberg Bridgge problem?? Explain wiith a suitablle diagram.    (3 Marks)









Solved Assignment CS-612 III Sem (2011)


There are four questions in this assignment. Answer all the questions. You may use illustrations and diagrams to enhance explanations.

Question 1: (a) What is a worksheet? How to create and format controls on worksheet. (4 Marks)

A worksheet is a sheet of paper, or on a computer, on which problems are worked out or solved and answers recorded.
A worksheet is an object in a spreadsheet program that consists primarily of a grid of cells, organized in rows and column, in which spreadsheet calculations and information are held. A file saved by a spreadsheet program may consist of many worksheets.
Some spreadsheet application
Microsoft Excel
Microsoft Excel is a commercial spreadsheet application written and distributed byMicrosoft for Microsoft Windows and Mac OS X. It features calculation, graphing tools, pivot tables and a macro programming language called Visual Basic for Applications. It has been a very widely applied spreadsheet for these platforms, especially since version 5 in 1993. Excel forms part of Microsoft Office. The current versions are 2010 for Windows and 2011 forMac.
Lotus 123
Lotus 1-2-3 is a spreadsheet program from Lotus Software (now part of IBM). It was the IBM PC's first "killer application"; its huge popularity in the mid-1980s contributed significantly to the success of the IBM PC in the corporate environment.
Open Office Calc
A spreadsheet similar to Microsoft Excel and Lotus 1-2-3. Calc can export spreadsheets to the PDF format. (See ooWriter entry, above, for details of PDF). Calc provides a number of features not present in Excel, including a system which automatically defines series for graphing, based on the layout of the user’s data.

(b) What is need of a web browser? List the advantages and disadvantages of different browsers. (3 Marks)
A web browser or Internet browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web. An information resource is identified by aUniform Resource Identifier (URI) and may be a web page, image, video, or other piece of content. Hyperlinks present in resources enable users to easily navigate their browsers to related resources.
Although browsers are primarily intended to access the World Wide Web, they can also be used to access information provided by Web servers in private networks or files in file systems. Some browsers can also be used to save information resources to file systems.
Mozilla released Firefox 3.0 on 17 June 2008, with performance improvements, and other new features. Firefox 3.5 followed on 30 June 2009 with further performance improvements, native integration of audio and video, and more privacy features.
Google released the Chrome browser for Microsoft Windows on December 11, 2008, using the same WebKit rendering engine as Safari and a faster JavaScript engine called V8. An open sourced version for the Windows, Mac OS X and Linux platforms was released under the name Chromium. According to Net Applications, Chrome had gained a 3.6% usage share by October 2009. After the release of the beta for Mac OS X and Linux, the market share had increased rapidly.
On March 19, 2009, Microsoft released Internet Explorer 8, which added accelerators, improved privacy protection, a compatibility mode for pages designed for Internet Explorer 7 and improved support for various web standards.

During December 2009 and January 2010, StatCounter reported that its statistics indicated that Firefox 3.5 was the most popular browser, when counting individual browser versions, passing Internet Explorer 7 and 8 by a small margin. This is the first time a global statistic has reported that a non-Internet Explorer browser version has exceeded the top Internet Explorer version in usage share since the fall of Netscape Navigator. This feat, which GeekSmack called the "dethron[ing of] Microsoft and its Internet Explorer 7 browser," can largely be attributed to the fact that it came at a time when IE 8 was replacing IE 7 as the dominant Internet Explorer version. No more than two months later IE 8 had established itself as the most popular browser version, a position which it still holds as of March 2011. It should also be noted that other major statistics, such as Net Applications, never report any non-IE browser version as having a higher usage share than the most popular Internet Explorer version, although Firefox 3.5 was reported as the third most popular browser version between December 2009 and February 2010, to be replaced by Firefox 3.6 since April 2010, each ahead of IE7 and behind IE6 and IE8.
On January 21, 2010, Mozilla released Mozilla Firefox 3.6, which allows support for a new type of theme display, 'Personas', which allows users to change Firefox's appearance with a single click. Version 3.6 also improves JavaScript performance, overall browser responsiveness and startup times.
In October 2010, StatCounter reported that Internet Explorer had for the first time dropped below 50% market share to 49.87% in their figures. Also, StatCounter reported Internet Explorer 8's first drop in usage share in the same month.
On February 3, 2011, Google released Chrome 9. New features introduced include: support for WebGL, Chrome Instant, and the Chrome Web Store.
StatCounter global market share figures were as follows for February 2011. Internet Explorer 45%, Firefox 30%, Chrome 17%, Safari 5% and Opera 2%, leaving all the others sharing the remaining 1%.




HLOOKUP()
Searches for a value in the top row of a table or an array of values, and then returns a value in the same column from a row you specify in the table or array. Use HLOOKUP when your comparison values are located in a row across the top of a table of data, and you want to look down a specified number of rows. Use VLOOKUP when your comparison values are located in a column to the left of the data you want to find.
SYNTAX

HLOOKUP(lookup_value,table_array,row_index_num,range_lookup)
Where
Lookup_value :- The value to search in the first column of the table array.
Table_Array :- Two or more columns of data.
row_index :- The row number in table_array from which the matching value must be returned.
Range_lookup :- A logical value that specifies whether you want VLOOKUP to find an exact
match or an approximate match:
If TRUE or omitted, an exact or approximate match is returned. If an exact match is not found, the next largest value that is less than lookup_value is returned.

(b) What is FTP? Explain how it is different from telnet. (3 Marks)
File Transfer Protocol (FTP) is a standard network protocol used to copy a file from one host to another over a TCP-based network, such as the Internet. FTP is built on a client-server architecture and utilizes separate control and data connections between the client and server. FTP users may authenticate themselves using a clear-text sign-in protocol but can connect anonymously if the server is configured to allow it.
The first FTP client applications were interactive command-line tools, implementing standard commands and syntax. Graphical user interface clients have since been developed for many of the popular desktop operating systems in use today.
Both of these applications allow two different computers to communicate with each other. Telnet allows the user to log on to an account on a remote computer and work as if you were there. This is useful if you are traveling or are going to be away from your own computer and your local account but need to have access to the latter. You might be at a conference in another state and suddenly remember that you need some information that is stored on a file in your account back at your home institution. You can log on remotely, telnet to your account, get into your files that are on that server, and retrieve the information. For example, let's say you are at ACTFL and you are supposed to meet some people but you forgot the time and the place. They sent you this information in an e-mail message, and you have that message in your account on the server at your institution. If you can use a computer with Internet access where you are, you can telnet to your account, call up the message, and read the information off the screen. Voilá--you won't miss your dinner date.



Questioon 3: (a) Whhat is Koniggsberg Bridgge problem?? Explain wiith a suitablle diagram.    (3 Marks)









Solved Assignment CS-62 IIIrd Sem(2011)


There are three questions in this assignment. Answer all the questions. You may use illustrations and diagrams to enhance your explanations.
Question 1: Write an algorithm for the implementation of a circular doubly linked list           (10 Marks)

Operations
1)insertion
2)forward traversal
3)reverse traversal
4)search
#include<iostream.h>
cll*hd;
struct cll
{
private:
int data;
cll *next;
public:
cll* insert_one(int d,cll* c)
{
cll*NEW;
NEW=new cll;
NEW->data=d;
NEW->next=NULL;
if(c==NULL)
{
c=NEW;
c->next=c;
}
else
{
cll*c1=c;
while(c1->next!=c)
c1=c1->next;
c1->next=NEW;
NEW->next=c;
}
return c;
}
cll* delete_one(int,cll*);
void ftraverse(cll* c)
{
if(c==NULL)
{
cout<<"\nlist empty\n";
return;

}
else
{
cll *c1=c;
cout<<c1->data<<"->";
c1=c1->next;

while(c1!=c)
{
cout<<c1->data<<"->";
c1=c1->next;
}
cout<<"NULL\n";
}
}
void rtraverse(cll* c)
{
if(c->next==hd)
{
cout<<c->data<<"->";
return;
}
else
rtraverse(c->next);
cout<<c->data<<"->";
}
void search(int d,cll* c)
{
cll*c1=c;
if(c==NULL)
{
cout<<"\nlist empty\n";
return;
}
else
{
if(c->data == d)
{
cout<<"found\n";
return ;
}
while(c->next !=c1)
{
if(c->data==d)
{
cout<<"found\n";
return ;
}
c=c->next;
}

if(c->data ==d)
{
cout<<"found\n";
return ;
}
cout<<" search unsuccess ful \n";

}
}
void function()
{
cout<<"******************************************\n";
cout<<"program to implement a circular linked list \n";
cout<<"******************************************\n";
cll * head;
head=NULL;
cout<<"\n\nMENU :\n";
cout<<"1)insertion\n"
<<"2forward traversal\n"
<<"3)reverse traversal\n"
<<"4)search\n"
<<"5)exit\n\n";
cout<<"Enter your option :";
int opt;
cin>>opt;
int d;
while(opt!=5)
{
switch(opt)
{
case 1:
cout<<"Enter data to the node :";
cin>>d;
head=insert_one(d,head);
cout<<"inserted\n";
break;
case 2:
cout<<"The forward traversal is :\n";
ftraverse(head);
break;
case 3:
cout<<"The reverse traversal is :\n";
hd=head;
rtraverse(head);
cout<<"NULL\n";
break;
case 4:

cout<<"Enter the element to be searched :";
int d;
cin>>d;
search(d,head);
break;
case 5:

break;
default:
cout<<"invalid option";
break;
}
cout<<"\n\nMENU :\n";
cout<<"1)insertion\n"
<<"2)forward traversal\n"
<<"3)reverse traversal\n"
<<"4)search\n"
<<"5)exit\n\n";
cout<<"Enter your option :";
cin>>opt;
}
}
};
void main()
{
cll list;
list.function();
}


Question 2: What are the advantages of Arrays and Pointers? What is the basis for selection of Arrays or Pointers as data structure in a program.                                                                (5 Marks)

POINTERS
Pointers are generally useful in the context where we need a continuous memory allocation. Using pointers dynamic allocation of memory is achieved pointers basically hold the address of a variable. they are mainly used as function parameters to pass values of parameters as references rather than values
ARRAYS
You can use one name for similar objects and save then with the same name but different indexes. Arrays are very useful when you are working with sequences of the same kind of data (similar to the first point but has a different meaning). Arrays use reference type and so.
The principal benefit of a linked list (using pointer) over a conventional array is that the list elements can easily be added or removed without reallocation or reorganization of the entire structure because the data items need not be stored contiguously in memory or on disk. Linked lists (pointer) allow insertion and removal of nodes at any point in the list, and can do so with a constant number of operations if the link previous to the link being added or removed is maintained during list traversal.
On the other hand, simple linked lists by themselves do not allow random access to the data other than the first node's data, or any form of efficient indexing. Thus, many basic operations — such as obtaining the last node of the list (assuming that the last node is not maintained as separate node reference in the list structure), or finding a node that contains a given datum, or locating the place where a new node should be inserted — may require scanning most or all of the list elements.

A pointer can refer to an individual item or to an array of items. In fact, an array is just a way of creating both a list of items and a pointer to that list's first item in one declaration. The array and pointer concepts are more or less completely interchangeable in C.
This means that subscripts can be used with pointers, as if they were arrays held at the address of the pointer. As C does no array bound checking, this is completely unsafe. You may assign the address of a simple int variable to a pointer to int and than access locations following it as if they belonged to an array of ints, as follows.
void main()
{
int i, * ip;
ip = & i;
ip[0] = 3;
ip[1] = 2;
ip[2] = 1;
}
On the other hand, an array can be used as if it was a pointer. We have
seen that arrays are always passed by reference, even though no & is written,
and this is why. The only
difference is that the address of an array cannot be changed by assignment. Thus,
the following would not be allowed:
void main()
{
int i, ia[];
ia = &i;
}



Question 3: What is a row major order? What is a column major order? How will you find the location of an element of an array , if the array is stored using row major order? Answer the question, if the array is stored in column major order.                                                       (10 Marks)
Lets now see how the data represented in an array is actually stored in the memory cells of the machine. Because computer memory is linear, a one-dimensional array can be mapped on to the memory cells in a rther straight forward manner. Sotrage for element A[I+1] will be adjacent to storage for element A[I] for I=0,1,2,… N-1. To find the actual address of an element one merely needs to subtract one from the position of the desired entry and then add the result to the address of the first cell in the sequence. Let us see it through an example. Consider an array A of 26 elements. We require to find the addressof A[4]. If the first cell in the sequence A[0] A[1],A[2],….A[25]. Was at address 16, then A[4] would be located at 16+4 = 20, as shown in Firgure. We assume that the size of each elemtn stored is one unit.



Therefore, it is necessary to know the starting address of the space allocated to the array and the size of the each element, which is same for all the elements of an array. We may call the starting address as a base address and denote it by B. then the location of 1th element would be
B + I*S (1)
Where S is the size of each element of array.
Let us now consider storage mapping for multi-dimentional arrays. As we had seen in previous section that in a 2-dimentional array must be simulated we first calculated the amount of storage area needed and allocate a block of contigous memory cells of that size. One way to stoe the data in the cells is row by row. That is, we store first the fist row of the array, then the second row of the aray and then the next and so on. For example the array defined by A, which logically appears as given in Firgure2 appears physically as given in Figure3 such a storage scheme is called Row Major Order.
The other alternative is to store the array column by column. It is called Column Major Order as in Figure 4.














Solved Assignment CS-62 IIIrd Sem(2011)


There are three questions in this assignment. Answer all the questions. You may use illustrations and diagrams to enhance your explanations.
Question 1: Write an algorithm for the implementation of a circular doubly linked list           (10 Marks)

Operations
1)insertion
2)forward traversal
3)reverse traversal
4)search
#include<iostream.h>
cll*hd;
struct cll
{
private:
int data;
cll *next;
public:
cll* insert_one(int d,cll* c)
{
cll*NEW;
NEW=new cll;
NEW->data=d;
NEW->next=NULL;
if(c==NULL)
{
c=NEW;
c->next=c;
}
else
{
cll*c1=c;
while(c1->next!=c)
c1=c1->next;
c1->next=NEW;
NEW->next=c;
}
return c;
}
cll* delete_one(int,cll*);
void ftraverse(cll* c)
{
if(c==NULL)
{
cout<<"\nlist empty\n";
return;

}
else
{
cll *c1=c;
cout<<c1->data<<"->";
c1=c1->next;

while(c1!=c)
{
cout<<c1->data<<"->";
c1=c1->next;
}
cout<<"NULL\n";
}
}
void rtraverse(cll* c)
{
if(c->next==hd)
{
cout<<c->data<<"->";
return;
}
else
rtraverse(c->next);
cout<<c->data<<"->";
}
void search(int d,cll* c)
{
cll*c1=c;
if(c==NULL)
{
cout<<"\nlist empty\n";
return;
}
else
{
if(c->data == d)
{
cout<<"found\n";
return ;
}
while(c->next !=c1)
{
if(c->data==d)
{
cout<<"found\n";
return ;
}
c=c->next;
}

if(c->data ==d)
{
cout<<"found\n";
return ;
}
cout<<" search unsuccess ful \n";

}
}
void function()
{
cout<<"******************************************\n";
cout<<"program to implement a circular linked list \n";
cout<<"******************************************\n";
cll * head;
head=NULL;
cout<<"\n\nMENU :\n";
cout<<"1)insertion\n"
<<"2forward traversal\n"
<<"3)reverse traversal\n"
<<"4)search\n"
<<"5)exit\n\n";
cout<<"Enter your option :";
int opt;
cin>>opt;
int d;
while(opt!=5)
{
switch(opt)
{
case 1:
cout<<"Enter data to the node :";
cin>>d;
head=insert_one(d,head);
cout<<"inserted\n";
break;
case 2:
cout<<"The forward traversal is :\n";
ftraverse(head);
break;
case 3:
cout<<"The reverse traversal is :\n";
hd=head;
rtraverse(head);
cout<<"NULL\n";
break;
case 4:

cout<<"Enter the element to be searched :";
int d;
cin>>d;
search(d,head);
break;
case 5:

break;
default:
cout<<"invalid option";
break;
}
cout<<"\n\nMENU :\n";
cout<<"1)insertion\n"
<<"2)forward traversal\n"
<<"3)reverse traversal\n"
<<"4)search\n"
<<"5)exit\n\n";
cout<<"Enter your option :";
cin>>opt;
}
}
};
void main()
{
cll list;
list.function();
}


Question 2: What are the advantages of Arrays and Pointers? What is the basis for selection of Arrays or Pointers as data structure in a program.                                                                (5 Marks)

POINTERS
Pointers are generally useful in the context where we need a continuous memory allocation. Using pointers dynamic allocation of memory is achieved pointers basically hold the address of a variable. they are mainly used as function parameters to pass values of parameters as references rather than values
ARRAYS
You can use one name for similar objects and save then with the same name but different indexes. Arrays are very useful when you are working with sequences of the same kind of data (similar to the first point but has a different meaning). Arrays use reference type and so.
The principal benefit of a linked list (using pointer) over a conventional array is that the list elements can easily be added or removed without reallocation or reorganization of the entire structure because the data items need not be stored contiguously in memory or on disk. Linked lists (pointer) allow insertion and removal of nodes at any point in the list, and can do so with a constant number of operations if the link previous to the link being added or removed is maintained during list traversal.
On the other hand, simple linked lists by themselves do not allow random access to the data other than the first node's data, or any form of efficient indexing. Thus, many basic operations — such as obtaining the last node of the list (assuming that the last node is not maintained as separate node reference in the list structure), or finding a node that contains a given datum, or locating the place where a new node should be inserted — may require scanning most or all of the list elements.

A pointer can refer to an individual item or to an array of items. In fact, an array is just a way of creating both a list of items and a pointer to that list's first item in one declaration. The array and pointer concepts are more or less completely interchangeable in C.
This means that subscripts can be used with pointers, as if they were arrays held at the address of the pointer. As C does no array bound checking, this is completely unsafe. You may assign the address of a simple int variable to a pointer to int and than access locations following it as if they belonged to an array of ints, as follows.
void main()
{
int i, * ip;
ip = & i;
ip[0] = 3;
ip[1] = 2;
ip[2] = 1;
}
On the other hand, an array can be used as if it was a pointer. We have
seen that arrays are always passed by reference, even though no & is written,
and this is why. The only
difference is that the address of an array cannot be changed by assignment. Thus,
the following would not be allowed:
void main()
{
int i, ia[];
ia = &i;
}



Question 3: What is a row major order? What is a column major order? How will you find the location of an element of an array , if the array is stored using row major order? Answer the question, if the array is stored in column major order.                                                       (10 Marks)
Lets now see how the data represented in an array is actually stored in the memory cells of the machine. Because computer memory is linear, a one-dimensional array can be mapped on to the memory cells in a rther straight forward manner. Sotrage for element A[I+1] will be adjacent to storage for element A[I] for I=0,1,2,… N-1. To find the actual address of an element one merely needs to subtract one from the position of the desired entry and then add the result to the address of the first cell in the sequence. Let us see it through an example. Consider an array A of 26 elements. We require to find the addressof A[4]. If the first cell in the sequence A[0] A[1],A[2],….A[25]. Was at address 16, then A[4] would be located at 16+4 = 20, as shown in Firgure. We assume that the size of each elemtn stored is one unit.



Therefore, it is necessary to know the starting address of the space allocated to the array and the size of the each element, which is same for all the elements of an array. We may call the starting address as a base address and denote it by B. then the location of 1th element would be
B + I*S (1)
Where S is the size of each element of array.
Let us now consider storage mapping for multi-dimentional arrays. As we had seen in previous section that in a 2-dimentional array must be simulated we first calculated the amount of storage area needed and allocate a block of contigous memory cells of that size. One way to stoe the data in the cells is row by row. That is, we store first the fist row of the array, then the second row of the aray and then the next and so on. For example the array defined by A, which logically appears as given in Firgure2 appears physically as given in Figure3 such a storage scheme is called Row Major Order.
The other alternative is to store the array column by column. It is called Column Major Order as in Figure 4.














BCA CS-06 BOOKS


To download right click on the link then select "save linked content as.."
CS-06 : Database Management Systems (IV SEM)
Block-1 : Introductory Concepts Of Data Base Management System
Block-2 : RDBMS and DDBMS
Block-3: Emerging Trends in Database Management Systems

BCA CS-06 BOOKS


To download right click on the link then select "save linked content as.."
CS-06 : Database Management Systems (IV SEM)
Block-1 : Introductory Concepts Of Data Base Management System
Block-2 : RDBMS and DDBMS
Block-3: Emerging Trends in Database Management Systems

BCA CS-63 (UNIX LESSONS)


UNIX LESSON 1

FEATURES OF UNIX

The UNIX operating system is a popular Operating system because of its simplicity in its design and functioning. The following are the key features which made the UNIX OS very popular:
• Multiuser system
• Time sharing
• Portability
• Multitasking
• Background processing
• Hierarchical file system
• Security and Protection
• Better communication
• Availability of compilers / tools / utilities
• Shell programming.

KERNEL AND THE SHELL

The main control program in a UNIX operating system is called the kernel. However, the kernel does not allow the user to give its commands directly; instead when the user types commands on the keyboard they are read by another program in the Operating System called a shell which parses, checks, translates and then passes them to the kernel for execution.

There are a number of different shells available, with names such as sh, csh, tcsh, ksh, bash, each with different rules of syntax; these are partly though not completely responsible for the diversity of UNIX. Later in our discussion we will see what are the criteria to select a shell. Once the command has been interpreted and executed, the kernel sends its reply, which may simply be a prompt for the next command to be entered, either directly to the display monitor. This is a program responsible for deciding where and in what form the output will appear on the display monitor. If for any reason the kernel cannot perform the command requested (wrong syntax), for example, the reply will be an error message; the user must then re-enter the corrected command.





UNIX COMMANDS


With many competing standards (UNIX 98, UNIX95, POSIX.2, SVID3, 4.3BSD, etc.) and most users having to deal with multiple systems, it’s crucial to know which commands are important enough to be used on nearly every version of UNIX. The following is a list of commonly used commands which are organised under different categories for understanding and ease of use. Keys proceeded by a ^ character are CONTROL key combinations.

Terminal Control Characters

^h backspace erase previously typed character
^u erase entire line of input so far typed
^d end-of-input for programs reading from terminal
^s stop printing on terminal
^q continue printing on terminal
^z currently running job; restart with bg or fg
DEL, ^c kill currently running program and allow clean-up before exiting
^\ emergency kill of currently running program with no chance of cleanup

Login and Authentication

login access computer; start interactive session
logout disconnect terminal session
passwd change local login password; you MUST set a non-trivial password

Information
date show date and time
history list of previously executed commands
pine send or receive mail messages
msgs display system messages
man show on-line documentation by program name
info on-line documentation for GNU programs
w, who who is on the system and what are they doing
who am i who is logged onto this terminal
top show system status and top CPU-using processes
uptime show one line summary of system status
finger find out info about a user@system

File Management

cat combine files
cp copy files
ls list files in a directory and their attributes
mv change file name or directory location
rm remove files
ln create another link (name) to a file
chmod set file permissions
des encrypt a data file with a private key
find find files that match specified criteria

Display Contents of Files

cat copy file to display device
vi screen editor for modifying text files
more show text file on display terminal with paging control
head show first few lines of a file(s)
tail show last few lines of a file; or reverse line order
grep display lines that match a pattern
lpr send file to line printer
pr format file with page headers, multiple columns etc.
diff compare two files and show differences
cmp compare two binary files and report if different
od display binary file as equivalent octal/hex codes
file examine file(s) and tell you whether text, data, etc.
wc count characters, words, and lines in a file

Directories

cd change to new directory
mkdir create new directory
rmdir remove empty directory (remove files first)
mv change name of directory
pwd show current directory

Devices

df summarize free space on disk device
du show disk space used by files or directories

Special Character Handling for C-shell

* match any characters in a file name
~user shorthand for home directory of "user"
$ name substitute value of variable "name"
\ turn off special meaning of character that follows
 In pairs, quote string w/ special chars, except !
 In pairs, quote string w/ special chars, except !, $
` In pairs, substitute output from enclosed command

Controlling Program Execution for C-shell

run job in background
DEL, ^c kill job in foreground
^z suspend job in foreground
fg restart suspended job in foreground
bg run suspended job in background
; delimit commands on same line
( ) group commands on same line


DESCRIPTION OF COMMONLY USED UNIX COMMANDS

The description for the most commonly used UNIX commands is given below in an alphabetic order.

cat

cat allows you to read multiple files and then print them out. You can combine files by using the > operator and append files by using >>.
Syntax: cat [argument] [specific file]
Example:
cat abc.txt
If you want to append three files (abc.txt, def.txt, xyz.txt), give the command as,
cat abc.txt def.txt xyz.txt > all

cd, chdir

cd (or chdir) stands for “change directory”. This command is the key command to move around your file structure.
Syntax: cd [name of directory you want to move to]
When changing directories, start with / and then type the complete file path, like
cd /vvs/abc/xyz

chmod

chmod (which stands for “change mode”) changes who can access a particular file. A “mode” is created by combining the various options from who, opcode, and permission.
Syntax: chmod [option] mode file
If you look at a list of files using the long list command ls –l, you’ll see the permissions, owner, file size, modification time, and filename. The first column of the list shows who can read, write, and execute the files or directories, in other words, the permissions. It basically shows who has permission to do what to a given file or directory. r stands for “read” and means that you’re allowed to read the file or directory. w stands for “write” and gives permission to edit or change the file as well
as create, move, rename, or remove a directory. x stands for “execute” which gives permission to run a file or search a directory. Every file or directory has four sets of rwx permissions. The first set represents the user (u), the second set represents the group (g), the third set represents other (o), and the fourth set represents all (a). The column will look like this:
rwxrwxrwx
Each set of rwx represents user, group, and other respectively. Only the owner of a file or a privileged user may change the permissions on a file. There are two ways to change permissions on a file or directory, either numerically or by using lettered commands. Both ways use the command chmod. To add permissions to a file, you use +, to remove permissions you use-.
For example, take a file:
-rw-r--r-- 1 yash mony 476 Apr 14 17:13 vvs.txt
To allow a group (mony, in this case) “write” access, you would type:
chmod g+w vvs.txt
If you wanted to remove “read” ability from “other” you would type:
chmod o-r vvs.txt
It is also possible to specify permissions using a three-digit sequence. This is a more efficient way to change permissions (or at least it requires less typing), so use this method if it doesn’t confuse you. Each type of permission is given an octal value. Read is given the value of 4, write is given the value of 2, and execute is given the value of 1. These values are added together for each user category. The permissions are changed by using a three-digit sequence with the first digit representing owner permission, the second digit representing group permission, and the third digit representing other permission. For example, if you wanted to make vvs.txt readable, writable, and executable for the user, readable and writable for the group, and readable for other, you would type:
chmod 764 vvs.txt
The first digit means readable and writable for the user (4+2+1), the second digit means readable and writable for the group (4+2+0), and the third digit means readable for other (4+0+0).
If you want to change the permissions on a directory tree use the -R option. chmod -R will recursively change the permissions of directories and their contents.

chown

chown changes who owns a particular file or set of files. New owner files refer to a user ID number or login name that is usually located in the /etc/password directory. The owner of a file or directory can be seen by using the command.
Syntax: chown [option] newowner files
Only the owner of a file or a privileged user can change the permissions on a file or directory. The following example changes the owner of vvs.txt to sridhar
chown sridhar vvs.txt

cp

The cp command copies files or directories from one place to another. You can copy a set of files to another file, or copy one or more files under the same name in a directory. If the destination of the file you want to copy is an existing file, then the existing file is overwritten. If the destination is an existing directory, then the file is copied into that directory.
Syntax: cp [options] file1 file2
If you want to copy the file favourites.html into the directory called laksh, you give the command as:
cp favourites.html /vvs/laksh/
A handy option to use with cp is -r. This recursively copies a particular directory and all of its contents to the specified directory, so you won’t have to copy one file at a time.

date

The date command can be used to display the date or to set a date.
Syntax: date [option] [+format] date [options] [string]
The first structure shows how date can be used to display the current date. A certain format can be specified in which the date should be displayed. Check the Unix manual for specific formats and options. The second structure allows you to set the date by supplying a numeric string. Only privileged users will be able to use this second command structure.

diff

diff displays the lines that differ between two given files.
Syntax: diff [options] [directory options] file1 file2
diff can be an extremely valuable tool for both checking errors and building new pages. If you run a diff between two files, you'll be shown what differences the files have line by line. The lines referring to file1 are marked with the <> symbol. If the file is a directory, diff will list the file in the directory that has the same name as file2. If both of the files are directories, diff will list all the lines differing between all files that have the same name.
If you have a file that is not working properly, it can be a great help to check it against a similar file that is working. It will often quickly alert you to a line of code that’s missing.
A handy option to use if you want to generally compare two files without noting the complex differences between them is the -h option (h stands for half-hearted). Using -i as an option will ignore differences in uppercase and lowercase characters between files, and -b will ignore repeating blanks and line breaks.

exit

The exit command allows you to terminate a process that is currently occurring.
For example, if you wanted to leave a remote host that you were logged onto (see rlogin also), you should type exit. This would return you to your home host.

find

find searches through directory trees beginning with each pathname and finds the files that match the specified condition(s). You must specify at least one pathname and one condition.
Syntax: find pathname(s) condition(s)
There are several handy conditions you can use to find exactly what you want. The -name condition will find files whose names match a specified pattern. The structure for the name condition is:
find pathname -name pattern
The condition -print will print the matching files to the pathname specified. -print can also be used in conjunction with other conditions to print the output.
If you wanted to find all the files named favorites.html in the directory Ram, then you’d do this:
find /Ram -name favorites.html –print
This looks through the directory Ram and finds all the files in that directory that contain favorites.html, then prints them to the screen. Your output would look like this:
/Ram/sixteen_candles/favorites.html
/Ram/favorites.html
/Ram/breakfast_club/favorites.html
All meta-characters (!, *, ., etc.) used with -name should be escaped (place a \ before the character) or quoted. Meta-characters come in handy when you are searching for a pattern and only know part of the pattern or need to find several similar patterns. For example, if you are searching for a file that contains the word “favorite”, then use the meta-character * to represent matching zero or more of the preceding characters. This will show you all files which contain favorite.
find /Ram -name '*favorite*' -print
This looks through the directory Ram and finds all the files in that directory that contain the word “favorite”. The output would look like this:
/Ram/sixteen_candles/favorites.html
/Ram/favorites.html
/Ram/least_favorites.html
/Ram/breakfast_club/favorites.html
/Ram/favorite_line.html
The -user condition finds files belonging to a particular user ID or name.

finger

finger displays information about various users as well as information listed in the .plan and .project files in a user’s home directory. You can obtain the information on a particular user by using login or last names. If you use the latter, the info on all users with that last name will be printed. Environments that are hooked up to a network recognize arguments (users) in the form of user@host or @ host.
Syntax: finger [options] users

grep

The grep command searches a file or files for lines that match a provided regular expression (“grep” comes from a command meaning to globally search for a regular expression and then print the found matches).
Syntax: grep [options] regular expression [files]
To exit this command, type 0 if lines have matched, 1 if no lines match, and 2 for errors. This is very useful if you need to match things in several files. If you wanted to find out which files in our vvs directory contained the word “mca” you could use grep to search the directory and match those files with that word. All that you have to do is give the command as shown:
grep ‘mca’ /vvs/*
The * used in this example is called a meta-character, and it represents matching zero or more of the preceding characters. In this example, it is used to mean “all files and directories in this directory”. So, grep will search all the files and directories in vvs and tell you which files contain “mca”.

head


head prints the first couple of lines of one or multiple files. -n is used to display the first n lines of a file(s). The default number of lines is 10.
Syntax: head [-n] [files]
For example, the following command will display the first 15 lines of favourites.html.
head -15 favourites.html

kill


kill ends the execution of one or more process ID’s. In order to do this you must own the process or be designated a privileged user. To find the process ID of a certain job give the command ps.
Syntax: kill [options] PIDs
There are different levels of intensity to the kill command, and these can be represented either numerically or symbolically. kill -1 or HUP makes a request to the server to terminate the process, while kill -9 or kill KILL forces a process to terminate absolutely. Most politely, UNIX users will attempt to kill a process using -1 first before forcing a process to die.

less


less is similar to more in that it displays the contents of files on your screen. Unlike more, less allows backward and forward movement within the file. It does not read the whole file before displaying its contents, so with large files less displays faster than more. Press h for assistance with other commands or q to quit.
Syntax: less [options] [files]

lprm

lprm removes printer queue requests.
Syntax: lprm /usr/ucb/lprm [optons] [job#] [users]
The lprm command will remove a job or jobs from a printer’s queue. If lprm is used without any arguments, it will delete the active job if it is owned by the user. If the command is used with -, then all the jobs owned by the user will be removed. To remove a specific job, use the job number.

ls

ls will list all the files in the current directory. If one or more files are given, ls will display the files contained within “name” or list all the files with the same name as “name”. The files can be displayed in a variety of formats using various options.
Syntax: ls [options] [names]
ls is a command you'll end up using all the time. It simply stands for list. If you are in a directory and you want to know what files and directories are inside that directory, type ls. Sometimes the list of files is very long and it flies past your screen so quickly you miss the file you want. To overcome this problem give the command as shown below:
ls | more
The character | (called pipe) is typed by using shift and the \ key. | more will show as many files as will fit on your screen, and then display a highlighted “more” at the bottom. If you want to see the next screen, hit enter (for moving one line at a time) or the spacebar (to move a screen at a time). | more can be used anytime you wish to view the output of a command in this way.
A useful option to use with ls command is -l. This will list the files and directories in a long format. This means it will display the permissions (see chmod), owners, group, size, date and time the file was last modified, and the filename.
drwxrwxr-x vvs staff 512 Apr 5 09:34 sridhar.txt
-rwx-rw-r-- vvs staff 4233 Apr 1 10:20 resume.txt
-rwx-r--r-- vvs staff 4122 Apr 1 12:01 favourites.html
There are several other options that can be used to modify the ls command, and many of these options can be combined. -a will list all files in a directory, including those files normally hidden. -F will flag filenames by putting / on directories, @ on symbolic links, and * on executable files.

man


The man command can be used to view information in the online Unix manual.
Syntax: man [options] [[section] subjects]
man searches for information about a file, command, or directory and then displays it on your screen. Each command is a subject in the manual. If no subject is specified, you must give either a keyword or a file. You can also search for commands that serve a similar purpose. For example, if you want more information about the chmod command, you should type:
man chmod
A screen will then appear with information about chmod. Type q to quit.

mkdir


mkdir creates a new directory.
Syntax: mkdir [options] directory name
For example, to create a directory called parkhyath in the present working directory, give the command as,
mkdir prakhyath

more


more displays the contents of files on your screen.
Syntax: more [options] [files]
To have the next line displayed, hit the return key, otherwise press the spacebar to bring up the next screen. Press h for assistance with other commands, n to move to the next file, or q to quit.

mv


mv moves files and directories. It can also be used to rename files or directories.
Syntax: mv [options] source target
If you wanted to rename vvs.txt to vsv.txt, you should give the command as:
mv vvs.txt vsv.txt
After executing this command, vvs.txt would no longer exist, but a file with name vsv.txt would now exist with the same contents.

passwd


The passwd command creates or changes a user’s password. Only the owner of the password or a privileged user can make these changes.
Syntax: passwd [options] files

ps


The ps command prints information about active processes. This is especially useful if you need to end an active process using the kill command. Use ps to find out the process ID number, then use kill to end the process.
Syntax: ps [options]

pwd


pwd prints the pathname of the current directory. If you wanted to know the path of the current directory you were in you give the command as pwd. You will get the complete path.

rlogin


The rlogin command, which stands for remote login, lets you connect your local host to a remote host.
Syntax: rlogin [options] host
If you wanted to connect to the remote host vsmanyam and you were on sree, you would do this:
rlogin vsmanyam password:******
You would then be at vsmanyam

rm

rm removes or deletes files from a directory.
Syntax: rm [options] files
In order to remove a file, you must have write permission to the directory where the file is located. While removing a which does’t have write permission on, a prompt will come up asking you whether or not you wish to override the write protection.
The -r option is very handy and very dangerous. -r can be used to remove a directory and all its contents. If you use the -i option, you can possibly catch some disastrous mistakes because it’ll ask you to confirm whether you really want to remove a file before going ahead and doing it.

rmdir

rmdir allows you to remove or delete directories but not their contents. A directory must be empty in order to remove it using this command.
Syntax: rmdir [options] directories
If you wish to remove a directory and all its contents, you should use rm -r.

su

su stands for superuser (a privileged user), and can be used to log in as another user. If no user is specified and you know the appropriate password, su can be used to log in as a superuser.
Syntax: su [option] [user] [shell_args]

tail

The tail command will print the last ten lines of a file. tail is often used with the option -f, which tells tail not to quit at the end of file and instead follow the file as it grows.
Syntax: tail [options] [file]
Use ctrl-c to exit this command.

telnet

You can communicate with other computers by using the telnet protocol. The host must be a name or an Internet address. telnet has two modes: the command mode, which is indicated by the telnet > prompt, and an input mode which is usually a session where you would log on to the host system. The default mode is command mode, so if no host is given it will automatically go into this mode. If you need help while in the command mode, type? or help.
Syntax: telnet [host [port]]

who

The who command prints out information about the most recent status of the system. If no options are listed, then all of the usernames currently logged onto the system are displayed.
Syntax: who [options] [file]
The option am i will print the name of the current user. The -u option will display how long the terminal has been idle.

Related Posts Plugin for WordPress, Blogger...

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites