English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

hi!
i have just learned to make programs on linked list and have only made two programs--
to find vowels among 5 characters entered
and to enter the marks of 5 students in 3 subjects
can you give me some thoughtful and interesting questions which may not be too difficult for me, and also provide some hints to make programs on them ( at least give 5 questions).
thax

2007-01-17 00:53:53 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

in c++..........

2007-01-17 01:05:12 · update #1

2 answers

[1]

Create a recursive function that calculates the factorial of an integer, N.

int factorial( int N) {

if( N > ?) {
return ? * factorial( ?);
} else {
return ?;
}
}

[2]

Create a factorial function that doesn't use recursion.

int factorial( int N) {
?
while( ?) {
?;
}
return ?;
}

[3]

Why does this method for switching two numbers work and why would anybody have ever used it? *Hint* Think about the environment in the early days of computer programming.

int a = 5;
int b = 7;

a ^= b;
b ^= a;
a ^= b;

[4]

Euclid created an algorithm that can be used to find the Greatest Common Divisor of two integers. Here is the pseudo-code, create the function.

while (B does not equal 0) {
Temp = A modulus B
A = B;
B = Temp;
}

[5]

You are using an environment that limits the length of a number to three digits. Create a function, possibly recursive, that would overcome this limitation and allow you to add four digit numbers. *Hint* Use characters and strings.

COMMENTS :

[1] is meant to introduce you to the concept of recursion which is a handy feature of advanced programming languages. You'll find yourself using it for many things such as binary searches.

[2] is meant to point out that all recursive functions can also be made using WHILE or FOR loops. Recursive functions have inherent memory limitations because each new instance of a recursive call takes up memory so they aren't always the best solution.

[3] is meant to point out how numbers are represented by computers. These days, programmers don't have to worry about memory limitations which has the adverse effect of creating sloppy coding. Be conscious of how efficient the programs you make are. Remember the KISS rule. The best codes are simple and elegant.

[4] is just another example of simple and elegant.

[5]. With object-oriented programming, you are going to have find ways to divide up a problem, solve each one individually, and combine those solutions to create one solution. This will hopefully get you in that mindset as you learn more about programming.

2007-01-17 01:31:15 · answer #1 · answered by Kookiemon 6 · 0 0

Ah, in which programming language?

I can suggest you look up wikipedia that will provide you some functions and some ideas how to write up one.

Note: In java, they provided some classes and methods to allow you to do linked list quickly.

2007-01-17 09:03:05 · answer #2 · answered by Psionic2006 3 · 0 0

fedest.com, questions and answers