Friday, November 21, 2008
Microsoft Excel : copying the same data to Other cells
Copying (Filling) the Same Data to Other Cells
Another way to enter labels or values onto a sheet is to use the Fill feature. You can copy (fill) an entry into surrounding cells. For example, suppose you have a list of students on a worksheet, and they will each get 1 mark in an assignment . You can enter the once and then use the Fill feature to insert multiple copies of into nearby cells. To use the Fill feature for copying, follow these steps:
1. Click the fill handle of the cell (the small block in the lower-right corner of the cell) that holds the data that you want to copy
2. Drag the fill handle down or to the right to copy the data to adjacent cells. A data tag appears to let you know exactly what data is being copied into the cells.
3. Drag the fill handle to copy the contents of a cell into neighboring cells.
Release the mouse button. The data is "filled" into the selected cells.
Converting xlsx file to xls file
is output by MS-Office 2007 and cannot be opened with Office
2003 directly. Nor can Google Docs handle it as of today.
So, if you have Office 2003 and an xlsx file, which you want to
view, Download Microsoft Office Compatibility Pack .
Wednesday, November 19, 2008
Chromatic Polynomial
Chromatic Polynomial :
For some reason, the topic of chromatic polynomials has
caught the fancy
of my students. And, in particular, the chromatic
polynomial of this graph:
In order to compute
C(G, λ) for the above, I suggested using
the decomposition
theorem. Remove the edge between b,d
and fuse the same vertices in
order to obtain G1 and G2.
G2 will be K3(complete graph with 3
vertices) and for G1,
use the decomposition theorem once
again(i.e. remove the edge between b,c and fuse the same vertices)
to obtain G3 and G4. Now, G4 will again be K3, whereas G3 will
be a simple path of 4 vertices.
After that, I have got two
different and correct solutions
from the students, both of which
don’t use decomposition
theorem.
Solution I :
Suppose, a can be colored in λ ways. Then b
can be colored in λ-1 ways, d in λ-2 ways and
finally c in λ-2 ways.
So, C(G, λ) = (λ)(λ-1)( λ-2)( λ-2)
Note that the order, in which the colors are being assigned,
is important. So, if we assign the colors in a different order, i.e.:
a,b,c,d , the above solution will no longer hold. That is what
confused a bunch of students and one of them(Garveet Parmar)
came up with this solution :
Solution II :
Suppose a can be colored in
λ ways, then b can be colored in
λ-1 ways and c in λ-1 ways. Now, in order to color d,
how many choices do we have? d is connected to all the 3
vertices,
so a casual answer might be : 3. But note that, a and c
can be of same colors. So there are 2 different cases :
Case 1:
a and c are of same colors :
a can be colored in λ ways, b in λ-1 ways, c in 1
way and d in -2 ways.
C1(G, λ) =
(λ).( λ -1).1.( λ-2)
Case 2 :
a and c are of different colors :
a can be colored in λ ways, b in λ-1 ways, c in λ-2
ways and d in λ-3 ways.
C2(G, λ) = λ(λ-1)( λ-2)( λ-3)
Take some time to grasp it and post a comment
if you don’t get it.
Now adding the polynomials C1 and C2, you should get
the final polynomial :
C(G, λ) = C1(G, λ) + C2(G, λ)
= (λ).( λ -1).( λ-2).[ λ-3+1]
= (λ).( λ -1).( λ-2).( λ -2)
which is same as our earlier answer.
Tuesday, November 18, 2008
Enabling hibernate option in Windows XP
- Make sure you're logged onto your PC as Administrator or as a user with Administrator rights.
- You can check the status of your user account by going to Start Control Panel and selecting the User Account icon.
- Your account should be listed there.
- If it says Computer Administrator you have the rights to make this change.
- To show the Hibernate option under shutdown, select Start Control Panel, and select the Performance and Maintenance icon.
- Select the Power Options icon under "or pick a Control Panel Icon."
- Select the Hibernate tab, and click on the Enable Hibernation box.
Chromatic Polynomial
Chromatic Polynomial :
The chromatic polynomial C(G,λ)of graph G denotes the different number of
colorings which are possible for G with at most λ colors. For example in the following Graph(K3), no coloring is possible for λ<=2 colors. With λ=3, 6 colorings are possible
which is equal to factorial(3). Since first vertex can be colored in λ
ways, second vertex in λ-1 and third vertex in λ-2 ways, so total number of colorings
possible is λ(λ-1)( λ-2).
Arguing in the similar fashion, we can arrive at following chromatic polynomials :
(i) C(G, λ) = λn for a null graph G with n vertices.
(ii) If G is an open path with n vertices :
C(G, λ) = λ .λn-1
(iii) If G is the complete graph Kn
C(G, λ) = λ(λ-1)( λ-2)….( λ-n+1)
(iv) If Gi, 1<=i<=k, are components of graph G,
then C(G, λ) = Πi=1k C(Gi, λ) = C(G1, λ).C(G2, λ)…C(Gk, λ)
Finding out chromatic number of a graph from its chromatic polynomial:
Remember what’s the chromatic number?
Minimum number of colors required in order to color a graph such that
none of its adjacent vertices are of same color.
Now, Chromatic number has to be an integer.
Also, Chromatic polynomial should always be >0.
So, the minimum value of λ for which the chromatic
polynomial is >0, is the chromatic number.
For e.g.,
for C(G, λ) = λ(λ-1)( λ-2)
the minimum positive integer value of λ for which the polynomial is >0
is 2. Which is indeed the chromatic number of K3.
Decomposition Theorem for chromatic polynomials :
If we obtain two graphs G1 and G2 from G in the following way :
(i) Obtain G1 by removing an edge (v1,v2) from G.
(i) Obtain G2 by fusing/collapsing v1,v2 in G.
Then :
C(G1, λ) = C(G, λ) + C(G2, λ)
For e.g.
Let G be the following graph :
then if I remove the edge (a,b) and obtain G1
chromatic polynomial for G1 is λ2 .
And if I fuse/collapse a and b to obtain G2 :
chromatic polynomial for G2 is λ.
In order to obtain C(G, λ),
C(G, λ) = C(G1, λ) – C(G2, λ)
= λ2 – λ = λ(λ -1),
which is indeed correct.
Similarly you can obtain the chromatic polynomial for the following
graph :
By observing that if you fuse/collapse b,d you obtain K3, whose
chromatic polynomial is known to you and if you remove the edge
(b,d) you obtain an open path with 4 vertices, whose chromatic
polynomial is also known to you.
You should get the following C.P. for the above graph :
C(G, λ) = λ(λ-1)( λ2 - 3λ + 3)
Tuesday, November 11, 2008
displaying newline space etc in vim
Saturday, November 8, 2008
Hi,
I use a tablet PC(IBM) to teach my class. This tablet PC doesn't have a CD/DVD drive.
And I have a software on a DVD, which I have installed.
But this software doesn't run, if the DVD is not present in the DVD drive.
I tried to copy the DVD contents as am image file using ImgBurn, but there was this error :
--------------------------
ImgBurn
--------------------------
I/O Error!
Device: [1:0:0] HL-DT-ST DVDRAM GSA-T20L NC08 (F:) (ATA)
ScsiStatus: 0x02
Interpretation: Check Condition
CDB: BE 00 00 00 03 AD 00 00 01 10 00 00
Interpretation: Read CD - Sector: 941
Sense Area: 70 00 03 00 00 00 00 0A 00 00 00 80 10 90 00 00 00 00 00 00 00 00 00 00
Interpretation: Unknown (CRC or ECC Error) (0x10, 0x90)
I also tried to copy the CD contents as they are, but there is
a file named DATA.tsr, which is not being copied.
When I tried to copy through, Ctrl-C, Ctrl-V,
I got this :
"Cannot read from the source file or disk".
I got similar errors when I tried to copy through command line.
How to get around this?
Solution:
I just ignored the Data.tsr file and copied the rest of the contents.
Then created an image using Imgburn and I was able to load
and run it with Daemon tools correctly.
PS :
I had also tried ddrescue(sudo apt-get install ddrescue) on this dvd in Ubuntu, but it was not
the correct approach, since, apparently the DVD was kept
intentionally corrupt in order to prevent any copies.
A simple TCP/IP chat application
client.c
sock1 = socket(..);
connect();
while(1)
{
printf("enter your message");
fgets();
write(sock1);
read();
}
server.c
socket();bind();listen;
sock2=accept();
while(1){
read();
printf("enter your message");
fgets();
write();
}
Echo server/client using tcp/ip sockets in c
1. client.c
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#define PORT 2080
main()
{
int sock1,sock2,clength;
char str1[100],str2[100];
sock1 = socket(AF_INET,SOCK_STREAM,0);
struct sockaddr_in serv,cli;
serv.sin_port = htons(PORT);
serv.sin_family = AF_INET;
serv.sin_addr.s_addr = inet_addr("127.0.0.1");
connect(sock1, (struct sockaddr *)&serv,sizeof(serv));
printf("client connecting\n");
printf("enter a string\n");
fgets(str1,100,stdin);
write(sock1,str1,100);
printf("\nString sent to server, waiting for reply");
read(sock1,str2,100);
printf("\nserver replied : %s",str2);
return 0;
}
2. server.c :
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#define PORT 2080
main()
{
int sock1,sock2,clength;
char recv[100];
sock1 = socket(AF_INET,SOCK_STREAM,0);
struct sockaddr_in serv,cli;
serv.sin_port = htons(PORT);
serv.sin_family = AF_INET;
serv.sin_addr.s_addr = inet_addr("127.0.0.1");
bind(sock1,(struct sockaddr *)&serv,sizeof(serv));
listen(sock1,5);
clength = sizeof(cli);
sock2 = accept(sock1,(struct sockaddr*)&cli,&clength);
printf("\n Client connected");
read(sock2,recv,100);
printf("\nClient said: %s",recv);
write(sock2,recv,100);
return 0;
}
A bunch of c files for file transfer using tcp/ip sockets
1. server.c
2. client.c
server.c :
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#define PORT 2080
main()
{
int sock1,sock2, clength;
sock1 = socket(AF_INET,SOCK_STREAM,0);
struct sockaddr_in serv,cli;
serv.sin_family = AF_INET;
serv.sin_port = htons(PORT);
serv.sin_addr.s_addr = inet_addr("127.0.0.1");
bind(sock1,(struct sockaddr *)&serv, sizeof(serv));
listen(sock1,5);
clength = sizeof(cli);
int i=0;
char buf[50];
sock2 = accept(sock1,(struct sockaddr *)&cli,&clength);
printf("\n Client Connected\n");
FILE* fp = fopen("server.txt","r");
while(!feof(fp)){
bzero(buf,sizeof(buf));
fread(buf,sizeof(char),50,fp);
write(sock2,buf,50);
}
write(sock2,"quit1234",50);
fclose(fp);
return 0;
}
client.c :
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#define PORT 2080
main()
{
int sock1;
sock1 = socket(AF_INET,SOCK_STREAM,0);
struct sockaddr_in serv;
serv.sin_port = htons(PORT);
printf("%x %x\n",PORT,htons(PORT));
serv.sin_family = AF_INET;
serv.sin_addr.s_addr = inet_addr("127.0.0.1");
printf("client connecting\n");
connect(sock1, (struct sockaddr *)&serv,sizeof(serv));
char buf[50];
FILE* fp = fopen("client.txt","w");
while(1){
bzero(buf,sizeof(buf));
read(sock1,buf,50);
if(strcmp(buf,"quit1234")==0)
{
break;
}
fprintf(fp,"%s",buf);
}
fclose(fp);
}
Friday, November 7, 2008
Wednesday, November 5, 2008
Sunday, November 2, 2008
The "Compilers" course at MIT
But, at times it's difficult to find what we are looking for.
I too had a tough time finding out which was the course
for "Compilers".
Here it is :
http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-035Fall-2005/LectureNotes/index.htm
Blog Archive
-
▼
2008
(73)
-
▼
November
(14)
- Microsoft Excel : copying the same data to Other c...
- Converting xlsx file to xls file
- Chromatic Polynomial
- Enabling hibernate option in Windows XP
- Chromatic Polynomial
- displaying newline space etc in vim
- Problem :Hi,I use a tablet PC(IBM) to teach my cla...
- A simple TCP/IP chat application
- Echo server/client using tcp/ip sockets in c
- A bunch of c files for file transfer using tcp/ip ...
- Achieving Mathematical Proofs Via Computers
- Tower of hanoi non recursive program in C
- The DSA(data structures and algoritms" course at MIT
- The "Compilers" course at MIT
-
▼
November
(14)