Uploaded by Красный дьявол

TM111-TMA-all-SPRING (1)-١

advertisement
Faculty of Computer Studies
Course Code: TM111
Course Title: Introduction to computing and information technology 1
Tutor Marked Assignment
Cut-Off Date: TBA
Total Marks: 20
Plagiarism Warning:
As per AOU rules and regulations, all students are required to submit their own TMA work and
avoid plagiarism. The AOU has implemented sophisticated techniques for plagiarism detection.
You must provide all references in case you use and quote another person's work in your TMA.
You will be penalized for any act of plagiarism as per the AOU's rules and regulations.
Declaration of No Plagiarism by Student (to be signed and submitted by student with TMA
work):
I hereby declare that this submitted TMA work is a result of my own efforts and I have not
plagiarized any other person's work. I have provided all references of information that I have
used and quoted in my TMA work.
Important Note:


For all questions you need to write the full algorithm and implement the algorithm
by using OUBILD script. The student should provide provide one screenshot for
the OUBUILD script and two screenshots for differnt outputs.
If you will not provide SCREENSHOTs you will lose grades
Name of Student:
Signature:
Date:
Question 1: (12 marks)
You are requested to write a program according to the following specification:
1. Create a list that contains minimum 12 characters
2. Initialize the list with random characters from alphabetical characters.
3. Sort the characters in the list as follows:
a. find the smallest character in the list and then move it to the first position.
b. Keep doing step a for all characters by finding the smallest character and
moving it to the second position and so on till all the characters in the list
are sorted.
To answer question 1, you need to do the following:
1. Write an algorithm for the sorting process you will follow as described in steps
a and b above.
2. What sorting algorithm did you use?
3. Implement the algorithm using OUBuild script following the above steps.
4. Provide 3 screenshots, one for the code, one for the initial list before sorting,
and one for the list after the sorting is done.
Example: (Note: Make sure to use different list than the one used in the example below
when you answer your question).
Unsorted List
Sorted list
Question 2: (8 marks)
Consider a list of unsorted numbers, think about an algorithm to test all the items in the
list to check whether there are any two consecutive numbers (even if they are not
adjacent) or not.


For example 1: List A = [10,7,23,18,45, 24] -> output: true
o the output is True because 23 and 24 are consecutive numbers (even not
adjacent).
For example 2: List B = [24,15,18,18,42, 22] -> output: false
o the output of example 2 is False because there isn’t any consecutive
numbers.
Now, answer the following Questions:
1- Write an algorithm to solve the above problem?
2- Can you write a new algorithm that is more efficient than the one you wrote in
question1 which does the same job? if the answer is yes you need to write down
the new algorithm, if not you need to mention that your solution is the best solution?
End of the question
Download