Wednesday, 10 October 2012

Algorithm and Programming


What is a computer algorithm?
              To make a computer do anything, you have to write a computer program. To write a computer program, you have to tell the computer, step by step, exactly what you want it to do. The computer then "executes" the program, following each step mechanically, to accomplish the end goal.
When you are telling the computer what to do, you also get to choose how it's going to do it. That's wherecomputer algorithms come in. The algorithm is the basic technique used to get the job done. Let's follow an example to help get an understanding of the algorithm concept.
Let's say that you have a friend arriving at the airport, and your friend needs to get from the airport to your house. Here are four different algorithms that you might give your friend for getting to your home:
The taxi algorithm:
1.    Go to the taxi stand.
2.    Get in a taxi.
3.    Give the driver my address.
The call-me algorithm:
1.    When your plane arrives, call my cell phone.
2.    Meet me outside baggage claim.
The rent-a-car algorithm:
1.    Take the shuttle to the rental car place.
2.    Rent a car.
3.    Follow the directions to get to my house.
The bus algorithm:
1.    Outside baggage claim, catch bus number 70.
2.    Transfer to bus 14 on Main Street.
3.    Get off on Elm street.
4.    Walk two blocks north to my house.
All four of these algorithms accomplish exactly the same goal, but each algorithm does it in completely different way. Each algorithm also has a different cost and a different travel time. Taking a taxi, for example, is probably the fastest way, but also the most expensive. Taking the bus is definitely less expensive, but a whole lot slower. You choose the algorithm based on the circumstances.
In computer programming, there are often many different ways -- algorithms -- to accomplish any given task. Each algorithm has advantages and disadvantages in different situations. Sorting is one place where a lot of research has been done, because computers spend a lot of time sorting lists. Here are five different algorithms that are used in sorting:
·         Bin sort
·         Merge sort
·         Bubble sort
·         Shell sort
·         Quicksort
If you have a million integer values between 1 and 10 and you need to sort them, the bin sort is the right algorithm to use. If you have a million book titles, the quicksort might be the best algorithm. By knowing the strengths and weaknesses of the different algorithms, you pick the best one for the task at hand.
Here are some interesting links:
·         whatis.com: Algorithm
               Definition An algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem. The word derives from the name of the mathematician, Mohammed ibn-Musa al-Khwarizmi, who was part of the royal court in Baghdad and who lived from about 780 to 850. Al-Khwarizmi's work is the likely source for the word algebra as well.
A computer program can be viewed as an elaborate algorithm. In mathematics and computer science, an algorithm usually means a small procedure that solves a recurrent problem.       
·         How Java Works
              Have you ever wondered how computer programs work? Have you ever wanted to learn how to write your own computer programs? Whether you are 14 years old and hoping to learn how to write your first game, or you are 70 years old and have been curious about computer programming for 20 years, this article is for you. In this edition of HowStuffWorks, I'm going to teach you how computer programs work by teaching you how to program in the Java programming language.
·         I am going to assume that you know nothing about computer programming now. If you already know something then the first part of this article will seem elementary to you. Please feel free to skip forward until you get to something you don't know.
·         I am going to assume you do know something about the computer you are using. That is, I am going to assume you already know how to edit a file, copy and delete files, rename files, find information on your system, etc.
·         For simplicity, I am going to assume that you are using a machine running Windows 95, 98, 2000, NT or XP. It should be relatively straightforward for people running other operating systems to map the concepts over to those.
·         I am going to assume that you have a desire to learn.

In order to teach you about computer programming, I am going to make several assumptions from the start:
·          
·          
·          
All of the tools you need to start programming in Java are widely available on the Web for free. There is also a huge amount of educational material for Java available on the Web, so once you finish this article you can easily go learn more to advance your skills. You can learn Java programming here without spending any money on compilers, development environments, reading materials, etc. Once you learn Java it is easy to learn other languages, so this is a good place to start.
·         How C Programming Work
The C programming language is a popular and widely used programming language for creating computer programs. Programmers around the world embrace C because it gives maximum control and efficiency to the programmer.
If you are a programmer, or if you are interested in becoming a programmer, there are a couple of benefits you gain from learning C:

·         You will be able to read and write code for a large number of platforms -- everything from microcontrollers to the most advanced scientific systems can be written in C, and many modern operating systems are written in C.
·         The jump to the object oriented C++ language becomes much easier. C++ is an extension of C, and it is nearly impossible to learn C++ without learning C first.
Learn More
·         How JAVA Works
·         How PERL Works
·         Discovery.com: Software Tools

·          
In this article, we will walk through the entire language and show you how to become a C programmer, starting at the beginning. You will be amazed at all of the different things you can create once you know C!
·         How PCs Work
                The word computer refers to an object that can accept some input and produce some output. In fact, the human brain itself is a sophisticated computer, and scientists are learning more about how it works with each passing year. Our most common use of the word computer, though, is to describe an electronic device containing a microprocessor.

  • designed for use by one person at a time
  • runs an operating system to interface between the user and the microprocessor
  • has certain common internal components described in this article, like a CPU and RAM
  • runs software applications designed for specific work or play activities
  • allows for adding and removing hardware or software as needed


A microprocessor is a small electronic device that can carry out complex calculations in the blink of an eye. You can find microprocessors in many devices you use each day, such as cars, refrigerators and televisions. The most recognized device with a microprocessor is the personal computer, or PC. In fact, the concept of a computer has become nearly synonymous with the term PC.
When you hear PC, you probably envision an enclosed device with an attached video screen, keyboard and some type of a pointing device, like a mouse or touchpad. You might also envision different forms of PCs, such as desktop computers, towers and laptops. The term PC has been associated with certain brands, such as Intel processors or Microsoft operating systems. In this article, though, we define a PC as a more general computing device with these characteristics:
PCs trace their history back to the 1970s when a man named Ed Roberts began to sell computer kits based on a microprocessor chip designed by Intel. Roberts called his computer the Altair 8800 and sold the unassembled kits for $395. Popular Electronics ran a story about the kit in its January 1975 issue, and to the surprise of just about everyone, the kits became an instant hit. Thus, the era of the personal computer began [sources: Cerruzi, Lasar].
While the Altair 8800 was the first real personal computer, it was the release of the Apple II a couple of years later that signaled the start of the PC as a sought-after home appliance. The Apple II, from inventors Steve Jobs and Steve Wozniak, proved that there was a demand for computers in homes and schools. Soon after, long-established computer companies like IBM and Texas Instruments jumped into the PC market, and new brands like Commodore and Atari jumped into the game.
In this article, we'll look inside the PC to find out about its parts and what they do. We'll also check out the basic software used to boot and run a PC. Then, we'll cover mobile PCs and examine the future for PC technology.                 
·         How Encryption Works                      
Related Articles
·         How CAPTCHA Works
·         How Internet Cookies Work 
·         How Digital Fingerprinting Works

·          


When we use the Internet, we're not always just clicking around and passively taking in information, such as reading news articles or blog posts -- a great deal of our time online involves sending others our own information. Ordering something over the Internet, whether it's a book, a CD or anything else from an online vendor, or signing up for an online account, requires entering in a good deal of sensitive personal information. A typical transaction might include not only our names, e-mail addresses and physical address and phone number, but also passwords and personal identification numbers (PINs).
The incredible growth of the Internet has excited businesses and consumers alike with its promise of changing the way we live and work. It's extremely easy to buy and sell goods all over the world while sitting in front of alaptop. But security is a major concern on the Internet, especially when you're using it to send sensitive information between parties.
Let's face it, there's a whole lot of information that we don't want other people to see, such as:
·         Credit-card information
·         Social Security numbers
·         Private correspondence
·         Personal details
·         Sensitive company information
·         Bank-account information 

·         How File Compression Works
               If you download many programs and files off the Internet, you've probably encountered ZIP files before. This compression system is a very handy invention, especially for Web users, because it lets you reduce the overall number of bits and bytes in a file so it can be transmitted faster over slower Internet connections, or take up less space on a disk. Once you download the file, your computer uses a program such as WipnZi or Stuffit to expand the file back to its original size. If everything works correctly, the expanded file is identical to the original file before it was compressed.


"Ask not what your country can do for you -- ask what you can do for your country."
·         "ask" appears two times
·         "what" appears two times
·         "your" appears two times
·         "country" appears two times
·         "can" appears two times
·         "do" appears two times
·         "for" appears two times
·         "you" appears two times


At first glance, this seems very mysterious. How can you reduce the number of bits and bytes and then add those exact bits and bytes back later? As it turns out, the basic idea behind the process is fairly straightforward. In this article, we'll examine this simple method as we take a very small file through the basic process of compression.
Most types of computer files are fairly redundant -- they have the same information listed over and over again. File-compression programs simply get rid of the redundancy. Instead of listing a piece of information over and over again, a file-compression program lists that information once and then refers back to it whenever it appears in the original program.
As an example, let's look at a type of information we're all familiar with: words.
In John F. Kennedy's 1961 inaugural address, he delivered this famous line:
The quote has 17 words, made up of 61 letters, 16 spaces, one dash and one period. If each letter, space or punctuation mark takes up one unit of memory, we get a total file size of 79 units. To get the file size down, we need to look for redundancies.
Immediately, we notice that:
Ignoring the difference between capital and lower-case letters, roughly half of the phrase is redundant. Nine words -- ask, not, what, your, country, can, do, for, you -- give us almost everything we need for the entire quote. To construct the second half of the phrase, we just point to the words in the first half and fill in the spaces and punctuation.
We'll look at how file-compression systems deal with redundancy in more detail in the next section.



No comments:

Post a Comment