int main(){     while(1)         fork(); }
Computer Science Notes
Wednesday, February 1, 2012
Fork Bomb: A simple bomb that makes you restart
Below is the few lines of code in C. It creats a Bomb called Fork Bomb.
Its just a few lines but it is sufficient to spawn infinitely many child processes. Each child again spawns infinite children. This continues.. and your system cries. Unable to take handle those many processes, your system gets slow, slower and finally stops responding. You got to restart your system.
Warning! You will loose your unsaved data. Also don't make any pranks out of it.
Monday, January 30, 2012
Blocking websites in your computer
If you want to block certain websites due to several reasons like parental restrictions or whatever use the following guidelines.
You will have to edit the host file. Here I will show you how to edit it in Ubuntu. The format of the host file is same in linux or windows so you will be fine even in windows.
Open your terminal
Your hosts file may be read only. so change it to read write. To do so you have to type in the command
right click on the hosts file
Click on properties
Click on Security
Choose your username then click edit
Check on the full control option.
Click on Apply and then on Ok
You can now edit the file.
What follows now is applicable to both windows and linux
You don't need to care about IPV6. Just ignore it. Now you need to add a line in the first block. Line to be added would be something like
Congratulations! Your sites are blocked
You will have to edit the host file. Here I will show you how to edit it in Ubuntu. The format of the host file is same in linux or windows so you will be fine even in windows.
Open your terminal
Your hosts file may be read only. so change it to read write. To do so you have to type in the command
sudo chmod +w /etc/hostsOpen the hosts file to edit it. You may open it using the commands :
sudo gedit /etc/hostsYou will see following things in your file.
127.0.0.1 localhostIn windows 7, the hosts file is located at
127.0.1.1 abc-laptop
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
C:\Windows\System32\drivers\etcYou won't have the access to edit it. So in order to enable the editing:
right click on the hosts file
Click on properties
Click on Security
Choose your username then click edit
Check on the full control option.
Click on Apply and then on Ok
You can now edit the file.
What follows now is applicable to both windows and linux
You don't need to care about IPV6. Just ignore it. Now you need to add a line in the first block. Line to be added would be something like
127.0.0.1 www.facebook.comHere I used it to block facebook, instead you can replace www.facebook.com with any domain name you would like to be blocked. So your final file would look something like this
127.0.0.1 localhostNow save the file and close it.
127.0.1.1 mahesh-laptop
127.0.0.1 www.facebook.com
127.0.0.1 twitter.com
127.0.0.1 http://www.youtube.com
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
Congratulations! Your sites are blocked
Saturday, January 7, 2012
Adding copyright to your image
If you want to add copyright to image which you want to upload to your picasa web albums, its as easy as this.
1) run Picasa application
2) go to tools
3) go to options...
4) go to Web Albums
5) select option "Add a watermark for all photo uploads. "
6) now you need to copy the copyright symbol © using Ctrl + C command.
7) use ctrl +v to paste it in the textbox in picasa.
8) add any text you want after the © symbol
eg. when I use ©maheshmhs in my photo it appears as in the image below.
1) run Picasa application
2) go to tools
3) go to options...
4) go to Web Albums
5) select option "Add a watermark for all photo uploads. "
6) now you need to copy the copyright symbol © using Ctrl + C command.
7) use ctrl +v to paste it in the textbox in picasa.
8) add any text you want after the © symbol
eg. when I use ©maheshmhs in my photo it appears as in the image below.
iPhone 5: Release Date and Specifications
iPhone 5: Release Date and Specifications: I don't own an iPhone yet. I was planning to have one. But then a thought crossed my mind. What if Apple guys decide to launch iPhone 5? ...
Thursday, December 15, 2011
Data Structure
What is data structure, storage structure and file structure?
The physical meaning of the term ‘data structure’ itself explains that data structure pertains to how a particular data item is structured. We are well aware that data may be organized in many different ways. The logical or mathematical description on how the data item is organized is called data structure. At the same time it deals how the data item behaves on being stored in that particular structure. These data items may be organized in different ways, thus defining different data structure. One needs to make choice between these different data models putting in consideration that it should have sufficient structure to reflect the real world data besides being simple enough to be processed efficiently whenever necessary. The data item needs for sure to be stored in the memory of the computer. The data item may be represented in the memory in different ways. This representation of the particular data structure in memory of computer is called ‘Storage Structure’. However data item can still be stored in auxiliary memory. This representation of the storage structure in auxiliary memory is called file structure.
What is algorithm? What are its categories? Describe the properties of algorithm.
An algorithm is a well defined list of steps for solving a particular problem. Or it may be defined as the step by step procedure to solve any problem. In other words it is a finite sequence of instructions, each of which has a clear meaning and can be performed with a finite length of time. These algorithms are written using some English like statements and statements of some programming language like c, c++, java, Pascal.
Algorithms are categorized in two major groups:
1). Iterative: These types of algorithms follow iteration methods. In doing so, they make best use of loops and conditional statements.
2). Recursive: These types of algorithms follow recursive methods. These algorithms divide complex problems to smaller problems of the same type. This can be better said that these algorithms use divide and conquer strategy.
Properties of algorithms:
i) Input: An algorithm must receive some data externally.
ii) Output: An algorithm must produce an output as a result.
iii) Finiteness: An algorithm must terminate after a finite no of steps, i.e. it must not execute infinitely. Operating system is the only algorithm which must work infinitely until we apply some external interrupt.
iv) Definiteness: The steps of the algorithm to be performed must be clear and unambiguous.
v) Effectiveness: An algorithm must be effective enough to perform the steps in the algorithm without applying intelligence.
Describe the whole classification of data structure.
Data structure can be broadly divided in to two groups:
A)Primitive Data Structure:
These are the basic data structure which can be directly used or operated on the system. Examples of this type of data structure are integers, characters, string, float, pointers.
B) Non Primitive Data Structure:
This group of data structure is more complex and is derived from primitive type of data structure. It emphasizes on structuring a group of either homogeneous or non homogeneous data items.
Non primitive data structure is again categorized into linear data structure and non linear data structure.
Linear Data Structure: In such data structure processing of data item is possible in linear manner. Stacks and queues are the examples of this type of data structure where data can be processed one by one sequentially.
Non Linear Data Structure: Non linear data structures are those structure in which processing of data like insertion, deletion and traversing is not possible in linear manner. E.g. trees, graphs.
Data Structure can again be classified in to following six types:
1) Array: This is the simplest type of data structure in which a list of finite number of similar data elements is referenced respectively by a set of n consecutive numbers.
2) Linked List: It’s collection of nodes in which each node has two fields. The first part is information part which stores the data and the other one is address of the next node.
3) Stacks: It’s the data structure which follows the LIFO (last In First Out) rule. It’s a linear list in which insertion and deletion can take place only at top. It’s similar to that of pile of plates.
4) Queue: It follows FIFO (first in first out) rule. It’s a linear list of elements in which the insertion can take place at the rear of the list while deletion can take place only at the front of the list. Automobiles waiting to pass through an intersection can be taken as an example where first car in a line is the first to leave.
5) Tree: In this data structure the data items are arranged in a hierarchical manner. It is generally represented by tree like structure in which the tree is turned upside down i.e. roots on top.
6) Graph: This is another type of data structure which contains relationships between pair of elements which may not by necessary hierarchical in nature. So tree can also be considered to be a graph.
The physical meaning of the term ‘data structure’ itself explains that data structure pertains to how a particular data item is structured. We are well aware that data may be organized in many different ways. The logical or mathematical description on how the data item is organized is called data structure. At the same time it deals how the data item behaves on being stored in that particular structure. These data items may be organized in different ways, thus defining different data structure. One needs to make choice between these different data models putting in consideration that it should have sufficient structure to reflect the real world data besides being simple enough to be processed efficiently whenever necessary. The data item needs for sure to be stored in the memory of the computer. The data item may be represented in the memory in different ways. This representation of the particular data structure in memory of computer is called ‘Storage Structure’. However data item can still be stored in auxiliary memory. This representation of the storage structure in auxiliary memory is called file structure.
What is algorithm? What are its categories? Describe the properties of algorithm.
An algorithm is a well defined list of steps for solving a particular problem. Or it may be defined as the step by step procedure to solve any problem. In other words it is a finite sequence of instructions, each of which has a clear meaning and can be performed with a finite length of time. These algorithms are written using some English like statements and statements of some programming language like c, c++, java, Pascal.
Algorithms are categorized in two major groups:
1). Iterative: These types of algorithms follow iteration methods. In doing so, they make best use of loops and conditional statements.
2). Recursive: These types of algorithms follow recursive methods. These algorithms divide complex problems to smaller problems of the same type. This can be better said that these algorithms use divide and conquer strategy.
Properties of algorithms:
i) Input: An algorithm must receive some data externally.
ii) Output: An algorithm must produce an output as a result.
iii) Finiteness: An algorithm must terminate after a finite no of steps, i.e. it must not execute infinitely. Operating system is the only algorithm which must work infinitely until we apply some external interrupt.
iv) Definiteness: The steps of the algorithm to be performed must be clear and unambiguous.
v) Effectiveness: An algorithm must be effective enough to perform the steps in the algorithm without applying intelligence.
Describe the whole classification of data structure.
Data structure can be broadly divided in to two groups:
A)Primitive Data Structure:
These are the basic data structure which can be directly used or operated on the system. Examples of this type of data structure are integers, characters, string, float, pointers.
B) Non Primitive Data Structure:
This group of data structure is more complex and is derived from primitive type of data structure. It emphasizes on structuring a group of either homogeneous or non homogeneous data items.
Non primitive data structure is again categorized into linear data structure and non linear data structure.
Linear Data Structure: In such data structure processing of data item is possible in linear manner. Stacks and queues are the examples of this type of data structure where data can be processed one by one sequentially.
Non Linear Data Structure: Non linear data structures are those structure in which processing of data like insertion, deletion and traversing is not possible in linear manner. E.g. trees, graphs.
Data Structure can again be classified in to following six types:
1) Array: This is the simplest type of data structure in which a list of finite number of similar data elements is referenced respectively by a set of n consecutive numbers.
2) Linked List: It’s collection of nodes in which each node has two fields. The first part is information part which stores the data and the other one is address of the next node.
3) Stacks: It’s the data structure which follows the LIFO (last In First Out) rule. It’s a linear list in which insertion and deletion can take place only at top. It’s similar to that of pile of plates.
4) Queue: It follows FIFO (first in first out) rule. It’s a linear list of elements in which the insertion can take place at the rear of the list while deletion can take place only at the front of the list. Automobiles waiting to pass through an intersection can be taken as an example where first car in a line is the first to leave.
5) Tree: In this data structure the data items are arranged in a hierarchical manner. It is generally represented by tree like structure in which the tree is turned upside down i.e. roots on top.
6) Graph: This is another type of data structure which contains relationships between pair of elements which may not by necessary hierarchical in nature. So tree can also be considered to be a graph.
Subscribe to:
Comments (Atom)
