hello everyone...

im a first year computer science student. I found really tough to solve algorithm and problem solving questions. Do you have any idea or even a good resources. thanks

# algorithm and problem solving

Page 1 of 1## 14 Replies - 1618 Views - Last Post: 15 August 2012 - 10:18 PM

##
**Replies To:** algorithm and problem solving

### #2

## Re: algorithm and problem solving

Posted 15 August 2012 - 07:52 AM

Would you be more specific on the problems and where you are failing? Is it an issue with conceptualizing what is going on? Is it structured logic? Is it syntax?

### #3

## Re: algorithm and problem solving

Posted 15 August 2012 - 07:56 AM

I understand what problem says. but do not know how to approach a diffeeent styles. ya it is in the conceptualizing whats going on. so any idea.

thanks

thanks

### #4

## Re: algorithm and problem solving

Posted 15 August 2012 - 07:59 AM

What's an example of a question you had problems with?

### #5

## Re: algorithm and problem solving

Posted 15 August 2012 - 07:59 AM

and logic part is much harder.

### #6

## Re: algorithm and problem solving

Posted 15 August 2012 - 08:08 AM

Conceptual issues just means you need to find a concrete basis for seeing a problem is done. Think of problems in terms of something you are familiar with... cars/engines.. legos.. people standing in bank.. etc.

As logic - just grab any 'intro to logic' and learn. That's an easy memorization part. Truth tables and such.

You are a freshman comp sci student.. this stuff shouldn't be too easy else why are you paying to learn it? Ha!

As logic - just grab any 'intro to logic' and learn. That's an easy memorization part. Truth tables and such.

You are a freshman comp sci student.. this stuff shouldn't be too easy else why are you paying to learn it? Ha!

### #7

## Re: algorithm and problem solving

Posted 15 August 2012 - 08:09 AM

consider the following problem.

You have a bag with three types of object.

Each turn you remove 2 objects of different types and replace them with an object of the third type.

1.For what starting conditions can we finish with exactly one object in the bag?

2.clearly identify the problem(notation)

-start state.

-end or goal state.

-operators

-constraints and

-any eventual assumptions

3. identify the invariants

4. look for thw symmetry.

5. look for the ways to sub divide the problems.

For me the hardest part is to show the question 1 answer and 5 part.

You have a bag with three types of object.

Each turn you remove 2 objects of different types and replace them with an object of the third type.

1.For what starting conditions can we finish with exactly one object in the bag?

2.clearly identify the problem(notation)

-start state.

-end or goal state.

-operators

-constraints and

-any eventual assumptions

3. identify the invariants

4. look for thw symmetry.

5. look for the ways to sub divide the problems.

For me the hardest part is to show the question 1 answer and 5 part.

### #8

## Re: algorithm and problem solving

Posted 15 August 2012 - 08:31 AM

This is just something you need to work at, but sure.. you can get books on boning up on critical thinking skills.

http://www.amazon.co.../dp/1876462639/

As for that problem - write down what you know and work backwards!

You know there are three objects that can exist... A, B, C.

You want only one object.. so start there.

You also know that two different objects have to be removed to get a third different one..

So you start with object C.

To get C you needed to have removed A and B, right?

To get A you would have needed B and C... and to get that second level B you needed A and C.

On and on and on.. then you can extrapolate that into an equation once you start seeing a pattern.

http://www.amazon.co.../dp/1876462639/

As for that problem - write down what you know and work backwards!

You know there are three objects that can exist... A, B, C.

You want only one object.. so start there.

You also know that two different objects have to be removed to get a third different one..

So you start with object C.

To get C you needed to have removed A and B, right?

C -|-A | |-B

To get A you would have needed B and C... and to get that second level B you needed A and C.

C -|-A-|-B | |-C | | |-B-|-A |-C

On and on and on.. then you can extrapolate that into an equation once you start seeing a pattern.

### #9

## Re: algorithm and problem solving

Posted 15 August 2012 - 08:38 AM

can u do that part . so then i can workout on the other problems.

thanks a lot

thanks a lot

### #10

## Re: algorithm and problem solving

Posted 15 August 2012 - 08:48 AM

Ah.. no. I am not doing your homework.

### #11

## Re: algorithm and problem solving

Posted 15 August 2012 - 08:55 AM

thanks a lot ....this nt a homework

### #12

## Re: algorithm and problem solving

Posted 15 August 2012 - 08:56 AM

Riiiiiiight.. and then what is it?

### #13

## Re: algorithm and problem solving

Posted 15 August 2012 - 09:01 AM

class tutorial we already done nd i dnt get the correct answer.

### #14

## Re: algorithm and problem solving

Posted 15 August 2012 - 09:06 AM

Ahuh.. so homework. Nope.. you need to work it out yourself else you won't learn, right?

If it has already been done then you should have the answer.. and work back from there.

If it has already been done then you should have the answer.. and work back from there.

### #15

## Re: algorithm and problem solving

Posted 15 August 2012 - 10:18 PM

One thing that you will need to learn to do is "play" with these problems. Do some trial error runs, try various groupings, try rephrasing the problem, note interesting patterns and try to apply them generally. Admittedly, this is not the most efficient way to earn the grade, but it most resembles how you will have to cope with the real world. Here is how I went about "playing" with this problem.

1. Prove the opposite. Rather than find starting conditions that succeed, I tried to find starting conditions that fail.

- obvious situations are sets of 2 or more of only one type.

- back track to see what can reduce to such cases. Make sure alternate paths do not produce a solution.

examples: AA <- ABC and any operation on ABC leaves 2 of the same type so ABC is not solvable.

AAA <- AABC but this is solvable because AABC -> ACC -> BC -> B

2. One of the patterns I noticed from my various trials in 1 is that if you have any number of A's you can eliminate them all so long as you have one of the other types. I visualize this as a stack of A's in which a B is fired into the top. The collision results in a C. The C then boomerangs back and knocks of the top of the A's producing a B (hey, visuals help). Repeat until the stack of A's is gone. In this case, an odd number of A's results in a C when all is said and done. An even number would leave a B.

3. Once I had the stack visual, I decided to arrange all items into their 3 respective stacks. I treat the pattern in 2 as a sort of goal state because from there I can solve the problem trivially. For example, if we have 20 A's, 3 B's and 2 C's, then we just perform BC->A twice leaving us with 22 A's and 1 B. The boomerang then solves the problem.

Pursuing 3, I was able to identify exactly the conditions for which we can reduce the objects to a single item. Proving it was the only condition is a whole other can of worms. I leave both of those exercizes for you to play with.

1. Prove the opposite. Rather than find starting conditions that succeed, I tried to find starting conditions that fail.

- obvious situations are sets of 2 or more of only one type.

- back track to see what can reduce to such cases. Make sure alternate paths do not produce a solution.

examples: AA <- ABC and any operation on ABC leaves 2 of the same type so ABC is not solvable.

AAA <- AABC but this is solvable because AABC -> ACC -> BC -> B

2. One of the patterns I noticed from my various trials in 1 is that if you have any number of A's you can eliminate them all so long as you have one of the other types. I visualize this as a stack of A's in which a B is fired into the top. The collision results in a C. The C then boomerangs back and knocks of the top of the A's producing a B (hey, visuals help). Repeat until the stack of A's is gone. In this case, an odd number of A's results in a C when all is said and done. An even number would leave a B.

3. Once I had the stack visual, I decided to arrange all items into their 3 respective stacks. I treat the pattern in 2 as a sort of goal state because from there I can solve the problem trivially. For example, if we have 20 A's, 3 B's and 2 C's, then we just perform BC->A twice leaving us with 22 A's and 1 B. The boomerang then solves the problem.

Pursuing 3, I was able to identify exactly the conditions for which we can reduce the objects to a single item. Proving it was the only condition is a whole other can of worms. I leave both of those exercizes for you to play with.

Page 1 of 1