Sample Machine Exercises, CS 11 Part 1

Posted to Multiply on

Para sa ating mga CS friends, o sadyang wala lang talagang magawa sa buhay. Ito, sample problems for you to answer.

Please DO NOT POST SOURCE CODES HERE. Source codes can be sent to ardlexworld_90@yahoo,com (kung trip nyo lang). Source codes posted here would be deleted.

Wala lang.

Sample Machine Exercises

I. Calculator

Input

Mathematical statements to be evaluated in infix form.

Output

Result of the requested operation.

Operations Supported

Addition, subtraction, multiplication, division, modulus

Sample Run

1 + 1 = 2

3 – 3 = 0

Additional Notes

By default, all operations are performed from left to right without regard to precedence or associativity of operations. Parentheses are also ignored.

As a challenge, implement the calculator with support for operator precedence and associativity, as well as parenthesized expressions. See the Polish algorithm for more information.

II. Permutation

Input

Alphanumeric word.

Ouput

All possible permutations of the said input.

Sample Run

Input: RED

Output: RED, RDE, DRE, DER, ERD, EDR

Additional Notes

For a given input of length n, there are n! possible permutations.

Maximum length of input is 10.

No need to sort the output alphabetically; just print all possible permutations.

III. Palindromes

Input

Alphanumeric word or sentence.

Output

“Palindrome” if the input is a palindrome; else “Not a palindrome”.

Sample Run

Input:  NO MELON NO LEMON

Output: PALINDROME

Input: NOT A PALINDROME

Output: NOT A PALINDROME

IV. Mathematical Tables

Input

N -> number of rows

O -> number of columns

Output

NxO mathematical tables.

Operations Supported

multiplication, division

Sample Run

Enter row: 2

Enter column: 2

Multiplication Table:

1              2

2              4

Division Table:

1              0.5

2              1

Additional Notes

Rows start at 1, columns at 1.

NxO element = N x O.

V. ASCII Art

Input

Height n

Character c to be used

Ouput

Filled pyramid of height n consisting of the character indicated by user.

Sample Run

Enter height: 5

Enter character to be used: 8

8

888

88888

8888888

888888888

Additional Notes

As a challenge, implement the pyramid as a hollow one.

Enter height: 4

Enter character to be used: 8

8

8  8

8      8

8888888

VI. Bit Shifting

Input

Length of series n

Output

Series of powers of two from 0 to n and 0 to –n

Sample Run:

Enter n> 5

Series:

1 2 4 8 16 32

1 0.5 0.25 0.125 0.0625 0.03125

Additional Notes

Bit shifting SHOULD be the only operation applied.

VII. Fibonacci Series

Input

Length of series n

Output

Fibonacci series from element 1 to n

Sample Run

Enter n> 10

1 1 2 3 5 8 13 21 34 55

VIII. Factorial Series

Input

Length of series n

Output

Factorial values from 1! to n!

Sample Run

Enter n> 10

1 2 6 24 120 720 5040 40320 362880 3628800

IX. Binary Addition

Input

Numbers in binary form

Output

Sum of the two numbers in binary form

Sample Run

Enter addend 1: 11001100

Enter addend 2: 11010011

Sum:                    110011111

X. Coin Flips Generator

Input

Number of coins n

Output

All possible combinations of coins

Sample Run

Number of coins> 4

Possible Combinations:

HHHH

HHHT

HHTH

HHTT

HTHH

HTHT

HTTH

HTTT
THHH

THHT

THTH

THTT

TTHH

TTHT

TTTH

TTTT

Additional Notes

For a given number of coins n, there are a total of 2^n possible combinations.

 

Multiply comments:

acanare
acanare wrote on Dec 1, ’09
haha! defensive…okay lang yan…

thegenuisishere
thegenuisishere wrote on Dec 1, ’09
Kaya nga ME e. It’s supposed to be easy.

Sige. Pag nag-post ako ulit, yung medyo matrabaho na (hindi siguro mahirap, depende sa level mo. Hindi ata tayo magka-wavelength e.).

acanare
acanare wrote on Nov 30, ’09
dali naman nyan…
Advertisements

Mag-iwan ng puna

Filed under Archives, Multiply

Mag-iwan ng Tugon

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Baguhin )

Twitter picture

You are commenting using your Twitter account. Log Out / Baguhin )

Facebook photo

You are commenting using your Facebook account. Log Out / Baguhin )

Google+ photo

You are commenting using your Google+ account. Log Out / Baguhin )

Connecting to %s