Tuesday, June 30, 2009

prefix-infix-postfix

5 comments

Welcome back after a long time!!

@ UCSC for our data structures & algorithms course we had a assignment for converting between prefix-infix-postfix notations. So there are total of 6 conversions! I’m posting this because as i experienced this is a good project for get around in stacks, recursion and basic algorithm and data structure stuff.

I implemented four of conversions which are infix –> prefix,

infix –> postfix , prefix –> infix, postfix –> infix.

Other 2 conversions will happen using the above ones.

I wrote up the program that will support unary operators(minus numbers) 1-n digit numbers (5 , 50 , 456 , ..)

BELOW are the pseudocodes

Infix to Postfix algorithm
1) Check for parenthesis errors. If found return ERROR
2) Get the next element and store it in a variable – temp
a. IF temp is a operand, examine the next element
1. IF it is a operand output temp
2. ELSE IF stack.top is unary minus --> output temp
3. ELSE output temp and a SPACE
ii. ELSE IF stack.top is unary minus -->output temp
iii. ELSE output temp and a SPACE
b. ELSE IF temp is a opening parenthesis -->push stack with temp
c. ELSE IF temp is a operator
i. IF stack is empty -->push stack with temp
ii. ELSE IF stack.top is a opening parenthesis -->push stack with temp
iii. ELSE IF temp’s precedence > stack.top precedence -->push stack with temp
iv. ELSE output stack.pop and a SPACE AND repeat step “c”
d. ELSE IF temp is a closing parenthesis
i. WHILE stack.top is NOT opening parenthesis -->output stack.pop and a SPACE
ii. IF stack.top is opening parenthesis -->pop the stack
3) WHILE stack IS NOT empty -->output stack.pop and a SPACE


Infix to Prefix algorithm
Same as infix to postfix algorithm except,
1) Before step 2 the input string will be reversed.
2) Also the two parenthesis{ “ ( ” , ” ) ” } will be swapped where mentioned.
3) Lastly the output will be reversed


Prefix to Infix algorithm
This algorithm is a non-tail recursive method.
1) The reversed input string is completely pushed into a stack.
prefixToInfix(stack)
1) IF stack is not empty
a. Temp -->pop the stack
b. IF temp is a operator
i. Write a opening parenthesis to output
ii. prefixToInfix(stack)
iii. Write temp to output
iv. prefixToInfix(stack)
v. Write a closing parenthesis to output
c. ELSE IF temp is a space -->prefixToInfix(stack)
d. ELSE
i. Write temp to output
ii. IF stack.top NOT EQUAL to space -->prefixToInfix(stack)


Postfix to Infix Algorithm
Same as Prefix to Infix algorithm except,
1) Step 1 must be changed – The input string will be pushed into the stack
2) Also the two parenthesis{ “ ( ” , ” ) ” } will be swapped where mentioned.
3) The output string will be reversed.

as i think this post will be a valuable resource for any computer science student!

image

Monday, June 8, 2009

A easy way to share and store files online

4 comments

As i know almost of my friends @ da uni use pen drives (USB flash drives). They usually carry assignments, important documents, photos of GF or BF ;-) and etc., This is very dangerous becoz usually pen drive is not very reliable device and it can be lost or stolen by someone easily.

Your computer’s hard disk is also vulnerable for failures and can be virus affected also.

The result is losing ur assignment that must be given tomorrow. Then finally freaking out!!!

The ANSWER is storing the files online. There are various free sites that give this service but i use “Dropbox”. It hav lots of features to explore.

I will list some feature that i like most,

1. There is a desktop client which will integrate with a folder in ur hard disk which can be synched online. There re offering clients for Windows, Linux and OSX. Cool!!!

This means u can synch files over several computers.

dropbox dropboxmenu

This is a screenshot of my dropbox and the menu. U will see which files or folders are current updated or synchronizing.

There re giving out a 2GB account free, if u want to upgrade it is possible.

2. There is a web client which will be accessible @ www.getdropbox.com

This site is very feature rich and easy to learn. It uses https protocol which is more secure also.

dropboxevents dropboxweb

3. U can also share certain folders with ur friends. They wont be allowed to other files or folders so it is great in team work.

Hope u will give a try!

U can get dropbox @ the link below,This my referral which will give 250 MB free for both of us so if u re interested go to it & download!

Download Dropbox

Saturday, June 6, 2009

my most WANTED firefox extensions!

5 comments

I simply can’t live without firefox extenstions! Truly! It enhances the productivity of firefox & the web browsing experience overall.

I use about 10 extensions or add-ones. I will list them by my preference. btw u can download it by clicking on the title.

However addons make firefox more memory hungry! So be careful.

1. Adblock Plus

This nifty add-on can almost block any AD in internet. So this will result websites loading fast. You can also block anything according to ur preference also. It will also block adsense ads. After installing u can subscribe to a list that maintains a database of ads, scripts , etc. As i think it is a MUST for every firefox user.

2. Flagfox

This addon wont interest every user. This addon will list everythingabout the current site loaded up in the tab. It displays a flag according what country the site is hosted. It will also give access to numerous IP tools, Domain tools.

3. Xmarks

This is a addon which will sync ur bookmarks and passwords. This is useful who use more than one computer. Also it remembers all the passwords which is hosted online. All are encrypted so no need to be worry. A master password is used to access all the data. To use Xmarks u hav to create a account which is FREE.

This also list top 3 sited related to the current site u re browsing also.

4. TwitterFox

This is for twitters. It can update the status, receive twitters, link the current site, see the replies and messages. It supports multiple accounts. A simple addon but very useful.

5. EnSiTip

English-Sinhala translator for firefox. Displays the definition/s of the word below the cursor. Very useful!

6. Cooliris

A cool awesome addon which transforms ur browser to a 3d wall. It can browse numerous sites in it. I use it for google search, youtube, facebook photo albums. By using this u can enjoy sites in a geeky and a faster way! a MUST!

7. Peers

When google chrome came into the scene it had the awseome address bar that doubles as a search bar, remember? However this functionality is not there in firefox. However by this addon u can get that functionality.

8. Split Browser

This addon is more useful for who hav widescreen displays. It can split the current tab into two pages horizontally or vertically. This is great for comparing. U can also synchronize the scroll.

9. FoxTab

Do u love the flip3d in windows or ubuntu(compiz)? Then u will love this also. U can quickly switch between tabs in a cool way.

There is lot of features built-in so u can also give it a try!

10. FEBE

FEBE stands for Firefox Environment Backup Extension. It can backup ur entire profile including extensions, history(browser and form fill), bookmarks, cache, settings, themes cookies.

This is a life saver when u want to install firefox again. U wont have to download extensions or themes again ever!

Thursday, June 4, 2009

Trying out MS Office 2010

5 comments
Microsoft have released a technical preview of MS Office 2010 few weeks ago. Because of my curiosity I downloaded it @ da usual place and installed this beta-like software to my desktop.

I found out a new visually appealing splash screen
As i feel the performance is still the same as old Office 2007.
It still have the eye-catching and the very useful ribbon.












The ribbon feature is now available in Outlook also :-)

The most prominent new feature is the new Office Menu
All important functions of every office program is integrated into this powerful menu.










This version is made to Windows 7 hence it support
my favorite jump lists

However since this is a technical preview there are lots of bugs.
But i'm impressed what Microsoft have come up with!

Office 2010 bears the number 14. Previous version which is 2007 had number 12. Microsoft have skipped number 13 becoz of superstitious feelings maybe??