Sunday, June 23, 2013

Questions to practice recursion

  1. Find factorial of a number using recursion
  2. Sum of n natural numbers using recursion
  3. Sum of n even numbers using recursion
  4. Sum of n odd numbers using recursion
  5. Sum of the cube of n natural numbers using recursion
  6. Generate Fibonacci series using recursion
  7. Reverse a number using recursion in c program
  8. Check a number for palindrome
  9. Multiplication Table using recursion
  10. Find Lcm using recursion
  11. Using recursion find the largest element in an array
  12. Prime number program using recursion
  13. Print factors of a number using recursion
  14. Print Prime factors of a number using recursion
  15. Decimal to binary conversion using recursion
  16. Reverse a string using recursion
  17. Write a program for checking palindrome string using recursion
  18. Find gcd of a number using recursion in c program
  19. Find sum of digits of a number using recursion
  20. Find power of a number using recursion
  21. Binary search through recursion using
  22. Matrix multiplication using recursion 

Wednesday, June 19, 2013

Operating Systems (OS)

Every computer must have an operating system to run other programs. Operating systems perform basic tasks, such as recognizing input from the keyboard, sending output to the display screen, keeping track of files and directories on the disk, and controlling peripheral devices such as disk drives and printers.

Operating systems provide a software platform on top of which other application programs can run.
The application programs must be written to run on top of a particular operating system. As a user, you normally interact with the operating system through a set of commands through keyboard or Graphical user interfaces, which allow you to enter commands by pointing and clicking at objects that appear on the screen.

Microsoft Disk Operating System

MS DOS (Microsoft Disk Operating System) is an operating system for x86-based personal computers. It was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until superseded by operating systems offering a graphical user interface (GUI), in particular by various generations of the Microsoft Windows operating system.

Operating Systems in use Today

·         Windows 
·         Macintosh 
·         Linux
For PCs, the most popular operating systems are Mac, and Windows, but others are also available, such as Linux.

Macintosh

Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface. The original form of what Apple System Software first introduced in 1984 with the original Macintosh. It was the integral part of the system—an unnamed system software.

Linux

Linux is a Unix-like operating system that was designed to provide personal computer users a free or very low-cost operating system. It has a reputation as a very efficient and fast-performing system. Unlike Windows and other proprietary systems, Linux is publicly open and extendible by contributors.
Linux is sometimes suggested as a possible publicly-developed alternative to the desktop predominance of Microsoft Windows. Although Linux is popular among users already familiar with Unix, it remains far behind Windows in numbers of users. However, its use in the business enterprise is growing.

Microsoft Windows

Microsoft Windows is still the most utilized operating system followed by Mac and Linux.

Development of Windows

·         The first version of Microsoft Windows, version 1.0,  was released in November 1985. It is not a complete operating system; rather, it extends MS-DOS.
·         Microsoft Windows version 2.0 was released in November 1987 and was slightly more popular than its predecessor.
·         Microsoft Windows version 3.0, released in 1990, was the first Microsoft Windows version to achieve broad commercial success. It featured improvements to the user interface and to multitasking capabilities.
·         In July 1993, Microsoft released Windows NT 3.1. It was considered to be the professional OS.
·         On August 24, 1995, Microsoft released Windows 95. It was designed to replace not only Windows 3.1, but also Windows for Workgroups, and MS-DOS. It was also the first Windows operating system to use Plug and Play capabilities.
·         The next in the consumer line was Microsoft Windows 98 released on June 25, 1998.
·         As part of its "professional" line, Microsoft released Windows 2000 in February 2000.
·         In October 2001, Microsoft released Windows XP, a version built on the Windows NT kernel that also retained the consumer-oriented usability of Windows 95 and its successors. It shipped in two distinct editions, "Home" and "Professional", the former lacking many of the superior security and networking features of the Professional edition.
·         On January 30, 2007, Microsoft released Windows Vista. It contains a number of new features, from a redesigned shell and user interface to significant technical changes, with a particular focus on security features. It is available in a number of different editions, and has been subject to some criticism.

·         On October 22, 2009, Microsoft released Windows 7. Unlike its predecessor, Windows Vista, which introduced a large number of new features, Windows 7 was intended to be a more focused, incremental upgrade to the Windows line, with the goal of being compatible with applications and hardware which Windows Vista was not at the time.

Tuesday, June 18, 2013

Recursive function to add natural numbers

Now since you have learnt about recursive methods, here is a recursive method to add natural numbers up to n.

int sumNNumbers(int n) 
{
   if (n < 1)
      return 0;
   else
      return (n + sumNNumbers(n-1));

}


Write the main() method and checkout the function written above.

There is an alternative method of writing the same. Try out this also:

int sumNNumbers(int n) 


{
    return n<1 0="" :="" font="" nbsp="">n + sumNNumbers(n-1);
}

Tuesday, June 11, 2013

Recursion in Java Programming

What Is Recursion in Java Programming?

Recursion is a basic programming technique you can use in Java, in which a method calls itself to solve some problem. A method that uses this technique is recursive. Many programming problems can be solved only by recursion, and some problems that can be solved by other techniques are better solved by recursion.
One of the classic problems for introducing recursion is calculating the factorial of an integer. Thefactorial of any given integer — call it so that you sound mathematical — is the product of all the integers from 1 to n. Thus, the factorial of 5 is 120: 5 x 4 x 3 x 2 x 1.
The recursive way to look at the factorial problem is to realize that the factorial for any given number nis equal to times the factorial of n–1, provided that is greater than 1. If is 1, the factorial of is 1.
This definition of factorial is recursive because the definition includes the factorial method itself. It also includes the most important part of any recursive method: an end condition. The end condition indicates when the recursive method should stop calling itself. In this case, when n is 1, it just returns 1. Without an end condition, the recursive method keeps calling itself forever.
Here’s the recursive version of the factorial method:
private static long factorial(int n)
{
    if (n == 1)
        return 1;
    else
        return n * factorial(n-1);
}

Tuesday, April 14, 2009

My Blog

This blog is for the people interested in learning computer languages.
Rajni kansal