The wikipedia article has a nice concise description of when you would want to use the different types of depth-first search:
- Pre-order traversal while duplicating nodes and values can make a complete duplicate of a binary tree. It can also be used to make a prefix expression (Polish notation) from expression trees: traverse the expression tree pre-orderly.
- In-order traversal is very commonly used on binary search trees because it returns values from the underlying set in order, according to the comparator that set up the binary search tree (hence the name).
- Post-order traversal while deleting or freeing nodes and values can delete or free an entire binary tree. It can also generate a postfix representation of a binary tree.
It boils down to the logistical needs of an algorithm. For example, if you don't use post-order traversal during deletion, then you lose the references you need for deleting the child trees.
Write a shell script that searches the file contents in a directory and its sub-directories for a text string given by the user. It list all such file names having that given string and store in a temp file "search_temp". It should have user friendly messages e.g. "File does not exit" , "Do you want to search again", etc.
#bin/bashread-p"Enter a filename:"filename
if
[[
-f $ Search_temp]]
;
then echo
"The file $ Search_temp exists."read –p
"Enter the you word want to find:"
Word
grep "$word"
"$Search_temp"
else echo "The file $filename does not exist ".
fi
SUCCESS=0
E_NOARGS=65
If
[-z"$1"]
then
echo"Usage:basename
$0'rpm-file"
exist $E_NOARGS
fi
{
#Begin code block.
echo echo"Archive Description:"
rpm-qpi $ 1 # Query descri....
echo echo"Archive Listing:"
rpm-qpl $ 1 # Query listing
echo rpm-i—test $ 1 # Query whether rpm file can be installed.
If ["$?" – eq $ SUCCESS]
then
echo "$1 can be installed."
else
echo "$1 cannot be installed."
Fi
echo #End code block.
}> "$1.test" #Redirects output of everything in block of file.
echo "Result of rpm test in file $1.test"
#See rpm main page for explanation of options.
exit 0.
exits = $(grep-c$word$file)
if
[[$exits-gt0]];
then
echo"File does not exit"
fi
STEP 1: Setting up first IP address. Edit /etc/sysconfig/network-scripts/ifcfg-eth0 on Redhat Linux box and give the following entries as shown.
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=static IPADDR=192.168.1.10 NETMASK=255.255.255.0 NETWORK=192.168.1.0 ONBOOT=yes
STEP 2: Setting up second IP address. Create one file as /etc/sysconfig/network-scripts/ifcfg-eth0:1 and give the entries as below in to this file.
vi /etc/sysconfig/network-scripts/ifcfg-eth0:1
DEVICE=eth0:1 BOOTPROTO=static IPADDR=192.168.1.11 NETMASK=255.255.255.0 NETWORK=192.168.1.0 ONBOOT=yes
STEP 3: Once you configure above files and save them. Now reload the network service on your machine.
service network reload
STEP 4: Check if you get the IP address assigned to the eth0 and eth0:1 interfaces respectively.
ifconfig
Note1: We can assign virtual IP to the same interface with ifconfig but that one is not permanent so not giving info on that.
Note2: We can assign up to 16 virtual IP address to a single NIC card.
